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

Method computeBounds

Engine/source/ts/collada/colladaShapeLoader.cpp:347–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347void ColladaShapeLoader::computeBounds(Box3F& bounds)
348{
349 TSShapeLoader::computeBounds(bounds);
350
351 // Check if the model origin needs adjusting
352 if ( bounds.isValidBox() &&
353 (ColladaUtils::getOptions().adjustCenter ||
354 ColladaUtils::getOptions().adjustFloor) )
355 {
356 // Compute shape offset
357 Point3F shapeOffset = Point3F::Zero;
358 if ( ColladaUtils::getOptions().adjustCenter )
359 {
360 bounds.getCenter( &shapeOffset );
361 shapeOffset = -shapeOffset;
362 }
363 if ( ColladaUtils::getOptions().adjustFloor )
364 shapeOffset.z = -bounds.minExtents.z;
365
366 // Adjust bounds
367 bounds.minExtents += shapeOffset;
368 bounds.maxExtents += shapeOffset;
369
370 // Now adjust all positions for root level nodes (nodes with no parent)
371 for (S32 iNode = 0; iNode < shape->nodes.size(); iNode++)
372 {
373 if ( !appNodes[iNode]->isParentRoot() )
374 continue;
375
376 // Adjust default translation
377 shape->defaultTranslations[iNode] += shapeOffset;
378
379 // Adjust animated translations
380 for (S32 iSeq = 0; iSeq < shape->sequences.size(); iSeq++)
381 {
382 const TSShape::Sequence& seq = shape->sequences[iSeq];
383 if ( seq.translationMatters.test(iNode) )
384 {
385 for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
386 {
387 S32 index = seq.baseTranslation + seq.translationMatters.count(iNode)*seq.numKeyframes + iFrame;
388 shape->nodeTranslations[index] += shapeOffset;
389 }
390 }
391 }
392 }
393 }
394}
395
396//-----------------------------------------------------------------------------
397/// Find the file extension for an extensionless texture

Callers

nothing calls this directly

Calls 6

isValidBoxMethod · 0.45
getCenterMethod · 0.45
sizeMethod · 0.45
isParentRootMethod · 0.45
testMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected