We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4b5cd52 commit a1fe3dcCopy full SHA for a1fe3dc
1 file changed
src/Light.cpp
@@ -15,6 +15,11 @@ void DirectionalLight::updateDirection(Vector3 newDirection) {
15
}
16
17
void DirectionalLight::calculateLightDirection() {
18
+ // The trig tables are normally initialised by Scene::Scene(), but
19
+ // a DirectionalLight can be constructed before any Scene exists (e.g.
20
+ // as a struct member alongside a Scene*). Guard against that here so
21
+ // worldLightDir is always valid regardless of construction order.
22
+ if (sin_table[90] == 0) initializeTrigTables();
23
int32_t azimuthDeg = (direction.x + ANGLE_MAX) % ANGLE_MAX; // Keep within 0-359 range
24
int32_t elevationDeg = (direction.y + ANGLE_MAX) % ANGLE_MAX; // Ignore direction.z
25
0 commit comments