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

Method generateObjects

Engine/source/ts/loader/tsShapeLoader.cpp:402–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402void TSShapeLoader::generateObjects()
403{
404 for (S32 iSub = 0; iSub < subshapes.size(); iSub++)
405 {
406 Subshape* subshape = subshapes[iSub];
407 shape->subShapeFirstObject.push_back(shape->objects.size());
408
409 // Get the names and sizes of the meshes for this subshape
410 Vector<String> meshNames;
411 for (S32 iMesh = 0; iMesh < subshape->objMeshes.size(); iMesh++)
412 {
413 AppMesh* mesh = subshape->objMeshes[iMesh];
414 mesh->detailSize = 2;
415 String name = String::GetTrailingNumber( mesh->getName(), mesh->detailSize );
416 name = getUniqueName( name, cmpMeshNameAndSize, meshNames, &(subshape->objMeshes), (void*)(uintptr_t)mesh->detailSize );
417 meshNames.push_back( name );
418
419 // Fix up any collision details that don't have a negative detail level.
420 if ( dStrStartsWith(meshNames[iMesh], "Collision") ||
421 dStrStartsWith(meshNames[iMesh], "LOSCol") )
422 {
423 if (mesh->detailSize > 0)
424 mesh->detailSize = -mesh->detailSize;
425 }
426 }
427
428 // An 'object' is a collection of meshes with the same base name and
429 // different detail sizes. The object is attached to the node of the
430 // highest detail mesh.
431
432 // Sort the 3 arrays (objMeshes, objNodes, meshNames) by name and size
433 for (S32 i = 0; i < subshape->objMeshes.size()-1; i++)
434 {
435 for (S32 j = i+1; j < subshape->objMeshes.size(); j++)
436 {
437 if ((meshNames[i].compare(meshNames[j]) < 0) ||
438 ((meshNames[i].compare(meshNames[j]) == 0) &&
439 (subshape->objMeshes[i]->detailSize < subshape->objMeshes[j]->detailSize)))
440 {
441 {
442 AppMesh* tmp = subshape->objMeshes[i];
443 subshape->objMeshes[i] = subshape->objMeshes[j];
444 subshape->objMeshes[j] = tmp;
445 }
446 {
447 S32 tmp = subshape->objNodes[i];
448 subshape->objNodes[i] = subshape->objNodes[j];
449 subshape->objNodes[j] = tmp;
450 }
451 {
452 String tmp = meshNames[i];
453 meshNames[i] = meshNames[j];
454 meshNames[j] = tmp;
455 }
456 }
457 }
458 }
459

Callers

nothing calls this directly

Calls 13

dStrStartsWithFunction · 0.85
incrementMethod · 0.80
addNameMethod · 0.80
addDetailMethod · 0.80
getUniqueNameFunction · 0.70
warnfFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
getNameMethod · 0.45
compareMethod · 0.45
lastMethod · 0.45
isBillboardMethod · 0.45

Tested by

no test coverage detected