From 25345c2477b89f9c99a4b7b7761684df8939be0f Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Sun, 20 Feb 2022 04:46:19 +0800 Subject: [PATCH] Replace Thing UDMF keys for the ZDRayInfo with args instead --- README.md | 4 ---- src/level/level_light.cpp | 45 ++++++++++++++++----------------------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index dc72871..d12803e 100644 --- a/README.md +++ b/README.md @@ -52,10 +52,6 @@ Usage: zdray [options] sourcefile.wad thing // ZDRayInfo (ZDRay properties for the map) { type = 9890; - suncolor = <int> (color) - sampledistance = <int> (default: 8, map units each lightmap texel covers, must be in powers of two) - bounces = <int> (default: 1, how many times light bounces off walls) - gridsize = <float> (default: 32, grid density for the automatic light probes) } thing // Static point light (Light color and distance properties use the same args as dynamic lights) diff --git a/src/level/level_light.cpp b/src/level/level_light.cpp index d24adb9..e4ede04 100644 --- a/src/level/level_light.cpp +++ b/src/level/level_light.cpp @@ -113,33 +113,24 @@ void FLevel::SetupLights() 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]; - if (!stricmp(key.key, "suncolor")) - { - lightcolor = atoi(key.value); - } - else if (!stricmp(key.key, "sampledistance")) - { - Samples = atoi(key.value); - if (Samples <= 0) Samples = 1; - if (Samples > 128) Samples = 128; - Samples = Math::RoundPowerOfTwo(Samples); - } - else if (!stricmp(key.key, "bounces")) - { - LightBounce = atoi(key.value); - if (LightBounce < 0) LightBounce = 0; - if (LightBounce > 8) LightBounce = 8; - } - else if (!stricmp(key.key, "gridsize")) - { - GridSize = atof(key.value); - if (GridSize < 0.f) GridSize = 0.f; - if (GridSize > 1024.f) GridSize = 1024.f; - } - } + // sun color + lightcolor = thing->args[0]; + + // sample distance + Samples = thing->args[1]; + if (Samples <= 0) Samples = 1; + if (Samples > 128) Samples = 128; + Samples = Math::RoundPowerOfTwo(Samples); + + // number of light bounces + LightBounce = thing->args[2]; + if (LightBounce < 0) LightBounce = 0; + if (LightBounce > 8) LightBounce = 8; + + // auto probe grid size + GridSize = thing->args[3]; + if (GridSize < 0.f) GridSize = 0.f; + if (GridSize > 1024.f) GridSize = 1024.f; if (dot(sundir, sundir) > 0.01f) {