| 56 | } |
| 57 | |
| 58 | float EveBoxVolume::GetIntensity( Vector3 position ) |
| 59 | { |
| 60 | Vector3 axisAlignedPosition = TransformCoord( position, m_inverseBoxTransform ); |
| 61 | |
| 62 | // Are we outside the outer box? |
| 63 | if( !BoundingBoxIsInside( MIN_AABB, MAX_AABB, axisAlignedPosition ) ) |
| 64 | { |
| 65 | return 0.0f; |
| 66 | } |
| 67 | |
| 68 | Vector3 axisAlignedInnerPosition = TransformCoord( position, m_inverseInnerBoxTransform ); |
| 69 | |
| 70 | // Are we inside the inner box? |
| 71 | if( BoundingBoxIsInside( MIN_AABB, MAX_AABB, axisAlignedInnerPosition ) ) |
| 72 | { |
| 73 | return 1.0f; |
| 74 | } |
| 75 | |
| 76 | Vector3 rayDir = Normalize( -axisAlignedPosition ); |
| 77 | |
| 78 | // we are somewhere in between |
| 79 | IntersectAxisAlignedBoxRay( MIN_AABB, MAX_AABB, axisAlignedPosition, rayDir, m_outerIntersection ); |
| 80 | IntersectAxisAlignedBoxRay( MIN_AABB, MAX_AABB, axisAlignedInnerPosition, rayDir, m_innerIntersection ); |
| 81 | |
| 82 | // move the inner intersection to the outer box space |
| 83 | m_innerIntersection = TransformCoord( m_innerIntersection, m_innerBoxTransform * m_inverseBoxTransform ); |
| 84 | |
| 85 | return LengthSq( axisAlignedPosition - m_outerIntersection ) / LengthSq( m_innerIntersection - m_outerIntersection ); |
| 86 | } |
| 87 | |
| 88 | uint32_t EveBoxVolume::RegisterForChanges( const std::function<void()>& callBack ) |
| 89 | { |
no test coverage detected