| 99 | } |
| 100 | |
| 101 | void SpotLight::UpdateBounds() |
| 102 | { |
| 103 | // Cache light direction |
| 104 | Vector3::Transform(Vector3::Forward, _transform.Orientation, _direction); |
| 105 | _direction.Normalize(); |
| 106 | |
| 107 | // Cache cone angles |
| 108 | _cosOuterCone = Math::Cos(_outerConeAngle * DegreesToRadians); |
| 109 | _cosInnerCone = Math::Cos(_innerConeAngle * DegreesToRadians); |
| 110 | _invCosConeDifference = 1.0f / Math::Max(_cosInnerCone - _cosOuterCone, 0.0001f); |
| 111 | |
| 112 | // Cache bounds |
| 113 | // Note: we use the law of cosines to find the distance to the furthest edge of the spotlight cone from a position that is halfway down the spotlight direction |
| 114 | const float radius = GetScaledRadius(); |
| 115 | const float boundsRadius = Math::Sqrt(1.25f * radius * radius - radius * radius * _cosOuterCone); |
| 116 | _sphere = BoundingSphere(GetPosition() + 0.5f * GetDirection() * radius, boundsRadius); |
| 117 | BoundingBox::FromSphere(_sphere, _box); |
| 118 | |
| 119 | if (_sceneRenderingKey != -1) |
| 120 | GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); |
| 121 | } |
| 122 | |
| 123 | void SpotLight::OnTransformChanged() |
| 124 | { |
nothing calls this directly
no test coverage detected