MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / copyMesh

Method copyMesh

Engine/source/ts/tsShapeEdit.cpp:911–957  ·  view source on GitHub ↗

Helper to copy a TSMesh ready for adding to this TSShape (with the right vertex format etc)

Source from the content-addressed store, hash-verified

909
910// Helper to copy a TSMesh ready for adding to this TSShape (with the right vertex format etc)
911TSMesh* TSShape::copyMesh( const TSMesh* srcMesh ) const
912{
913 TSMesh * mesh = 0;
914 if ( srcMesh && ( srcMesh->getMeshType() == TSMesh::SkinMeshType ) )
915 {
916 TSSkinMesh* skin = new TSSkinMesh;
917
918 // Copy skin elements
919 const TSSkinMesh *srcSkin = dynamic_cast<const TSSkinMesh*>(srcMesh);
920 skin->weight = srcSkin->weight;
921 skin->vertexIndex = srcSkin->vertexIndex;
922 skin->boneIndex = srcSkin->boneIndex;
923
924 skin->batchData.nodeIndex = srcSkin->batchData.nodeIndex;
925 skin->batchData.initialTransforms = srcSkin->batchData.initialTransforms;
926 skin->batchData.initialVerts = srcSkin->batchData.initialVerts;
927 skin->batchData.initialNorms = srcSkin->batchData.initialNorms;
928
929 mesh = static_cast<TSMesh*>(skin);
930 }
931 else
932 {
933 mesh = new TSMesh;
934 }
935
936 if ( !srcMesh )
937 return mesh; // return an empty mesh
938
939 // Copy mesh elements
940 mesh->mIndices = srcMesh->mIndices;
941 mesh->mPrimitives = srcMesh->mPrimitives;
942 mesh->numFrames = srcMesh->numFrames;
943 mesh->numMatFrames = srcMesh->numMatFrames;
944 mesh->vertsPerFrame = srcMesh->vertsPerFrame;
945 mesh->setFlags(srcMesh->getFlags());
946 mesh->mNumVerts = srcMesh->mNumVerts;
947
948 // Copy vertex data in an *unpacked* form
949 mesh->copySourceVertexDataFrom(srcMesh);
950
951 mesh->createTangents(mesh->mVerts, mesh->mNorms);
952 mesh->mEncodedNorms.set(NULL, 0);
953
954 mesh->computeBounds();
955
956 return mesh;
957}
958
959bool TSShape::addMesh(TSMesh* mesh, const String& meshName)
960{

Callers 2

initMeshFromFileMethod · 0.80
createTriMeshMethod · 0.80

Calls 7

getMeshTypeMethod · 0.80
createTangentsMethod · 0.80
setFlagsMethod · 0.45
getFlagsMethod · 0.45
setMethod · 0.45
computeBoundsMethod · 0.45

Tested by

no test coverage detected