Use ZDRayInfo's angle and pitch to determine the sun direction

This commit is contained in:
nashmuhandes 2022-02-16 06:42:33 +08:00
parent b42d771e17
commit 7f822dd250

View file

@ -104,6 +104,15 @@ void FLevel::SetupLights()
vec3 sundir(0.0f, 0.0f, 0.0f);
vec3 suncolor(1.0f, 1.0f, 1.0f);
// to do: is the math here correct?
float sdx = (float)std::cos(radians(thing->angle)) * (float)std::cos(radians(thing->pitch));
float sdy = (float)std::sin(radians(thing->angle)) * (float)std::cos(radians(thing->pitch));
float sdz = (float)-std::sin(radians(thing->pitch));
sundir.x = -sdx;
sundir.y = -sdy;
sundir.z = -sdz;
//printf("sun vector: %f, %f, %f\n", sundir.x, sundir.y, sundir.z);
for (unsigned int propIndex = 0; propIndex < thing->props.Size(); propIndex++)
{
const UDMFKey& key = thing->props[propIndex];
@ -111,18 +120,6 @@ void FLevel::SetupLights()
{
lightcolor = atoi(key.value);
}
else if (!stricmp(key.key, "sundirx"))
{
sundir.x = atof(key.value);
}
else if (!stricmp(key.key, "sundiry"))
{
sundir.y = atof(key.value);
}
else if (!stricmp(key.key, "sundirz"))
{
sundir.z = atof(key.value);
}
else if (!stricmp(key.key, "sampledistance"))
{
Samples = atoi(key.value);