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

Method install

Engine/source/ts/loader/tsShapeLoader.cpp:1156–1233  ·  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

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

Tested by

no test coverage detected