diff --git a/src/ecs/systems/atmosphere-system.cpp b/src/ecs/systems/atmosphere-system.cpp index f49888c..a912d5b 100644 --- a/src/ecs/systems/atmosphere-system.cpp +++ b/src/ecs/systems/atmosphere-system.cpp @@ -23,12 +23,10 @@ namespace ecs { atmosphere_system::atmosphere_system(ecs::registry& registry): - entity_system(registry) + entity_system(registry), + rgb_wavelengths_nm{0, 0, 0}, + rgb_wavelengths_m{0, 0, 0} { - // RGB wavelengths determined by matching wavelengths to XYZ, transforming XYZ to ACEScg, then selecting the max wavelengths for R, G, and B. - rgb_wavelengths_nm = {602.224, 541.069, 448.143}; - rgb_wavelengths_m = rgb_wavelengths_nm * 1e-9; - registry.on_construct().connect<&atmosphere_system::on_atmosphere_construct>(this); registry.on_replace().connect<&atmosphere_system::on_atmosphere_replace>(this); } @@ -36,6 +34,12 @@ atmosphere_system::atmosphere_system(ecs::registry& registry): void atmosphere_system::update(double t, double dt) {} +void atmosphere_system::set_rgb_wavelengths(const double3& wavelengths) +{ + rgb_wavelengths_nm = wavelengths; + rgb_wavelengths_m = wavelengths * 1e-9; +} + void atmosphere_system::update_coefficients(ecs::entity entity) { // Abort if entity has no atmosphere component diff --git a/src/ecs/systems/atmosphere-system.hpp b/src/ecs/systems/atmosphere-system.hpp index 1b6252b..442287c 100644 --- a/src/ecs/systems/atmosphere-system.hpp +++ b/src/ecs/systems/atmosphere-system.hpp @@ -38,6 +38,13 @@ public: virtual void update(double t, double dt); + /** + * Sets the wavelengths of red, green, and blue light. + * + * @param wavelengths Vector containing the wavelengths of red (x), green (y), and blue (z) light, in nanometers. + */ + void set_rgb_wavelengths(const double3& wavelengths); + private: void update_coefficients(ecs::entity entity); diff --git a/src/ecs/systems/blackbody-system.cpp b/src/ecs/systems/blackbody-system.cpp index dfde8ef..c9f7631 100644 --- a/src/ecs/systems/blackbody-system.cpp +++ b/src/ecs/systems/blackbody-system.cpp @@ -26,12 +26,10 @@ namespace ecs { blackbody_system::blackbody_system(ecs::registry& registry): - entity_system(registry) + entity_system(registry), + rgb_wavelengths_nm{0, 0, 0}, + rgb_wavelengths_m{0, 0, 0} { - // RGB wavelengths determined by matching wavelengths to XYZ, transforming XYZ to ACEScg, then selecting the max wavelengths for R, G, and B. - rgb_wavelengths_nm = {602.224, 541.069, 448.143}; - rgb_wavelengths_m = rgb_wavelengths_nm * 1e-9; - // Construct a range of sample wavelengths in the visible spectrum visible_wavelengths_nm.resize(780 - 280); std::iota(visible_wavelengths_nm.begin(), visible_wavelengths_nm.end(), 280); @@ -46,6 +44,12 @@ blackbody_system::blackbody_system(ecs::registry& registry): void blackbody_system::update(double t, double dt) {} +void blackbody_system::set_rgb_wavelengths(const double3& wavelengths) +{ + rgb_wavelengths_nm = wavelengths; + rgb_wavelengths_m = wavelengths * 1e-9; +} + void blackbody_system::update_luminous_intensity(ecs::entity entity) { // Abort if entity has no blackbody component diff --git a/src/ecs/systems/blackbody-system.hpp b/src/ecs/systems/blackbody-system.hpp index 4715cdd..1c55ca2 100644 --- a/src/ecs/systems/blackbody-system.hpp +++ b/src/ecs/systems/blackbody-system.hpp @@ -40,6 +40,13 @@ public: virtual void update(double t, double dt); + /** + * Sets the wavelengths of red, green, and blue light. + * + * @param wavelengths Vector containing the wavelengths of red (x), green (y), and blue (z) light, in nanometers. + */ + void set_rgb_wavelengths(const double3& wavelengths); + private: void update_luminous_intensity(ecs::entity entity); diff --git a/src/game/bootloader.cpp b/src/game/bootloader.cpp index 256d8c1..5877507 100644 --- a/src/game/bootloader.cpp +++ b/src/game/bootloader.cpp @@ -789,6 +789,9 @@ void setup_systems(game_context* ctx) const auto& viewport_dimensions = ctx->app->get_viewport_dimensions(); float4 viewport = {0.0f, 0.0f, static_cast(viewport_dimensions[0]), static_cast(viewport_dimensions[1])}; + // RGB wavelengths determined by matching wavelengths to XYZ, transforming XYZ to ACEScg, then selecting the max wavelengths for R, G, and B. + const double3 rgb_wavelengths_nm = {602.224, 541.069, 448.143}; + // Setup terrain system ctx->terrain_system = new ecs::terrain_system(*ctx->ecs_registry, ctx->resource_manager); ctx->terrain_system->set_patch_size(TERRAIN_PATCH_SIZE); @@ -864,9 +867,11 @@ void setup_systems(game_context* ctx) // Setup blackbody system ctx->blackbody_system = new ecs::blackbody_system(*ctx->ecs_registry); + ctx->blackbody_system->set_rgb_wavelengths(rgb_wavelengths_nm); // Setup atmosphere system ctx->atmosphere_system = new ecs::atmosphere_system(*ctx->ecs_registry); + ctx->atmosphere_system->set_rgb_wavelengths(rgb_wavelengths_nm); // Setup astronomy system ctx->astronomy_system = new ecs::astronomy_system(*ctx->ecs_registry); diff --git a/src/game/game-context.hpp b/src/game/game-context.hpp index 5395c0d..02e0fb7 100644 --- a/src/game/game-context.hpp +++ b/src/game/game-context.hpp @@ -36,6 +36,7 @@ #include "input/mapper.hpp" #include "input/event-router.hpp" #include "animation/tween.hpp" +#include "scene/scene.hpp" #include #include #include @@ -98,8 +99,6 @@ namespace ecs class samara_system; } -#include "scene/scene.hpp" - /** * */ @@ -206,7 +205,7 @@ struct game_context screen_transition* radial_transition_outer; animation* equip_tool_animation; animation* unequip_tool_animation; - + // Controls input::event_router* input_event_router; input::mapper* input_mapper;