MCPcopy Create free account
hub / github.com/carbonengine/trinity / UpdateBoundingBox

Method UpdateBoundingBox

trinity/Tr2RuntimeInstanceData.cpp:464–491  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Updates bounding box (if m_updateBoundingBox flag is set) after data is modified. --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

462// Updates bounding box (if m_updateBoundingBox flag is set) after data is modified.
463// --------------------------------------------------------------------------------------
464void Tr2RuntimeInstanceData::UpdateBoundingBox()
465{
466 if( m_explicitBoundingBox )
467 {
468 return;
469 }
470 unsigned positionOffset = -1;
471 for( auto it = m_layout.m_items.begin(); it != m_layout.m_items.end(); ++it )
472 {
473 if( it->m_usage == Tr2VertexDefinition::POSITION &&
474 it->m_usageIndex == 0 &&
475 Tr2VertexDefinition::GetDataTypeSizeInMembers( it->m_dataType ) >= 3 )
476 {
477 positionOffset = it->m_offset;
478 break;
479 }
480 }
481 m_aabb = CcpMath::AxisAlignedBox();
482 if( positionOffset != -1 )
483 {
484 for( unsigned i = 0; i < m_count; ++i )
485 {
486 const Vector3* pos =
487 reinterpret_cast<Vector3*>( m_data.get() + positionOffset + m_stride * i );
488 m_aabb.Include( *pos );
489 }
490 }
491}
492
493// --------------------------------------------------------------------------------------
494// Description:

Callers 1

RebuildMethod · 0.80

Calls 3

getMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected