| 376 | |
| 377 | |
| 378 | CcpMath::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 | |
| 404 | CcpMath::AxisAlignedBox Tr2InstancedMesh::GetAreaBounds( unsigned int, const Matrix* boneTransforms ) const |
| 405 | { |
no test coverage detected