TangentSpaceNormalData Class Reference

#include <tangentspacenormalhelper.h>

Detailed Description

A structure that for each vertex in the mesh, stores the vertex cycle and normal data required for conversion of normals to and from object and tangent space. Since the normal tag present on the polygon object does not store topology and vertex cycle information (which polygon around a vertex share the same normal) the cycles are determined by checking if the normals for the given polygons are aligned (within threshold).

Classes

struct  VertexCyclesParallelForContext
 

Public Member Functions

Result< void > CopyFrom (const TangentSpaceNormalData &src)
 
template<typename NEIGHBORTYPE >
Result< void > Init (const Block< const Vector > &points, const Block< const SimplePolygon > &polygons, Block< Vector > &inputNormals, NEIGHBORTYPE &neighbor)
 
Result< void > ComputeUpdatedNormals (const Block< const Vector > &updatedPointPoisitions, const Block< const SimplePolygon > &polygons, const Block< const Vector > &inNormals, Block< Vector > &outNormals) const
 
void Flush ()
 
Bool IsInitialized () const
 
Bool IsTopologyValid (Int32 pointCount, Int32 polygonCount) const
 

Public Attributes

BaseArray< NormalVertexCycles_normalVertexCycles
 

Private Attributes

Int32 _pointCount
 
Int32 _polygonCount
 

Member Function Documentation

◆ CopyFrom()

Result<void> CopyFrom ( const TangentSpaceNormalData src)

◆ Init()

Result<void> Init ( const Block< const Vector > &  points,
const Block< const SimplePolygon > &  polygons,
Block< Vector > &  inputNormals,
NEIGHBORTYPE &  neighbor 
)

Initializes the vertex cycles, converts the input data to a tangent space representation and stores it.

Parameters
[in]pointsThe points of the polygon object.
[in]polygonsThe list of polygons in the object. each polygon is represented by four vertex indices.
[in,out]inputNormalsThe custom input normals in object space. They will be converted to tangent space by this call. inputNormals.GetCount() = 4 * polygons.GetCount(). Normals are stored as (p0vn0, p0vn1, p0vn2, p0vn3, p1vn0, p1vn1, p1vn2, p1vn3, ...).
[in]neighborNeighbor class.
Returns
OK on success, otherwise error.

◆ ComputeUpdatedNormals()

Result<void> ComputeUpdatedNormals ( const Block< const Vector > &  updatedPointPoisitions,
const Block< const SimplePolygon > &  polygons,
const Block< const Vector > &  inNormals,
Block< Vector > &  outNormals 
) const

converts the data from tangent space to object space, and populates the given block with the converted data...

Parameters
[in]updatedPointPoisitionsThe points of the polygon object. These should be the positions after the modifications are completed.
[in]polygonsThe list of polygons in the object. each polygon is represented by four vertex indices.
[out]inNormalsThe normals in tangent space, in general, computed by the ::Init() call.
[out]outNormalsThe custom vertex normals (in object space), outNormals.GetCount() = 4 * polygons.GetCount(). Normals are stored as (p0vn0, p0vn1, p0vn2, p0vn3, p1vn0, p1vn1, p1vn2, p1vn3, ...).
Returns
OK on success, otherwise error.

◆ Flush()

void Flush ( )

Clear all stored normal data and vertex cycles, but do not free memory.

◆ IsInitialized()

Bool IsInitialized ( ) const

Check if the data is initalized. The data is inialized if the number of stored vertex cyclies is greater than zero.

Returns
True if initialized, otherwise false.

◆ IsTopologyValid()

Bool IsTopologyValid ( Int32  pointCount,
Int32  polygonCount 
) const

Check if the topology of the objects is valid. The topology will be valid if the given point count and polygon count are equal to the number of points and polygons used to initialize the data. Note that if the order of points in polygons (topology) changed, but the count did not, this will return true, but the conversion might yield unexpected results. Therefore, inside the deformers, additional logic should be performed (i.e. checking the actual topology) to decide if the normals should be transformed or not.

Parameters
[in]pointCountThe number of points on the updated object, after deformation was performed
[in]polygonCountThe number of polygons on the updated object, after deformation was performed.
Returns
True if valid, otherwise false.

Member Data Documentation

◆ _normalVertexCycles

BaseArray<NormalVertexCycles> _normalVertexCycles

Stores the vertex cycles for each vertex in the mesh. If the data is not disjoined (vertex and all of it's one ring edges are smootly shaded), the vertex will have only a single cycle.

◆ _pointCount

Int32 _pointCount
private

◆ _polygonCount

Int32 _polygonCount
private