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

Method install

Engine/source/ts/loader/tsShapeLoader.cpp:1157–1234  ·  view source on GitHub ↗

Install into the TSShape, the shape is expected to be empty. Data is not copied, the TSShape is modified to point to memory managed by this object. This object is also bound to the TSShape object and will be deleted when it's deleted.

Source from the content-addressed store, hash-verified

1155// managed by this object. This object is also bound to the TSShape
1156// object and will be deleted when it's deleted.
1157void TSShapeLoader::install()
1158{
1159 // Arrays that are filled in by ts shape init, but need
1160 // to be allocated beforehand.
1161 shape->subShapeFirstTranslucentObject.setSize(shape->subShapeFirstObject.size());
1162
1163 // Construct TS sub-meshes
1164 shape->meshes.setSize(appMeshes.size());
1165 for (U32 m = 0; m < appMeshes.size(); m++)
1166 shape->meshes[m] = appMeshes[m] ? appMeshes[m]->constructTSMesh() : NULL;
1167
1168 // Remove empty meshes and objects
1169 for (S32 iObj = shape->objects.size()-1; iObj >= 0; iObj--)
1170 {
1171 TSShape::Object& obj = shape->objects[iObj];
1172 for (S32 iMesh = obj.numMeshes-1; iMesh >= 0; iMesh--)
1173 {
1174 TSMesh *mesh = shape->meshes[obj.startMeshIndex + iMesh];
1175
1176 if (mesh && !mesh->mPrimitives.size())
1177 {
1178 S32 oldMeshCount = obj.numMeshes;
1179 destructInPlace(mesh);
1180 shape->removeMeshFromObject(iObj, iMesh);
1181 iMesh -= (oldMeshCount - obj.numMeshes - 1); // handle when more than one mesh is removed
1182 }
1183 }
1184
1185 if (!obj.numMeshes)
1186 shape->removeObject(shape->getName(obj.nameIndex));
1187 }
1188
1189 // Add a dummy object if needed so the shape loads and renders ok
1190 if (!shape->details.size())
1191 {
1192 shape->addDetail("detail", 2, 0);
1193 shape->subShapeNumObjects.last() = 1;
1194
1195 shape->meshes.push_back(NULL);
1196
1197 shape->objects.increment();
1198
1199 TSShape::Object& lastObject = shape->objects.last();
1200 lastObject.nameIndex = shape->addName("dummy");
1201 lastObject.nodeIndex = 0;
1202 lastObject.startMeshIndex = 0;
1203 lastObject.numMeshes = 1;
1204
1205 shape->objectStates.increment();
1206 shape->objectStates.last().frameIndex = 0;
1207 shape->objectStates.last().matFrameIndex = 0;
1208 shape->objectStates.last().vis = 1.0f;
1209 }
1210
1211 // Update smallest visible detail
1212 shape->mSmallestVisibleDL = -1;
1213 shape->mSmallestVisibleSize = 999999;
1214 for (S32 i = 0; i < shape->details.size(); i++)

Callers

nothing calls this directly

Calls 15

destructInPlaceFunction · 0.85
constructTSMeshMethod · 0.80
removeMeshFromObjectMethod · 0.80
addDetailMethod · 0.80
incrementMethod · 0.80
addNameMethod · 0.80
finalizeEditableMethod · 0.80
Box3FClass · 0.50
setSizeMethod · 0.45
sizeMethod · 0.45
removeObjectMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected