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

Method GetBounds

trinity/Tr2InstancedMesh.cpp:326–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326CcpMath::AxisAlignedBox Tr2InstancedMesh::GetBounds( const Matrix* boneTransforms, const int32_t* meshBindingIndices, size_t boneCount, const Tr2MorphTargetAnimationData* morphTargets, size_t morphTargetsCount ) const
327{
328 CcpMath::AxisAlignedBox aabb;
329 if( m_boundsMethod == STATIC )
330 {
331 aabb.m_min = m_minBounds;
332 aabb.m_max = m_maxBounds;
333 return aabb;
334 }
335 else
336 {
337 auto instanceGeometryResource = GetInstanceGeometryResource();
338 if( !instanceGeometryResource )
339 {
340 return aabb;
341 }
342 aabb = instanceGeometryResource->GetInstanceBufferBoundingBox( m_instanceMeshIndex );
343 if( !aabb )
344 {
345 return aabb;
346 }
347
348 auto instanceSize = m_maxInstanceSize;
349 if( m_boundsMethod == DYNAMIC_SCALED )
350 {
351 CcpMath::AxisAlignedBox instance = GetInstanceBounds();
352 if( instance )
353 {
354 float radius = 0;
355 instance.EnumerateVertices( [&radius]( const Vector3& vtx ) {
356 radius = std::max( radius, LengthSq( vtx ) );
357 } );
358 instanceSize *= sqrt( radius );
359 }
360 }
361 aabb.Grow( instanceSize );
362 return aabb;
363 }
364}
365
366CcpMath::AxisAlignedBox Tr2InstancedMesh::GetInstanceBounds() const
367{

Callers

nothing calls this directly

Calls 3

LengthSqFunction · 0.85
GrowMethod · 0.80

Tested by

no test coverage detected