From 855b236ee89eed5362a47deb3049f276040fd276 Mon Sep 17 00:00:00 2001 From: Sebastian Fieber Date: Fri, 25 Jul 2025 21:00:09 +0200 Subject: [PATCH] direction of the sun light != direction to the sun --- apps/openmw/mwlua/weatherbindings.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwlua/weatherbindings.cpp b/apps/openmw/mwlua/weatherbindings.cpp index 624382b293..0024cbdfa1 100644 --- a/apps/openmw/mwlua/weatherbindings.cpp +++ b/apps/openmw/mwlua/weatherbindings.cpp @@ -157,9 +157,11 @@ namespace MWLua api["getCurrentSunLightDirection"] = []() { osg::Vec4f sunPos = MWBase::Environment::get().getWorld()->getSunLightPosition(); + // normalize to get the direction towards the sun sunPos.normalize(); - return sunPos; + // and invert it to get the direction of the sun light + return -sunPos; }; api["getCurrentSunVisibility"] = []() { return MWBase::Environment::get().getWorld()->getSunVisibility(); }; api["getCurrentSunPercentage"] = []() { return MWBase::Environment::get().getWorld()->getSunPercentage(); };