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

Method computeBounds

Engine/source/ts/loader/appMesh.cpp:37–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void AppMesh::computeBounds(Box3F& bounds)
38{
39 bounds = Box3F::Invalid;
40
41 if ( isSkin() )
42 {
43 // Need to skin the mesh before we can compute the bounds
44
45 // Setup bone transforms
46 Vector<MatrixF> boneTransforms;
47 boneTransforms.setSize( nodeIndex.size() );
48 for (S32 iBone = 0; iBone < boneTransforms.size(); iBone++)
49 {
50 MatrixF nodeMat = bones[iBone]->getNodeTransform( TSShapeLoader::DefaultTime );
51 TSShapeLoader::zapScale(nodeMat);
52 boneTransforms[iBone].mul( nodeMat, initialTransforms[iBone] );
53 }
54
55 // Multiply verts by weighted bone transforms
56 for (S32 iVert = 0; iVert < initialVerts.size(); iVert++)
57 points[iVert].set( Point3F::Zero );
58
59 for (S32 iWeight = 0; iWeight < vertexIndex.size(); iWeight++)
60 {
61 const S32& vertIndex = vertexIndex[iWeight];
62 const MatrixF& deltaTransform = boneTransforms[ boneIndex[iWeight] ];
63
64 Point3F v;
65 deltaTransform.mulP( initialVerts[vertIndex], &v );
66 v *= weight[iWeight];
67
68 points[vertIndex] += v;
69 }
70
71 // compute bounds for the skinned mesh
72 for (S32 iVert = 0; iVert < initialVerts.size(); iVert++)
73 bounds.extend( points[iVert] );
74 }
75 else
76 {
77 MatrixF transform = getMeshTransform(TSShapeLoader::DefaultTime);
78 TSShapeLoader::zapScale(transform);
79
80 for (S32 iVert = 0; iVert < points.size(); iVert++)
81 {
82 Point3F p;
83 transform.mulP(points[iVert], &p);
84 bounds.extend(p);
85 }
86 }
87}
88
89void AppMesh::computeNormals()
90{

Callers 1

constructTSMeshMethod · 0.45

Calls 7

mulPMethod · 0.80
extendMethod · 0.80
setSizeMethod · 0.45
sizeMethod · 0.45
getNodeTransformMethod · 0.45
mulMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected