MCPcopy Create free account
hub / github.com/carbonengine/trinity / IsAreaMorphed

Method IsAreaMorphed

trinity/Resources/TriGeometryRes.cpp:819–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

817}
818
819bool TriGeometryRes::IsAreaMorphed( TriGeometryResAreaData& area, granny_mesh* myMesh, granny_file_info* gi )
820{
821 CCP_STATS_ZONE( __FUNCTION__ );
822
823 if( myMesh->MorphTargetCount == 0 )
824 {
825 return false;
826 }
827
828 const float EPSILON = .001f;
829
830 // primary mesh vertex declaration
831 granny_data_type_definition* grannyVertexDecl = myMesh->PrimaryVertexData->VertexType;
832 Tr2VertexDefinition vertexDefinition = BuildFromGrannyVertexDecl( grannyVertexDecl );
833
834 // morph target vertex declaration
835 granny_data_type_definition* grannyMorphVertexDecl = myMesh->MorphTargets[0].VertexData->VertexType;
836 Tr2VertexDefinition vertexMorphDefinition = BuildFromGrannyVertexDecl( grannyMorphVertexDecl );
837
838 MorphToBaseData baseData = InitMorphToBaseData( vertexDefinition );
839 MorphToBaseData morphData = InitMorphToBaseData( vertexMorphDefinition );
840
841 // let's try to find at least one vertex that is being affected by at least one morph target
842 bool dataIsDeltas = myMesh->MorphTargets->DataIsDeltas;
843 auto pVertices = (uint8_t*)GrannyGetMeshVertices( myMesh );
844
845 for( int i = 0; i < myMesh->MorphTargetCount; ++i )
846 {
847 auto pMorphSrc = (uint8_t*)GrannyGetMeshMorphVertices( myMesh, i );
848
849 for( int vIx = 0; vIx < area.m_primitiveCount * 3; ++vIx )
850 {
851 int index;
852
853 if( myMesh->PrimaryTopology->Indices16 )
854 {
855 index = myMesh->PrimaryTopology->Indices16[vIx + area.m_firstIndex];
856 }
857 else
858 {
859 index = myMesh->PrimaryTopology->Indices[vIx + area.m_firstIndex];
860 }
861
862 float squaredDist = SquaredDistMorphToBase( index, dataIsDeltas, pVertices, baseData, pMorphSrc, morphData );
863 if( squaredDist > EPSILON )
864 {
865 return true;
866 }
867 }
868 }
869
870 return false;
871}
872#endif
873
874bool TriGeometryRes::SetupMeshes( const cmf::Data& cmfData )

Callers

nothing calls this directly

Calls 3

InitMorphToBaseDataFunction · 0.85
SquaredDistMorphToBaseFunction · 0.85

Tested by

no test coverage detected