Browse Source

Fix all W3 warnings

master
C. J. Howard 1 year ago
parent
commit
4a96033376
49 changed files with 148 additions and 171 deletions
  1. +18
    -41
      CMakeLists.txt
  2. +9
    -9
      src/engine/animation/animation-channel.hpp
  3. +2
    -2
      src/engine/animation/animation.cpp
  4. +27
    -27
      src/engine/animation/animation.hpp
  5. +1
    -1
      src/engine/animation/animator.cpp
  6. +1
    -1
      src/engine/animation/animator.hpp
  7. +3
    -3
      src/engine/geom/aabb.hpp
  8. +3
    -3
      src/engine/physics/light/vmag.hpp
  9. +21
    -18
      src/game/game.cpp
  10. +2
    -2
      src/game/menu.cpp
  11. +3
    -3
      src/game/states/credits-state.cpp
  12. +2
    -2
      src/game/states/main-menu-state.cpp
  13. +2
    -2
      src/game/states/nuptial-flight-state.cpp
  14. +6
    -6
      src/game/states/splash-state.cpp
  15. +1
    -1
      src/game/systems/astronomy-system.cpp
  16. +1
    -1
      src/game/systems/astronomy-system.hpp
  17. +1
    -1
      src/game/systems/atmosphere-system.cpp
  18. +1
    -1
      src/game/systems/atmosphere-system.hpp
  19. +1
    -1
      src/game/systems/behavior-system.cpp
  20. +1
    -1
      src/game/systems/behavior-system.hpp
  21. +1
    -1
      src/game/systems/blackbody-system.cpp
  22. +1
    -1
      src/game/systems/blackbody-system.hpp
  23. +1
    -1
      src/game/systems/camera-system.cpp
  24. +1
    -1
      src/game/systems/camera-system.hpp
  25. +1
    -1
      src/game/systems/collision-system.cpp
  26. +1
    -1
      src/game/systems/collision-system.hpp
  27. +2
    -2
      src/game/systems/constraint-system.cpp
  28. +1
    -1
      src/game/systems/constraint-system.hpp
  29. +1
    -1
      src/game/systems/locomotion-system.cpp
  30. +1
    -1
      src/game/systems/locomotion-system.hpp
  31. +1
    -1
      src/game/systems/metamorphosis-system.cpp
  32. +1
    -1
      src/game/systems/metamorphosis-system.hpp
  33. +1
    -1
      src/game/systems/morphogenesis-system.cpp
  34. +1
    -1
      src/game/systems/morphogenesis-system.hpp
  35. +1
    -1
      src/game/systems/orbit-system.cpp
  36. +1
    -1
      src/game/systems/orbit-system.hpp
  37. +3
    -3
      src/game/systems/render-system.cpp
  38. +4
    -4
      src/game/systems/render-system.hpp
  39. +1
    -1
      src/game/systems/spatial-system.cpp
  40. +1
    -1
      src/game/systems/spatial-system.hpp
  41. +5
    -7
      src/game/systems/spring-system.cpp
  42. +1
    -1
      src/game/systems/spring-system.hpp
  43. +3
    -3
      src/game/systems/steering-system.cpp
  44. +1
    -1
      src/game/systems/steering-system.hpp
  45. +1
    -1
      src/game/systems/subterrain-system.cpp
  46. +1
    -1
      src/game/systems/subterrain-system.hpp
  47. +2
    -2
      src/game/systems/terrain-system.cpp
  48. +1
    -1
      src/game/systems/terrain-system.hpp
  49. +1
    -2
      src/game/systems/updatable-system.hpp

+ 18
- 41
CMakeLists.txt View File

@ -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$<$<CONFIG:Debug>: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$<$<CONFIG:Debug>: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()

+ 9
- 9
src/engine/animation/animation-channel.hpp View File

@ -34,7 +34,7 @@ class animation_channel
{
public:
/// Keyframe consisting of a time and a value.
typedef std::tuple<double, T> keyframe;
typedef std::tuple<float, T> 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<const keyframe*, 2> find_keyframes(double position) const;
std::array<const keyframe*, 2> 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<keyframe> find_keyframes(double start, double end) const;
std::list<keyframe> 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 <typename T>
void animation_channel<T>::remove_keyframes(double start, double end)
void animation_channel<T>::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 <typename T>
std::array<const typename animation_channel<T>::keyframe*, 2> animation_channel<T>::find_keyframes(double position) const
std::array<const typename animation_channel<T>::keyframe*, 2> animation_channel<T>::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 <typename T>
std::list<typename animation_channel<T>::keyframe> animation_channel<T>::find_keyframes(double start, double end) const
std::list<typename animation_channel<T>::keyframe> animation_channel<T>::find_keyframes(float start, float end) const
{
std::list<keyframe> keyframe_list;
@ -190,7 +190,7 @@ inline int animation_channel::get_id() const
}
template <typename T>
double animation_channel<T>::get_duration() const
float animation_channel<T>::get_duration() const
{
if (keyframes.empty())
{

+ 2
- 2
src/engine/animation/animation.cpp View File

@ -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;
}

+ 27
- 27
src/engine/animation/animation.hpp View File

@ -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<void()> callback);
@ -106,8 +106,8 @@ protected:
int loop_count;
bool paused;
bool stopped;
double position;
double speed;
float position;
float speed;
std::function<void()> start_callback;
std::function<void()> 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<std::function<T(const T&, const T&, double)>>::type interpolator_type;
typedef typename std::decay<std::function<T(const T&, const T&, float)>>::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<int, channel> channels;
@ -221,7 +221,7 @@ animation::animation():
{}
template <typename T>
void animation<T>::advance(double dt)
void animation<T>::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<int>(i), frame);
frame_callback(channel.first, frame);
}
else if (frames[0] != nullptr)
{
// Pass frame to frame callback
frame_callback(static_cast<int>(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<int>(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<int>(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 <typename T>
double animation<T>::get_duration() const
float animation<T>::get_duration() const
{
double duration = 0.0;
float duration = 0.0;
for (auto it = channels.begin(); it != channels.end(); ++it)
{
duration = std::max<double>(duration, it->second.get_duration());
duration = std::max<float>(duration, it->second.get_duration());
}
return duration;

+ 1
- 1
src/engine/animation/animator.cpp View File

@ -25,7 +25,7 @@ animator::animator():
animating(0)
{}
void animator::animate(double dt)
void animator::animate(float dt)
{
// Advance animations
++animating;

+ 1
- 1
src/engine/animation/animator.hpp View File

@ -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.

+ 3
- 3
src/engine/geom/aabb.hpp View File

@ -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 <class T>
@ -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<T, 4> transformed_corner = math::mul(m, math::vector<T, 4>{corner.x(), corner.y(), corner.z(), T(1)});
math::vector<T, 4> transformed_corner = math::mul(m, math::vector<T, 4>{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 <class T>
typename aabb<T>::vector_type aabb<T>::corner(int index) const noexcept
typename aabb<T>::vector_type aabb<T>::corner(std::size_t index) const noexcept
{
return
{

+ 3
- 3
src/engine/physics/light/vmag.hpp View File

@ -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 <class T>
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 <class T>
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

+ 21
- 18
src/game/game.cpp View File

@ -1257,6 +1257,9 @@ void game::setup_loop()
(
[&](double t, double dt)
{
const float time = static_cast<float>(t);
const float timestep = static_cast<float>(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<float>(alpha));
window->swap_buffers();
}
);

+ 2
- 2
src/game/menu.cpp View File

@ -247,7 +247,7 @@ void fade_in(::game& ctx, const std::function& end_callback)
ctx.menu_fade_animation->set_interpolator(ease<float>::out_cubic);
animation_channel<float>* 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<float>::out_cubic);
animation_channel<float>* 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);

+ 3
- 3
src/game/states/credits-state.cpp View File

@ -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<float>::in_quad);
animation_channel<float>* 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);

+ 2
- 2
src/game/states/main-menu-state.cpp View File

@ -335,7 +335,7 @@ void main_menu_state::fade_in_title()
{
animation_channel<float>* 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<float>* 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();

+ 2
- 2
src/game/states/nuptial-flight-state.cpp View File

@ -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<int>(female_name_pool->lines.size() - 1));
std::uniform_int_distribution<> male_name_pool_distribution(0, static_cast<int>(male_name_pool->lines.size() - 1));
ctx.entity_registry->view<ant_caste_component>().each
(
[&](entity::id entity_id, const auto& caste)

+ 6
- 6
src/game/states/splash-state.cpp View File

@ -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<float>(std::get<0>(splash_dimensions)) * 0.5f, static_cast<float>(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<float>::out_cubic);
animation_channel<float>* 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<float>::out_cubic);
animation_channel<float>* 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

+ 1
- 1
src/game/systems/astronomy-system.cpp View File

@ -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};

+ 1
- 1
src/game/systems/astronomy-system.hpp View File

@ -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.

+ 1
- 1
src/game/systems/atmosphere-system.cpp View File

@ -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)

+ 1
- 1
src/game/systems/atmosphere-system.hpp View File

@ -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.

+ 1
- 1
src/game/systems/behavior-system.cpp View File

@ -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<behavior_component>().each(
// [&](entity::id entity_id, auto& behavior)

+ 1
- 1
src/game/systems/behavior-system.hpp View File

@ -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);
};

+ 1
- 1
src/game/systems/blackbody-system.cpp View File

@ -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<double>& illuminant)

+ 1
- 1
src/game/systems/blackbody-system.hpp View File

@ -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.

+ 1
- 1
src/game/systems/camera-system.cpp View File

@ -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)
{
}

+ 1
- 1
src/game/systems/camera-system.hpp View File

@ -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);

+ 1
- 1
src/game/systems/collision-system.cpp View File

@ -34,7 +34,7 @@ collision_system::collision_system(entity::registry& registry):
registry.on_destroy<collision_component>().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<collision_component>().disconnect<&collision_system::on_collision_construct>(this);
registry.on_update<collision_component>().disconnect<&collision_system::on_collision_update>(this);

+ 1
- 1
src/game/systems/collision-system.hpp View File

@ -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.

+ 2
- 2
src/game/systems/constraint-system.cpp View File

@ -37,7 +37,7 @@ constraint_system::~constraint_system()
registry.on_destroy<constraint_stack_component>().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<transform_component, constraint_stack_component>().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<float>(dt));
handle_constraint(transform, constraint_eid, dt);
// Get entity ID of next constraint in the stack
constraint_eid = node->next;

+ 1
- 1
src/game/systems/constraint-system.hpp View File

@ -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.

+ 1
- 1
src/game/systems/locomotion-system.cpp View File

@ -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<transform_component, locomotion_component>().each(
[&](entity::id entity_id, auto& transform, auto& locomotion)

+ 1
- 1
src/game/systems/locomotion-system.hpp View File

@ -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);
};

+ 1
- 1
src/game/systems/metamorphosis-system.cpp View File

@ -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)
{
}

+ 1
- 1
src/game/systems/metamorphosis-system.hpp View File

@ -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.

+ 1
- 1
src/game/systems/morphogenesis-system.cpp View File

@ -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)
{}

+ 1
- 1
src/game/systems/morphogenesis-system.hpp View File

@ -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:
};

+ 1
- 1
src/game/systems/orbit-system.cpp View File

@ -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);

+ 1
- 1
src/game/systems/orbit-system.hpp View File

@ -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.

+ 3
- 3
src/game/systems/render-system.cpp View File

@ -50,7 +50,7 @@ render_system::~render_system()
registry.on_destroy<light_component>().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<float>(t + dt * alpha), static_cast<float>(dt), static_cast<float>(alpha), *collection);
renderer->render(t + dt * alpha, dt, alpha, *collection);
}
}
}

+ 4
- 4
src/game/systems/render-system.hpp View File

@ -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<scene::collection*> layers;
std::unordered_map<entity::id, std::unique_ptr<scene::model_instance>> model_instances;

+ 1
- 1
src/game/systems/spatial-system.cpp View File

@ -27,7 +27,7 @@ spatial_system::spatial_system(entity::registry& registry):
updated_unconstrained_transforms(registry, entt::collector.update<transform_component>().where(entt::exclude<constraint_stack_component>))
{}
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)

+ 1
- 1
src/game/systems/spatial-system.hpp View File

@ -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.

+ 5
- 7
src/game/systems/spring-system.cpp View File

@ -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<float>(dt);
registry.view<spring1_component>().each
(
[&](entity::id spring_eid, auto& component)
{
solve_numeric_spring<float, float>(component.spring, dtf);
solve_numeric_spring<float, float>(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<float2, float>(component.spring, dtf);
solve_numeric_spring<float2, float>(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<float3, float>(component.spring, dtf);
solve_numeric_spring<float3, float>(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<float4, float>(component.spring, dtf);
solve_numeric_spring<float4, float>(component.spring, dt);
if (component.callback)
component.callback(component.spring.x0);
}

+ 1
- 1
src/game/systems/spring-system.hpp View File

@ -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);
};

+ 3
- 3
src/game/systems/steering-system.cpp View File

@ -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<steering_component, transform_component>().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<float>(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<float>(dt);
agent.position += agent.velocity * dt;
// Rotate agent
if (speed_squared)

+ 1
- 1
src/game/systems/steering-system.hpp View File

@ -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);
};

+ 1
- 1
src/game/systems/subterrain-system.cpp View File

@ -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)

+ 1
- 1
src/game/systems/subterrain-system.hpp View File

@ -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);

+ 2
- 2
src/game/systems/terrain-system.cpp View File

@ -67,7 +67,7 @@ terrain_system::~terrain_system()
// registry.on_destroy<terrain_component>().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<float>(quadtree_type::max_depth - i)) * patch_side_length;
}
}

+ 1
- 1
src/game/systems/terrain-system.hpp View File

@ -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.

+ 1
- 2
src/game/systems/updatable-system.hpp View File

@ -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

Loading…
Cancel
Save