diff --git a/data/assets/scene/solarsystem/planets/earth/atmosphere.asset b/data/assets/scene/solarsystem/planets/earth/atmosphere.asset index 574c67cbf2..6392fbc1d2 100644 --- a/data/assets/scene/solarsystem/planets/earth/atmosphere.asset +++ b/data/assets/scene/solarsystem/planets/earth/atmosphere.asset @@ -72,18 +72,15 @@ local Atmosphere = { SaveCalculatedTextures = false }, ShadowGroup = { - Source1 = { - Name = "Sun", - -- All radius in meters - Radius = 696.3E6 - }, - --Source2 = { Name = "Monolith", Radius = 0.01E6, }, - Caster1 = { - Name = "Moon", - -- All radius in meters - Radius = 1.737E6 - } - --Caster2 = { Name = "Independency Day Ship", Radius = 0.0, } + Sources = { + { Name = "Sun", Radius = 696.3E6 }, + -- { Name = "Monolith", Radius = 0.01E6 } + }, + Casters = { + { Name = "Moon", Radius = 1.737E6 }, + -- { Name = "Independence Day Ship", Radius = 0.0 } + + } } }, GUI = { diff --git a/modules/atmosphere/rendering/renderableatmosphere.cpp b/modules/atmosphere/rendering/renderableatmosphere.cpp index 4d81cff2d2..5201d6a8d3 100644 --- a/modules/atmosphere/rendering/renderableatmosphere.cpp +++ b/modules/atmosphere/rendering/renderableatmosphere.cpp @@ -183,24 +183,56 @@ documentation::Documentation RenderableAtmosphere::Documentation() { TableVerifier* shadowGroupTable = new TableVerifier({ { - "*", + "Sources", new TableVerifier({ { - "Name", - new StringVerifier, - Optional::No, - "The scene graph node name of the caster/source" - }, - { - "Radius", - new DoubleVerifier, - Optional::No, - "The radius of the object in meters" + "*", + new TableVerifier({ + { + "Name", + new StringVerifier, + Optional::No, + "The scene graph node name of the source" + }, + { + "Radius", + new DoubleVerifier, + Optional::No, + "The radius of the object in meters" + } + }), + Optional::Yes, + "Individual light sources" } }), Optional::No, - "A list of casters and sources. The sources must be named SourceX and the " - "casters be named CasterX where X is a whole number starting at 1" + "A list of light sources" + }, + { + "Casters", + new TableVerifier({ + { + "*", + new TableVerifier({ + { + "Name", + new StringVerifier, + Optional::No, + "The scene graph node name of the caster" + }, + { + "Radius", + new DoubleVerifier, + Optional::No, + "The radius of the object in meters" + } + }), + Optional::Yes, + "Individual shadow casters" + } + }), + Optional::No, + "A list of objects that cast light on this atmosphere" } }); @@ -282,7 +314,7 @@ documentation::Documentation RenderableAtmosphere::Documentation() { }, { keyMiePhaseConstant, - new DoubleVerifier, + new DoubleInRangeVerifier(-1.0, 1.0), Optional::No, "" } @@ -418,51 +450,36 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary) if (dictionary.hasKey(KeyShadowGroup)) { ghoul::Dictionary shadowDictionary = dictionary.value(KeyShadowGroup); - bool success = true; + + std::vector> sourceArray; - unsigned int sourceCounter = 1; - while (success) { - std::string baseKey = KeyShadowSource + std::to_string(sourceCounter); - success = shadowDictionary.hasKey(baseKey); + ghoul::Dictionary sources = shadowDictionary.value("Sources"); + for (std::string_view k : sources.keys()) { + ghoul::Dictionary source = sources.value(k); - if (success) { - ghoul::Dictionary s = shadowDictionary.value(baseKey); - - std::string sourceName = s.value("Name"); - double sourceRadius = s.value("Radius"); - sourceArray.emplace_back(sourceName, sourceRadius); - } - - sourceCounter++; + std::string name = source.value("Name"); + double radius = source.value("Radius"); + sourceArray.emplace_back(name, radius); } - success = true; std::vector> casterArray; - unsigned int casterCounter = 1; - while (success) { - std::string baseKey = KeyShadowCaster + std::to_string(casterCounter); - success = shadowDictionary.hasKey(baseKey); + ghoul::Dictionary casters = shadowDictionary.value("Casters"); + for (std::string_view k : casters.keys()) { + ghoul::Dictionary caster = casters.value(k); - if (success) { - ghoul::Dictionary s = shadowDictionary.value(baseKey); - std::string casterName = s.value("Name"); - double casterRadius = s.value("Radius"); - casterArray.emplace_back(casterName, casterRadius); - } - - casterCounter++; + std::string name = caster.value("Name"); + double radius = caster.value("Radius"); + casterArray.emplace_back(name, radius); } - if (!sourceArray.empty() && !casterArray.empty()) { - for (const std::pair& source : sourceArray) { - for (const std::pair& caster : casterArray) { - ShadowConfiguration sc; - sc.source = source; - sc.caster = caster; - _shadowConfArray.push_back(sc); - } + _shadowEnabled = !sourceArray.empty() && !casterArray.empty(); + for (const std::pair& source : sourceArray) { + for (const std::pair& caster : casterArray) { + ShadowConfiguration sc; + sc.source = source; + sc.caster = caster; + _shadowConfArray.push_back(sc); } - _shadowEnabled = true; } }