MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / UpdateBounds

Method UpdateBounds

Source/Engine/Level/Actors/SpotLight.cpp:101–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void 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
123void SpotLight::OnTransformChanged()
124{

Callers

nothing calls this directly

Calls 9

GetDirectionFunction · 0.85
UpdateActorMethod · 0.80
TransformClass · 0.50
CosFunction · 0.50
MaxFunction · 0.50
SqrtFunction · 0.50
BoundingSphereClass · 0.50
GetPositionFunction · 0.50
NormalizeMethod · 0.45

Tested by

no test coverage detected