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

Method computeBounds

Engine/source/ts/tsShape.cpp:1047–1102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045Vector<MatrixF> gTempNodeTransforms(__FILE__, __LINE__);
1046
1047void TSShape::computeBounds(S32 dl, Box3F & bounds) const
1048{
1049 // if dl==-1, nothing to do
1050 if (dl==-1)
1051 return;
1052
1053 AssertFatal(dl>=0 && dl<details.size(),"TSShapeInstance::computeBounds");
1054
1055 // get subshape and object detail
1056 const TSDetail * detail = &details[dl];
1057 S32 ss = detail->subShapeNum;
1058 S32 od = detail->objectDetailNum;
1059
1060 // If we have no subshapes then there is
1061 // no valid bounds for this detail level.
1062 if ( ss < 0 )
1063 return;
1064
1065 // set up temporary storage for non-local transforms...
1066 S32 i;
1067 S32 start = subShapeFirstNode[ss];
1068 S32 end = subShapeNumNodes[ss] + start;
1069 gTempNodeTransforms.setSize(end-start);
1070 for (i=start; i<end; i++)
1071 {
1072 MatrixF mat;
1073 QuatF q;
1074 TSTransform::setMatrix(defaultRotations[i].getQuatF(&q),defaultTranslations[i],&mat);
1075 if (nodes[i].parentIndex>=0)
1076 gTempNodeTransforms[i-start].mul(gTempNodeTransforms[nodes[i].parentIndex-start],mat);
1077 else
1078 gTempNodeTransforms[i-start] = mat;
1079 }
1080
1081 // run through objects and updating bounds as we go
1082 bounds.minExtents.set( 10E30f, 10E30f, 10E30f);
1083 bounds.maxExtents.set(-10E30f,-10E30f,-10E30f);
1084 Box3F box;
1085 start = subShapeFirstObject[ss];
1086 end = subShapeNumObjects[ss] + start;
1087 for (i=start; i<end; i++)
1088 {
1089 const Object * object = &objects[i];
1090 TSMesh * mesh = od<object->numMeshes ? meshes[object->startMeshIndex+od] : NULL;
1091 if (mesh)
1092 {
1093 static MatrixF idMat(true);
1094 if (object->nodeIndex<0)
1095 mesh->computeBounds(idMat,box);
1096 else
1097 mesh->computeBounds(gTempNodeTransforms[object->nodeIndex-start],box);
1098 bounds.minExtents.setMin(box.minExtents);
1099 bounds.maxExtents.setMax(box.maxExtents);
1100 }
1101 }
1102}
1103
1104TSShapeAlloc TSShape::smTSAlloc;

Callers

nothing calls this directly

Calls 7

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