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

Method GetInstanceBoundsClosestToPoint

trinity/Tr2InstancedMesh.cpp:378–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376
377
378CcpMath::Sphere Tr2InstancedMesh::GetInstanceBoundsClosestToPoint( const Vector3& point ) const
379{
380 float instanceSize = m_maxInstanceSize;
381 switch( m_boundsMethod )
382 {
383 case Tr2InstancedMesh::DYNAMIC:
384 break;
385 case Tr2InstancedMesh::DYNAMIC_SCALED: {
386 float radius = 0;
387 GetInstanceBounds().EnumerateVertices( [&radius]( const Vector3& vtx ) {
388 radius = std::max( radius, LengthSq( vtx ) );
389 } );
390 instanceSize *= sqrt( radius );
391 break;
392 }
393 default:
394 return {};
395 }
396 auto outerBounds = GetBounds();
397 outerBounds.Grow( -instanceSize );
398
399 Vector3 closestPoint = ClosestPointToBoundingBox( outerBounds.m_min, outerBounds.m_max, point );
400
401 return CcpMath::Sphere( closestPoint, instanceSize );
402}
403
404CcpMath::AxisAlignedBox Tr2InstancedMesh::GetAreaBounds( unsigned int, const Matrix* boneTransforms ) const
405{

Callers 3

IsCastingShadowMethod · 0.80
UpdateVisibilityMethod · 0.80
IsCastingShadowMethod · 0.80

Calls 3

LengthSqFunction · 0.85
GrowMethod · 0.80

Tested by

no test coverage detected