| 324 | } |
| 325 | |
| 326 | CcpMath::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 | |
| 366 | CcpMath::AxisAlignedBox Tr2InstancedMesh::GetInstanceBounds() const |
| 367 | { |
nothing calls this directly
no test coverage detected