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

Method computeBounds

Engine/source/ts/tsShape.cpp:1087–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1085Vector<MatrixF> gTempNodeTransforms(__FILE__, __LINE__);
1086
1087void TSShape::computeBounds(S32 dl, Box3F & bounds) const
1088{
1089 // if dl==-1, nothing to do
1090 if (dl==-1)
1091 return;
1092
1093 AssertFatal(dl>=0 && dl<details.size(),"TSShapeInstance::computeBounds");
1094
1095 // get subshape and object detail
1096 const TSDetail * detail = &details[dl];
1097 S32 ss = detail->subShapeNum;
1098 S32 od = detail->objectDetailNum;
1099
1100 // If we have no subshapes then there is
1101 // no valid bounds for this detail level.
1102 if ( ss < 0 )
1103 return;
1104
1105 // set up temporary storage for non-local transforms...
1106 S32 i;
1107 S32 start = subShapeFirstNode[ss];
1108 S32 end = subShapeNumNodes[ss] + start;
1109 gTempNodeTransforms.setSize(end-start);
1110 for (i=start; i<end; i++)
1111 {
1112 MatrixF mat;
1113 QuatF q;
1114 TSTransform::setMatrix(defaultRotations[i].getQuatF(&q),defaultTranslations[i],&mat);
1115 if (nodes[i].parentIndex>=0)
1116 gTempNodeTransforms[i-start].mul(gTempNodeTransforms[nodes[i].parentIndex-start],mat);
1117 else
1118 gTempNodeTransforms[i-start] = mat;
1119 }
1120
1121 // run through objects and updating bounds as we go
1122 bounds.minExtents.set( 10E30f, 10E30f, 10E30f);
1123 bounds.maxExtents.set(-10E30f,-10E30f,-10E30f);
1124 Box3F box;
1125 start = subShapeFirstObject[ss];
1126 end = subShapeNumObjects[ss] + start;
1127 for (i=start; i<end; i++)
1128 {
1129 const Object * object = &objects[i];
1130 TSMesh * mesh = od<object->numMeshes ? meshes[object->startMeshIndex+od] : NULL;
1131 if (mesh)
1132 {
1133 static MatrixF idMat(true);
1134 if (object->nodeIndex<0)
1135 mesh->computeBounds(idMat,box);
1136 else
1137 mesh->computeBounds(gTempNodeTransforms[object->nodeIndex-start],box);
1138 bounds.minExtents.setMin(box.minExtents);
1139 bounds.maxExtents.setMax(box.maxExtents);
1140 }
1141 }
1142}
1143
1144TSShapeAlloc TSShape::smTSAlloc;

Callers

nothing calls this directly

Calls 8

setMatrixFunction · 0.85
getQuatFMethod · 0.80
sizeMethod · 0.45
setSizeMethod · 0.45
mulMethod · 0.45
setMethod · 0.45
setMinMethod · 0.45
setMaxMethod · 0.45

Tested by

no test coverage detected