diff --git a/CMakeLists.txt b/CMakeLists.txt index 912a62c..c6a07b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ cmake_minimum_required(VERSION 3.25) - option(APPLICATION_NAME "Application name" "Antkeeper") option(APPLICATION_VERSION "Application version string" "0.0.0") option(APPLICATION_AUTHOR "Application author" "C. J. Howard") @@ -9,7 +8,6 @@ option(APPLICATION_AUTHOR "Application author" "C. J. Howard") string(TOLOWER ${APPLICATION_NAME} APPLICATION_SLUG) string(REPLACE " " "-" APPLICATION_SLUG ${APPLICATION_SLUG}) - project(${APPLICATION_SLUG} VERSION ${APPLICATION_VERSION} LANGUAGES CXX) set(APPLICATION_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) @@ -43,8 +41,7 @@ set(SHARED_LIBS ${OPENGL_gl_LIBRARY}) # Generate configuration header file -configure_file(${PROJECT_SOURCE_DIR}/src/engine/config.hpp.in - ${PROJECT_BINARY_DIR}/src/engine/config.hpp) +configure_file(${PROJECT_SOURCE_DIR}/src/engine/config.hpp.in ${PROJECT_BINARY_DIR}/src/engine/config.hpp) # Collect source files file(GLOB_RECURSE SOURCE_FILES @@ -81,11 +78,22 @@ endif() # Add executable target set(EXECUTABLE_TARGET ${APPLICATION_SLUG}-executable) add_executable(${EXECUTABLE_TARGET} ${SOURCE_FILES}) -set_target_properties(${EXECUTABLE_TARGET} PROPERTIES OUTPUT_NAME ${APPLICATION_SLUG}) +set_target_properties(${EXECUTABLE_TARGET} PROPERTIES + OUTPUT_NAME ${APPLICATION_SLUG} + COMPILE_WARNING_AS_ERROR ON + CXX_STANDARD 23 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF) +target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) if(MSVC) - # Select the static multithreaded MSVC runtime library - set_property(TARGET ${EXECUTABLE_TARGET} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + target_compile_options(${EXECUTABLE_TARGET} PRIVATE /W3) + set_target_properties(${EXECUTABLE_TARGET} PROPERTIES + LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE" + LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:\"mainCRTStartup\"" + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +else() + target_compile_options(${EXECUTABLE_TARGET} PRIVATE -Wall -Wextra -Wpedantic) endif() # Add compile definitions @@ -95,24 +103,10 @@ else() target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE NDEBUG) endif() -# Set C++ standard -set_target_properties(${EXECUTABLE_TARGET} PROPERTIES - CXX_STANDARD 23 - CXX_STANDARD_REQUIRED ON - CXX_EXTENSIONS OFF) - -# Set link flags to show console window on debug builds and hide it on release builds -if(MSVC) - #set_target_properties(${EXECUTABLE_TARGET} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libvcruntime.lib") - set_target_properties(${EXECUTABLE_TARGET} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") - set_target_properties(${EXECUTABLE_TARGET} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:\"mainCRTStartup\"") -endif(MSVC) - # Set include directories -target_include_directories(${EXECUTABLE_TARGET} - PUBLIC - ${PROJECT_SOURCE_DIR}/src - ${PROJECT_BINARY_DIR}/src) +target_include_directories(${EXECUTABLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_BINARY_DIR}/src) # Link to dependencies target_link_libraries(${EXECUTABLE_TARGET} ${STATIC_LIBS} ${SHARED_LIBS}) @@ -121,22 +115,5 @@ target_link_libraries(${EXECUTABLE_TARGET} ${STATIC_LIBS} ${SHARED_LIBS}) if(PACKAGE_PLATFORM MATCHES "linux") install(TARGETS ${EXECUTABLE_TARGET} DESTINATION bin) elseif(PACKAGE_PLATFORM MATCHES "win") - # Install executable install(TARGETS ${EXECUTABLE_TARGET} DESTINATION .) - - # Install SDL2 DLLs - #if(CMAKE_BUILD_TYPE STREQUAL "Debug") - # get_target_property(SDL2_DLL SDL2::SDL2 IMPORTED_LOCATION_DEBUG) - #else() - # get_target_property(SDL2_DLL SDL2::SDL2 IMPORTED_LOCATION_RELEASE) - #endif() - #install(FILES ${SDL2_DLL} DESTINATION .) - - # Install OpenAL DLL - #if(CMAKE_BUILD_TYPE STREQUAL "Debug") - # get_target_property(OPENAL_DLL OpenAL::OpenAL IMPORTED_LOCATION_DEBUG) - #else() - # get_target_property(OPENAL_DLL OpenAL::OpenAL IMPORTED_LOCATION_RELEASE) - #endif() - #install(FILES ${OPENAL_DLL} DESTINATION .) endif() diff --git a/src/engine/animation/animation-channel.hpp b/src/engine/animation/animation-channel.hpp index 62f0896..3c6bca5 100644 --- a/src/engine/animation/animation-channel.hpp +++ b/src/engine/animation/animation-channel.hpp @@ -34,7 +34,7 @@ class animation_channel { public: /// Keyframe consisting of a time and a value. - typedef std::tuple keyframe; + typedef std::tuple keyframe; /** * Creates an animation channel. @@ -65,7 +65,7 @@ public: * @param start Starting position in time (inclusive). * @param end Ending position in time (non-inclusive). */ - void remove_keyframes(double start, double end); + void remove_keyframes(float start, float end); /// Removes all keyframes from the animation. void remove_keyframes(); @@ -76,7 +76,7 @@ public: * @param position Position in time. * @return Array containing the the keyframes on the left and right of @p position. */ - std::array find_keyframes(double position) const; + std::array find_keyframes(float position) const; /** * Finds all the keyframes on `[start, end)`. @@ -85,13 +85,13 @@ public: * @param end Ending position in time (non-inclusive). * @return All keyframes on `[start, end)`. */ - std::list find_keyframes(double start, double end) const; + std::list find_keyframes(float start, float end) const; /// Returns the ID of the animation channel. int get_id() const; /// Returns the duration of the animation channel. - double get_duration() const; + float get_duration() const; private: struct keyframe_compare @@ -138,7 +138,7 @@ void animation_channel::insert_keyframe(const keyframe& k) } template -void animation_channel::remove_keyframes(double start, double end) +void animation_channel::remove_keyframes(float start, float end) { auto lower_bound = keyframes.lower_bound({start, T()}); auto upper_bound = keyframes.upper_bound({end, T()}); @@ -152,7 +152,7 @@ void animation_channel::remove_keyframes() } template -std::array::keyframe*, 2> animation_channel::find_keyframes(double position) const +std::array::keyframe*, 2> animation_channel::find_keyframes(float position) const { // Find the following keyframe auto upper_bound = keyframes.upper_bound({position, T()}); @@ -169,7 +169,7 @@ std::array::keyframe*, 2> animation_channel< } template -std::list::keyframe> animation_channel::find_keyframes(double start, double end) const +std::list::keyframe> animation_channel::find_keyframes(float start, float end) const { std::list keyframe_list; @@ -190,7 +190,7 @@ inline int animation_channel::get_id() const } template -double animation_channel::get_duration() const +float animation_channel::get_duration() const { if (keyframes.empty()) { diff --git a/src/engine/animation/animation.cpp b/src/engine/animation/animation.cpp index 3900189..665b5cf 100644 --- a/src/engine/animation/animation.cpp +++ b/src/engine/animation/animation.cpp @@ -31,7 +31,7 @@ animation_base::animation_base(): loop_callback(nullptr) {} -void animation_base::seek(double t) +void animation_base::seek(float t) { position = t; } @@ -74,7 +74,7 @@ void animation_base::stop() loop_count = 0; } -void animation_base::set_speed(double speed) +void animation_base::set_speed(float speed) { this->speed = speed; } diff --git a/src/engine/animation/animation.hpp b/src/engine/animation/animation.hpp index be81afd..b0f4c66 100644 --- a/src/engine/animation/animation.hpp +++ b/src/engine/animation/animation.hpp @@ -39,14 +39,14 @@ public: * * @param dt Delta time by which the animation position will be advanced. */ - virtual void advance(double dt) = 0; + virtual void advance(float dt) = 0; /** * Sets the animation position to @p t. * * @param t Position in time to which the animation position will be set. */ - void seek(double t); + void seek(float t); /// Sets the animation position to `0.0`. void rewind(); @@ -68,7 +68,7 @@ public: * * @param speed Speed multiplier. */ - void set_speed(double speed); + void set_speed(float speed); /// Returns `true` if looping of the animation is enabled, `false` otherwise. bool is_looped() const; @@ -80,13 +80,13 @@ public: bool is_stopped() const; /// Returns the current position in time of the animation. - double get_position() const; + float get_position() const; /// Returns the current loop count of the animation. int get_loop_count() const; /// Returns the duration of the animation. - virtual double get_duration() const = 0; + virtual float get_duration() const = 0; /// Sets the callback that's executed when the animation is started from a stopped state. void set_start_callback(std::function callback); @@ -106,8 +106,8 @@ protected: int loop_count; bool paused; bool stopped; - double position; - double speed; + float position; + float speed; std::function start_callback; std::function end_callback; @@ -129,7 +129,7 @@ inline bool animation_base::is_stopped() const return stopped; } -inline double animation_base::get_position() const +inline float animation_base::get_position() const { return position; } @@ -155,13 +155,13 @@ public: typedef typename channel::keyframe keyframe; /// Interpolator function type. - typedef typename std::decay>::type interpolator_type; + typedef typename std::decay>::type interpolator_type; /// Creates an animation. animation(); /// @copydoc animation_base::advance() - virtual void advance(double dt); + virtual void advance(float dt); /** * Adds a channel to the animation. @@ -206,7 +206,7 @@ public: channel* get_channel(int id); /// @copydoc animation_base::get_duration() const - virtual double get_duration() const; + virtual float get_duration() const; private: std::unordered_map channels; @@ -221,7 +221,7 @@ animation::animation(): {} template -void animation::advance(double dt) +void animation::advance(float dt) { if (paused || stopped) { @@ -232,36 +232,36 @@ void animation::advance(double dt) position += dt * speed; // Determine duration of the animation - double duration = get_duration(); + float duration = get_duration(); if (position < duration) { if (frame_callback != nullptr && interpolator != nullptr) { - for (std::size_t i = 0; i < channels.size(); ++i) + for (const auto& channel: channels) { - auto frames = channels[i].find_keyframes(position); + auto frames = channel.second.find_keyframes(position); if (frames[0] != nullptr && frames[1] != nullptr) { // Calculate interpolated frame - double t0 = std::get<0>(*frames[0]); - double t1 = std::get<0>(*frames[1]); - double alpha = (position - t0) / (t1 - t0); + float t0 = std::get<0>(*frames[0]); + float t1 = std::get<0>(*frames[1]); + float alpha = (position - t0) / (t1 - t0); T frame = interpolator(std::get<1>(*frames[0]), std::get<1>(*frames[1]), alpha); // Pass frame to frame callback - frame_callback(static_cast(i), frame); + frame_callback(channel.first, frame); } else if (frames[0] != nullptr) { // Pass frame to frame callback - frame_callback(static_cast(i), std::get<1>(*frames[0])); + frame_callback(channel.first, std::get<1>(*frames[0])); } else if (frames[1] != nullptr) { // Pass frame to frame callback - frame_callback(static_cast(i), std::get<1>(*frames[1])); + frame_callback(channel.first, std::get<1>(*frames[1])); } } } @@ -292,12 +292,12 @@ void animation::advance(double dt) // Call frame callback for end frame if (frame_callback != nullptr) { - for (std::size_t i = 0; i < channels.size(); ++i) + for (auto& channel: channels) { - auto frames = channels[i].find_keyframes(channels[i].get_duration()); + auto frames = channel.second.find_keyframes(channel.second.get_duration()); if (frames[0] != nullptr) { - frame_callback(static_cast(i), std::get<1>(*frames[0])); + frame_callback(channel.first, std::get<1>(*frames[0])); } } } @@ -372,13 +372,13 @@ typename animation::channel* animation::get_channel(int id) } template -double animation::get_duration() const +float animation::get_duration() const { - double duration = 0.0; + float duration = 0.0; for (auto it = channels.begin(); it != channels.end(); ++it) { - duration = std::max(duration, it->second.get_duration()); + duration = std::max(duration, it->second.get_duration()); } return duration; diff --git a/src/engine/animation/animator.cpp b/src/engine/animation/animator.cpp index 932fdb4..1d63606 100644 --- a/src/engine/animation/animator.cpp +++ b/src/engine/animation/animator.cpp @@ -25,7 +25,7 @@ animator::animator(): animating(0) {} -void animator::animate(double dt) +void animator::animate(float dt) { // Advance animations ++animating; diff --git a/src/engine/animation/animator.hpp b/src/engine/animation/animator.hpp index 6af830a..99453df 100644 --- a/src/engine/animation/animator.hpp +++ b/src/engine/animation/animator.hpp @@ -39,7 +39,7 @@ public: * * @param dt Delta time by which the animations will be progressed. */ - void animate(double dt); + void animate(float dt); /** * Adds an animation to the animator. diff --git a/src/engine/geom/aabb.hpp b/src/engine/geom/aabb.hpp index c850837..deabf04 100644 --- a/src/engine/geom/aabb.hpp +++ b/src/engine/geom/aabb.hpp @@ -76,7 +76,7 @@ struct aabb: public bounding_volume * @param index Index of a corner. * @return Position of the specified corner. */ - vector_type corner(int index) const noexcept; + vector_type corner(std::size_t index) const noexcept; }; template @@ -108,7 +108,7 @@ aabb aabb::transform(const aabb& a, const matrix_type& m) for (std::size_t i = 0; i < 8; ++i) { vector_type corner = a.corner(i); - math::vector transformed_corner = math::mul(m, math::vector{corner.x(), corner.y(), corner.z(), T(1)}); + math::vector transformed_corner = math::mul(m, math::vector{corner.x(), corner.y(), corner.z(), T{1}}); for (std::size_t j = 0; j < 3; ++j) { @@ -192,7 +192,7 @@ bool aabb::contains(const vector_type& point) const } template -typename aabb::vector_type aabb::corner(int index) const noexcept +typename aabb::vector_type aabb::corner(std::size_t index) const noexcept { return { diff --git a/src/engine/physics/light/vmag.hpp b/src/engine/physics/light/vmag.hpp index d683288..0d76b00 100644 --- a/src/engine/physics/light/vmag.hpp +++ b/src/engine/physics/light/vmag.hpp @@ -40,7 +40,7 @@ template T to_brightness(T mv) { // 100^(1/5) - static constexpr double fifth_root_100 = 2.5118864315095801110850320677993; + static constexpr T fifth_root_100 = T{2.5118864315095801110850320677993}; return std::pow(fifth_root_100, -mv); } @@ -55,7 +55,7 @@ T to_brightness(T mv) template T to_illuminance(T mv) { - return std::pow(10.0, (-14.18 - mv) * 0.4); + return std::pow(T{10}, (T{-14.18} - mv) * T{0.4}); } /** @@ -69,7 +69,7 @@ T to_illuminance(T mv) template T from_illuminance(T ev) { - return -14.18 - 2.5 * std::log10(ev); + return T{-14.18} - T{2.5} * std::log10(ev); } } // namespace vmag diff --git a/src/game/game.cpp b/src/game/game.cpp index 00424c8..16ea0c7 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -1257,6 +1257,9 @@ void game::setup_loop() ( [&](double t, double dt) { + const float time = static_cast(t); + const float timestep = static_cast(dt); + // Update tweens sky_pass->update_tweens(); surface_scene->update_tweens(); @@ -1275,25 +1278,25 @@ void game::setup_loop() } // Advance timeline - timeline->advance(dt); + timeline->advance(timestep); // Update entity systems - //terrain_system->update(t, dt); - //subterrain_system->update(t, dt); - collision_system->update(t, dt); - behavior_system->update(t, dt); - steering_system->update(t, dt); - locomotion_system->update(t, dt); - camera_system->update(t, dt); - orbit_system->update(t, dt); - blackbody_system->update(t, dt); - atmosphere_system->update(t, dt); - astronomy_system->update(t, dt); - spring_system->update(t, dt); - spatial_system->update(t, dt); - constraint_system->update(t, dt); - animator->animate(dt); - render_system->update(t, dt); + //terrain_system->update(time, timestep); + //subterrain_system->update(time, timestep); + collision_system->update(time, timestep); + behavior_system->update(time, timestep); + steering_system->update(time, timestep); + locomotion_system->update(time, timestep); + camera_system->update(time, timestep); + orbit_system->update(time, timestep); + blackbody_system->update(time, timestep); + atmosphere_system->update(time, timestep); + astronomy_system->update(time, timestep); + spring_system->update(time, timestep); + spatial_system->update(time, timestep); + constraint_system->update(time, timestep); + animator->animate(timestep); + render_system->update(time, timestep); } ); @@ -1302,7 +1305,7 @@ void game::setup_loop() ( [&](double alpha) { - render_system->draw(alpha); + render_system->draw(static_cast(alpha)); window->swap_buffers(); } ); diff --git a/src/game/menu.cpp b/src/game/menu.cpp index 7259d27..3f5b09b 100644 --- a/src/game/menu.cpp +++ b/src/game/menu.cpp @@ -247,7 +247,7 @@ void fade_in(::game& ctx, const std::function& end_callback) ctx.menu_fade_animation->set_interpolator(ease::out_cubic); animation_channel* opacity_channel = ctx.menu_fade_animation->get_channel(0); opacity_channel->remove_keyframes(); - opacity_channel->insert_keyframe({0.0, 0.0f}); + opacity_channel->insert_keyframe({0.0f, 0.0f}); opacity_channel->insert_keyframe({config::menu_fade_in_duration, 1.0f}); ctx.menu_fade_animation->set_end_callback(end_callback); @@ -279,7 +279,7 @@ void fade_out(::game& ctx, const std::function& end_callback) ctx.menu_fade_animation->set_interpolator(ease::out_cubic); animation_channel* opacity_channel = ctx.menu_fade_animation->get_channel(0); opacity_channel->remove_keyframes(); - opacity_channel->insert_keyframe({0.0, 1.0f}); + opacity_channel->insert_keyframe({0.0f, 1.0f}); opacity_channel->insert_keyframe({config::menu_fade_out_duration, 0.0f}); ctx.menu_fade_animation->set_end_callback(end_callback); diff --git a/src/game/states/credits-state.cpp b/src/game/states/credits-state.cpp index 7d3b2de..59b7038 100644 --- a/src/game/states/credits-state.cpp +++ b/src/game/states/credits-state.cpp @@ -53,8 +53,8 @@ credits_state::credits_state(::game& ctx): credits_text.update_tweens(); // Set up animation timing configuration - const double credits_fade_in_duration = 0.5; - const double credits_scroll_duration = 5.0; + const float credits_fade_in_duration = 0.5; + const float credits_scroll_duration = 5.0; auto set_credits_opacity = [this](int channel, const float& opacity) { @@ -64,7 +64,7 @@ credits_state::credits_state(::game& ctx): // Build credits fade in animation credits_fade_in_animation.set_interpolator(ease::in_quad); animation_channel* credits_fade_in_opacity_channel = credits_fade_in_animation.add_channel(0); - credits_fade_in_opacity_channel->insert_keyframe({0.0, 0.0f}); + credits_fade_in_opacity_channel->insert_keyframe({0.0f, 0.0f}); credits_fade_in_opacity_channel->insert_keyframe({credits_fade_in_duration, 1.0f}); credits_fade_in_animation.set_frame_callback(set_credits_opacity); diff --git a/src/game/states/main-menu-state.cpp b/src/game/states/main-menu-state.cpp index 361689d..e499808 100644 --- a/src/game/states/main-menu-state.cpp +++ b/src/game/states/main-menu-state.cpp @@ -335,7 +335,7 @@ void main_menu_state::fade_in_title() { animation_channel* opacity_channel = title_fade_animation.get_channel(0); opacity_channel->remove_keyframes(); - opacity_channel->insert_keyframe({0.0, 0.0f}); + opacity_channel->insert_keyframe({0.0f, 0.0f}); opacity_channel->insert_keyframe({config::menu_fade_in_duration, 1.0f}); title_fade_animation.stop(); title_fade_animation.play(); @@ -345,7 +345,7 @@ void main_menu_state::fade_out_title() { animation_channel* opacity_channel = title_fade_animation.get_channel(0); opacity_channel->remove_keyframes(); - opacity_channel->insert_keyframe({0.0, 1.0f}); + opacity_channel->insert_keyframe({0.0f, 1.0f}); opacity_channel->insert_keyframe({config::menu_fade_out_duration, 0.0f}); title_fade_animation.stop(); title_fade_animation.play(); diff --git a/src/game/states/nuptial-flight-state.cpp b/src/game/states/nuptial-flight-state.cpp index 6423417..44e8ed6 100644 --- a/src/game/states/nuptial-flight-state.cpp +++ b/src/game/states/nuptial-flight-state.cpp @@ -115,8 +115,8 @@ nuptial_flight_state::nuptial_flight_state(::game& ctx): std::mt19937 rng(random_device()); // Assign random ant names - std::uniform_int_distribution<> female_name_pool_distribution(0, female_name_pool->lines.size() - 1); - std::uniform_int_distribution<> male_name_pool_distribution(0, male_name_pool->lines.size() - 1); + std::uniform_int_distribution<> female_name_pool_distribution(0, static_cast(female_name_pool->lines.size() - 1)); + std::uniform_int_distribution<> male_name_pool_distribution(0, static_cast(male_name_pool->lines.size() - 1)); ctx.entity_registry->view().each ( [&](entity::id entity_id, const auto& caste) diff --git a/src/game/states/splash-state.cpp b/src/game/states/splash-state.cpp index 6cc55f0..d5b5ed4 100644 --- a/src/game/states/splash-state.cpp +++ b/src/game/states/splash-state.cpp @@ -62,7 +62,7 @@ splash_state::splash_state(::game& ctx): // Construct splash billboard splash_billboard.set_material(splash_billboard_material); - splash_billboard.set_scale({(float)std::get<0>(splash_dimensions) * 0.5f, (float)std::get<1>(splash_dimensions) * 0.5f, 1.0f}); + splash_billboard.set_scale({static_cast(std::get<0>(splash_dimensions)) * 0.5f, static_cast(std::get<1>(splash_dimensions)) * 0.5f, 1.0f}); splash_billboard.set_translation({std::round(viewport_center.x()), std::round(viewport_center.y()), 0.0f}); splash_billboard.update_tweens(); @@ -70,21 +70,21 @@ splash_state::splash_state(::game& ctx): ctx.ui_scene->add_object(&splash_billboard); // Load animation timing configuration - const double splash_fade_in_duration = 0.5; - const double splash_duration = 2.0; - const double splash_fade_out_duration = 0.5; + const float splash_fade_in_duration = 0.5; + const float splash_duration = 2.0; + const float splash_fade_out_duration = 0.5; // Construct splash fade in animation splash_fade_in_animation.set_interpolator(ease::out_cubic); animation_channel* splash_fade_in_opacity_channel = splash_fade_in_animation.add_channel(0); - splash_fade_in_opacity_channel->insert_keyframe({0.0, 0.0f}); + splash_fade_in_opacity_channel->insert_keyframe({0.0f, 0.0f}); splash_fade_in_opacity_channel->insert_keyframe({splash_fade_in_duration, 1.0f}); splash_fade_in_opacity_channel->insert_keyframe({splash_fade_in_duration + splash_duration, 1.0f}); // Build splash fade out animation splash_fade_out_animation.set_interpolator(ease::out_cubic); animation_channel* splash_fade_out_opacity_channel = splash_fade_out_animation.add_channel(0); - splash_fade_out_opacity_channel->insert_keyframe({0.0, 1.0f}); + splash_fade_out_opacity_channel->insert_keyframe({0.0f, 1.0f}); splash_fade_out_opacity_channel->insert_keyframe({splash_fade_out_duration, 0.0f}); // Setup animation frame callbacks diff --git a/src/game/systems/astronomy-system.cpp b/src/game/systems/astronomy-system.cpp index dce4005..bf84f5d 100644 --- a/src/game/systems/astronomy-system.cpp +++ b/src/game/systems/astronomy-system.cpp @@ -90,7 +90,7 @@ astronomy_system::~astronomy_system() registry.on_destroy<::atmosphere_component>().disconnect<&astronomy_system::on_atmosphere_destroyed>(this); } -void astronomy_system::update(double t, double dt) +void astronomy_system::update(float t, float dt) { double3 sky_light_illuminance = {0.0, 0.0, 0.0}; diff --git a/src/game/systems/astronomy-system.hpp b/src/game/systems/astronomy-system.hpp index 275c85d..3fe64fa 100644 --- a/src/game/systems/astronomy-system.hpp +++ b/src/game/systems/astronomy-system.hpp @@ -50,7 +50,7 @@ public: * @param t Time, in seconds. * @param dt Delta time, in seconds. */ - virtual void update(double t, double dt); + virtual void update(float t, float dt); /** * Sets the current time. diff --git a/src/game/systems/atmosphere-system.cpp b/src/game/systems/atmosphere-system.cpp index e9e8e50..5a25734 100644 --- a/src/game/systems/atmosphere-system.cpp +++ b/src/game/systems/atmosphere-system.cpp @@ -42,7 +42,7 @@ atmosphere_system::~atmosphere_system() registry.on_destroy<::atmosphere_component>().disconnect<&atmosphere_system::on_atmosphere_destroy>(this); } -void atmosphere_system::update(double t, double dt) +void atmosphere_system::update(float t, float dt) {} void atmosphere_system::set_rgb_wavelengths(const double3& wavelengths) diff --git a/src/game/systems/atmosphere-system.hpp b/src/game/systems/atmosphere-system.hpp index 67bdf2b..233dcde 100644 --- a/src/game/systems/atmosphere-system.hpp +++ b/src/game/systems/atmosphere-system.hpp @@ -37,7 +37,7 @@ public: explicit atmosphere_system(entity::registry& registry); ~atmosphere_system(); - virtual void update(double t, double dt); + virtual void update(float t, float dt); /** * Sets the wavelengths of red, green, and blue light. diff --git a/src/game/systems/behavior-system.cpp b/src/game/systems/behavior-system.cpp index 6fce8cc..c584e52 100644 --- a/src/game/systems/behavior-system.cpp +++ b/src/game/systems/behavior-system.cpp @@ -26,7 +26,7 @@ behavior_system::behavior_system(entity::registry& registry): updatable_system(registry) {} -void behavior_system::update(double t, double dt) +void behavior_system::update(float t, float dt) { // registry.view().each( // [&](entity::id entity_id, auto& behavior) diff --git a/src/game/systems/behavior-system.hpp b/src/game/systems/behavior-system.hpp index 9801100..b5c24f0 100644 --- a/src/game/systems/behavior-system.hpp +++ b/src/game/systems/behavior-system.hpp @@ -27,7 +27,7 @@ class behavior_system: { public: explicit behavior_system(entity::registry& registry); - virtual void update(double t, double dt); + virtual void update(float t, float dt); }; diff --git a/src/game/systems/blackbody-system.cpp b/src/game/systems/blackbody-system.cpp index 3ce4068..be10605 100644 --- a/src/game/systems/blackbody-system.cpp +++ b/src/game/systems/blackbody-system.cpp @@ -47,7 +47,7 @@ blackbody_system::~blackbody_system() registry.on_update<::celestial_body_component>().disconnect<&blackbody_system::on_celestial_body_update>(this); } -void blackbody_system::update(double t, double dt) +void blackbody_system::update(float t, float dt) {} void blackbody_system::set_illuminant(const math::vector2& illuminant) diff --git a/src/game/systems/blackbody-system.hpp b/src/game/systems/blackbody-system.hpp index 692ddf0..59578c7 100644 --- a/src/game/systems/blackbody-system.hpp +++ b/src/game/systems/blackbody-system.hpp @@ -38,7 +38,7 @@ public: explicit blackbody_system(entity::registry& registry); ~blackbody_system(); - virtual void update(double t, double dt); + virtual void update(float t, float dt); /** * Sets the blackbody illuminant. diff --git a/src/game/systems/camera-system.cpp b/src/game/systems/camera-system.cpp index 9f8367e..c393910 100644 --- a/src/game/systems/camera-system.cpp +++ b/src/game/systems/camera-system.cpp @@ -25,7 +25,7 @@ camera_system::camera_system(entity::registry& registry): viewport{0, 0, 0, 0} {} -void camera_system::update(double t, double dt) +void camera_system::update(float t, float dt) { } diff --git a/src/game/systems/camera-system.hpp b/src/game/systems/camera-system.hpp index fe9da0a..908dc61 100644 --- a/src/game/systems/camera-system.hpp +++ b/src/game/systems/camera-system.hpp @@ -28,7 +28,7 @@ class camera_system: public updatable_system { public: explicit camera_system(entity::registry& registry); - virtual void update(double t, double dt); + virtual void update(float t, float dt); void set_viewport(const float4& viewport); diff --git a/src/game/systems/collision-system.cpp b/src/game/systems/collision-system.cpp index 6bd5749..e139815 100644 --- a/src/game/systems/collision-system.cpp +++ b/src/game/systems/collision-system.cpp @@ -34,7 +34,7 @@ collision_system::collision_system(entity::registry& registry): registry.on_destroy().connect<&collision_system::on_collision_destroy>(this); } -void collision_system::update(double t, double dt) +void collision_system::update(float t, float dt) { registry.on_construct().disconnect<&collision_system::on_collision_construct>(this); registry.on_update().disconnect<&collision_system::on_collision_update>(this); diff --git a/src/game/systems/collision-system.hpp b/src/game/systems/collision-system.hpp index f702275..8a52682 100644 --- a/src/game/systems/collision-system.hpp +++ b/src/game/systems/collision-system.hpp @@ -33,7 +33,7 @@ class collision_system: public updatable_system { public: explicit collision_system(entity::registry& registry); - virtual void update(double t, double dt); + virtual void update(float t, float dt); /** * Picks the nearest entity with the specified picking flags that intersects a ray. diff --git a/src/game/systems/constraint-system.cpp b/src/game/systems/constraint-system.cpp index 8ba2f18..c88bbf2 100644 --- a/src/game/systems/constraint-system.cpp +++ b/src/game/systems/constraint-system.cpp @@ -37,7 +37,7 @@ constraint_system::~constraint_system() registry.on_destroy().disconnect<&constraint_system::on_constraint_stack_update>(this); } -void constraint_system::update(double t, double dt) +void constraint_system::update(float t, float dt) { // For each entity with transform and constraint stack components registry.view().each @@ -62,7 +62,7 @@ void constraint_system::update(double t, double dt) // Apply constraint if enabled if (node->active) - handle_constraint(transform, constraint_eid, static_cast(dt)); + handle_constraint(transform, constraint_eid, dt); // Get entity ID of next constraint in the stack constraint_eid = node->next; diff --git a/src/game/systems/constraint-system.hpp b/src/game/systems/constraint-system.hpp index 1c153c2..a2ef623 100644 --- a/src/game/systems/constraint-system.hpp +++ b/src/game/systems/constraint-system.hpp @@ -47,7 +47,7 @@ public: explicit constraint_system(entity::registry& registry); ~constraint_system(); - virtual void update(double t, double dt); + virtual void update(float t, float dt); /** * Manually evaluates an entity's constraints. diff --git a/src/game/systems/locomotion-system.cpp b/src/game/systems/locomotion-system.cpp index 80bb11d..a53f74d 100644 --- a/src/game/systems/locomotion-system.cpp +++ b/src/game/systems/locomotion-system.cpp @@ -28,7 +28,7 @@ locomotion_system::locomotion_system(entity::registry& registry): updatable_system(registry) {} -void locomotion_system::update(double t, double dt) +void locomotion_system::update(float t, float dt) { registry.view().each( [&](entity::id entity_id, auto& transform, auto& locomotion) diff --git a/src/game/systems/locomotion-system.hpp b/src/game/systems/locomotion-system.hpp index dc1b87f..13750ea 100644 --- a/src/game/systems/locomotion-system.hpp +++ b/src/game/systems/locomotion-system.hpp @@ -28,7 +28,7 @@ class locomotion_system: { public: explicit locomotion_system(entity::registry& registry); - virtual void update(double t, double dt); + virtual void update(float t, float dt); }; diff --git a/src/game/systems/metamorphosis-system.cpp b/src/game/systems/metamorphosis-system.cpp index a928028..2ebe965 100644 --- a/src/game/systems/metamorphosis-system.cpp +++ b/src/game/systems/metamorphosis-system.cpp @@ -26,7 +26,7 @@ metamorphosis_system::metamorphosis_system(entity::registry& registry): time_scale(1.0f) {} -void metamorphosis_system::update(double t, double dt) +void metamorphosis_system::update(float t, float dt) { } diff --git a/src/game/systems/metamorphosis-system.hpp b/src/game/systems/metamorphosis-system.hpp index 4a98d2c..811278f 100644 --- a/src/game/systems/metamorphosis-system.hpp +++ b/src/game/systems/metamorphosis-system.hpp @@ -28,7 +28,7 @@ class metamorphosis_system: { public: explicit metamorphosis_system(entity::registry& registry); - virtual void update(double t, double dt); + virtual void update(float t, float dt); /** * Sets the factor by which the timestep `dt` will be scaled. diff --git a/src/game/systems/morphogenesis-system.cpp b/src/game/systems/morphogenesis-system.cpp index 97a6553..a9be3f4 100644 --- a/src/game/systems/morphogenesis-system.cpp +++ b/src/game/systems/morphogenesis-system.cpp @@ -25,6 +25,6 @@ morphogenesis_system::morphogenesis_system(entity::registry& registry): updatable_system(registry) {} -void morphogenesis_system::update(double t, double dt) +void morphogenesis_system::update(float t, float dt) {} diff --git a/src/game/systems/morphogenesis-system.hpp b/src/game/systems/morphogenesis-system.hpp index c270389..1d3729d 100644 --- a/src/game/systems/morphogenesis-system.hpp +++ b/src/game/systems/morphogenesis-system.hpp @@ -30,7 +30,7 @@ class morphogenesis_system: { public: explicit morphogenesis_system(entity::registry& registry); - virtual void update(double t, double dt); + virtual void update(float t, float dt); private: }; diff --git a/src/game/systems/orbit-system.cpp b/src/game/systems/orbit-system.cpp index b62f3e6..876e29e 100644 --- a/src/game/systems/orbit-system.cpp +++ b/src/game/systems/orbit-system.cpp @@ -37,7 +37,7 @@ orbit_system::~orbit_system() registry.on_update<::orbit_component>().disconnect<&orbit_system::on_orbit_update>(this); } -void orbit_system::update(double t, double dt) +void orbit_system::update(float t, float dt) { // Add scaled timestep to current time set_time(time + dt * time_scale); diff --git a/src/game/systems/orbit-system.hpp b/src/game/systems/orbit-system.hpp index d00fb86..647ce40 100644 --- a/src/game/systems/orbit-system.hpp +++ b/src/game/systems/orbit-system.hpp @@ -43,7 +43,7 @@ public: * @param t Time, in seconds. * @param dt Delta time, in seconds. */ - virtual void update(double t, double dt); + virtual void update(float t, float dt); /** * Sets the current time. diff --git a/src/game/systems/render-system.cpp b/src/game/systems/render-system.cpp index 996093c..f2b4c9c 100644 --- a/src/game/systems/render-system.cpp +++ b/src/game/systems/render-system.cpp @@ -50,7 +50,7 @@ render_system::~render_system() registry.on_destroy().disconnect<&render_system::on_light_destroy>(this); } -void render_system::update(double t, double dt) +void render_system::update(float t, float dt) { this->t = t; this->dt = dt; @@ -105,13 +105,13 @@ void render_system::update(double t, double dt) ); } -void render_system::draw(double alpha) +void render_system::draw(float alpha) { if (renderer) { for (const scene::collection* collection: layers) { - renderer->render(static_cast(t + dt * alpha), static_cast(dt), static_cast(alpha), *collection); + renderer->render(t + dt * alpha, dt, alpha, *collection); } } } diff --git a/src/game/systems/render-system.hpp b/src/game/systems/render-system.hpp index 5d18bf3..17bf612 100644 --- a/src/game/systems/render-system.hpp +++ b/src/game/systems/render-system.hpp @@ -38,9 +38,9 @@ public: explicit render_system(entity::registry& registry); ~render_system(); - virtual void update(double t, double dt); + virtual void update(float t, float dt); - void draw(double alpha); + void draw(float alpha); void add_layer(scene::collection* layer); @@ -62,8 +62,8 @@ private: void on_light_update(entity::registry& registry, entity::id entity_id); void on_light_destroy(entity::registry& registry, entity::id entity_id); - double t; - double dt; + float t; + float dt; ::render::renderer* renderer; std::vector layers; std::unordered_map> model_instances; diff --git a/src/game/systems/spatial-system.cpp b/src/game/systems/spatial-system.cpp index b4c9d17..4bf02a6 100644 --- a/src/game/systems/spatial-system.cpp +++ b/src/game/systems/spatial-system.cpp @@ -27,7 +27,7 @@ spatial_system::spatial_system(entity::registry& registry): updated_unconstrained_transforms(registry, entt::collector.update().where(entt::exclude)) {} -void spatial_system::update(double t, double dt) +void spatial_system::update(float t, float dt) { // Update world-space transforms of all updated, unconstrained transforms for (const auto transform_eid: updated_unconstrained_transforms) diff --git a/src/game/systems/spatial-system.hpp b/src/game/systems/spatial-system.hpp index 28b54bc..fc17d31 100644 --- a/src/game/systems/spatial-system.hpp +++ b/src/game/systems/spatial-system.hpp @@ -29,7 +29,7 @@ class spatial_system: { public: explicit spatial_system(entity::registry& registry); - virtual void update(double t, double dt); + virtual void update(float t, float dt); private: /// Observes entities with updated, unconstrained transforms. diff --git a/src/game/systems/spring-system.cpp b/src/game/systems/spring-system.cpp index 4c9c391..827f718 100644 --- a/src/game/systems/spring-system.cpp +++ b/src/game/systems/spring-system.cpp @@ -29,15 +29,13 @@ spring_system::spring_system(entity::registry& registry): spring_system::~spring_system() {} -void spring_system::update(double t, double dt) +void spring_system::update(float t, float dt) { - const float dtf = static_cast(dt); - registry.view().each ( [&](entity::id spring_eid, auto& component) { - solve_numeric_spring(component.spring, dtf); + solve_numeric_spring(component.spring, dt); if (component.callback) component.callback(component.spring.x0); } @@ -47,7 +45,7 @@ void spring_system::update(double t, double dt) ( [&](entity::id spring_eid, auto& component) { - solve_numeric_spring(component.spring, dtf); + solve_numeric_spring(component.spring, dt); if (component.callback) component.callback(component.spring.x0); } @@ -57,7 +55,7 @@ void spring_system::update(double t, double dt) ( [&](entity::id spring_eid, auto& component) { - solve_numeric_spring(component.spring, dtf); + solve_numeric_spring(component.spring, dt); if (component.callback) component.callback(component.spring.x0); } @@ -67,7 +65,7 @@ void spring_system::update(double t, double dt) ( [&](entity::id spring_eid, auto& component) { - solve_numeric_spring(component.spring, dtf); + solve_numeric_spring(component.spring, dt); if (component.callback) component.callback(component.spring.x0); } diff --git a/src/game/systems/spring-system.hpp b/src/game/systems/spring-system.hpp index 1ed099a..a417258 100644 --- a/src/game/systems/spring-system.hpp +++ b/src/game/systems/spring-system.hpp @@ -32,7 +32,7 @@ public: explicit spring_system(entity::registry& registry); ~spring_system(); - virtual void update(double t, double dt); + virtual void update(float t, float dt); }; diff --git a/src/game/systems/steering-system.cpp b/src/game/systems/steering-system.cpp index a8e81e0..991c6e6 100644 --- a/src/game/systems/steering-system.cpp +++ b/src/game/systems/steering-system.cpp @@ -30,7 +30,7 @@ steering_system::steering_system(entity::registry& registry): updatable_system(registry) {} -void steering_system::update(double t, double dt) +void steering_system::update(float t, float dt) { registry.view().each ( @@ -59,7 +59,7 @@ void steering_system::update(double t, double dt) // Accelerate agent.acceleration = force / agent.mass; - agent.velocity += agent.acceleration * static_cast(dt); + agent.velocity += agent.acceleration * dt; // Limit speed const float speed_squared = math::sqr_length(agent.velocity); @@ -70,7 +70,7 @@ void steering_system::update(double t, double dt) } // Move agent - agent.position += agent.velocity * static_cast(dt); + agent.position += agent.velocity * dt; // Rotate agent if (speed_squared) diff --git a/src/game/systems/steering-system.hpp b/src/game/systems/steering-system.hpp index b4d565a..fcafb3a 100644 --- a/src/game/systems/steering-system.hpp +++ b/src/game/systems/steering-system.hpp @@ -28,7 +28,7 @@ class steering_system: { public: explicit steering_system(entity::registry& registry); - virtual void update(double t, double dt); + virtual void update(float t, float dt); }; diff --git a/src/game/systems/subterrain-system.cpp b/src/game/systems/subterrain-system.cpp index d427053..08ab524 100644 --- a/src/game/systems/subterrain-system.cpp +++ b/src/game/systems/subterrain-system.cpp @@ -288,7 +288,7 @@ subterrain_system::~subterrain_system() */ } -void subterrain_system::update(double t, double dt) +void subterrain_system::update(float t, float dt) { /* if (first_run) diff --git a/src/game/systems/subterrain-system.hpp b/src/game/systems/subterrain-system.hpp index 5c9fd8b..3234f71 100644 --- a/src/game/systems/subterrain-system.hpp +++ b/src/game/systems/subterrain-system.hpp @@ -87,7 +87,7 @@ class subterrain_system: public updatable_system public: subterrain_system(entity::registry& registry, ::resource_manager* resource_manager); ~subterrain_system(); - virtual void update(double t, double dt); + virtual void update(float t, float dt); void set_scene(scene::collection* collection); diff --git a/src/game/systems/terrain-system.cpp b/src/game/systems/terrain-system.cpp index d594a36..9fda362 100644 --- a/src/game/systems/terrain-system.cpp +++ b/src/game/systems/terrain-system.cpp @@ -67,7 +67,7 @@ terrain_system::~terrain_system() // registry.on_destroy().disconnect<&terrain_system::on_terrain_destroy>(this); } -void terrain_system::update(double t, double dt) +void terrain_system::update(float t, float dt) { /* // Clear quadtree @@ -131,7 +131,7 @@ void terrain_system::set_patch_side_length(float length) // Recalculate node sizes at each quadtree depth for (std::size_t i = 0; i <= quadtree_type::max_depth; ++i) { - quadtree_node_size[i] = std::exp2(quadtree_type::max_depth - i) * patch_side_length; + quadtree_node_size[i] = std::exp2(static_cast(quadtree_type::max_depth - i)) * patch_side_length; } } diff --git a/src/game/systems/terrain-system.hpp b/src/game/systems/terrain-system.hpp index 2f2534e..acd353e 100644 --- a/src/game/systems/terrain-system.hpp +++ b/src/game/systems/terrain-system.hpp @@ -45,7 +45,7 @@ public: explicit terrain_system(entity::registry& registry); ~terrain_system(); - virtual void update(double t, double dt); + virtual void update(float t, float dt); /** * Sets the size of a patch. diff --git a/src/game/systems/updatable-system.hpp b/src/game/systems/updatable-system.hpp index ab8222b..7cdc88f 100644 --- a/src/game/systems/updatable-system.hpp +++ b/src/game/systems/updatable-system.hpp @@ -41,9 +41,8 @@ public: * * @param t Total elapsed time, in seconds. * @param dt Delta time, in seconds. - * @param registry Entity registry. */ - virtual void update(double t, double dt) = 0; + virtual void update(float t, float dt) = 0; protected: /// Registry on which the system operate