diff --git a/CMakeLists.txt b/CMakeLists.txt
index d3614e6..c6dd9d4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,8 +31,8 @@ set(SHARED_LIBS
${OPENGL_gl_LIBRARY})
# Generate configuration header file
-configure_file(${PROJECT_SOURCE_DIR}/src/configuration.hpp.in
- ${PROJECT_BINARY_DIR}/src/configuration.hpp)
+configure_file(${PROJECT_SOURCE_DIR}/src/config.hpp.in
+ ${PROJECT_BINARY_DIR}/src/config.hpp)
# Collect source files
file(GLOB_RECURSE SOURCE_FILES
diff --git a/src/config.hpp.in b/src/config.hpp.in
new file mode 100644
index 0000000..8527dff
--- /dev/null
+++ b/src/config.hpp.in
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2021 Christopher J. Howard
+ *
+ * This file is part of Antkeeper source code.
+ *
+ * Antkeeper source code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Antkeeper source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Antkeeper source code. If not, see .
+ */
+
+#ifndef ANTKEEPER_CONFIG_HPP
+#define ANTKEEPER_CONFIG_HPP
+
+#include "math/vector-type.hpp"
+
+/// Global configuration constants.
+namespace config {
+
+constexpr int version_major = @PROJECT_VERSION_MAJOR@;
+constexpr int version_minor = @PROJECT_VERSION_MINOR@;
+constexpr int version_patch = @PROJECT_VERSION_PATCH@;
+constexpr char* version_string = "@PROJECT_VERSION@";
+
+constexpr math::vector global_forward = {0.0f, 0.0f, -1.0f};
+constexpr math::vector global_up = {0.0f, 1.0f, 0.0f};
+constexpr math::vector global_right = {1.0f, 0.0f, 0.0f};
+
+/// Duration of the menu fade in animation, in seconds.
+constexpr float menu_fade_in_duration = 0.25f;
+
+/// Duration of the menu fade out animation, in seconds.
+constexpr float menu_fade_out_duration = 0.125f;
+
+/// Padding of the a menu item mouseover bounds, as a percentage of the font size.
+constexpr float menu_mouseover_padding = 0.1f;
+
+/// Opacity of the menu background.
+constexpr float menu_bg_opacity = 0.5f;
+
+/// RGBA color of active menu items.
+constexpr float4 menu_active_color{1.0f, 1.0f, 1.0f, 1.0f};
+
+/// RGBA color of inactive menu items.
+constexpr float4 menu_inactive_color{1.0f, 1.0f, 1.0f, 0.5f};
+
+/// Duration of the title screen fade in, in seconds.
+constexpr float title_fade_in_duration = 1.0f;
+
+/// Duration of the fade out when quitting the game or returning to the main menu, in seconds.
+constexpr float quit_fade_out_duration = 1.0f;
+
+/// Duration of the fade out when a new colony is started, in seconds.
+constexpr float new_colony_fade_out_duration = 1.0f;
+
+/// Duration of the nuptial flight fade in, in seconds.
+constexpr float nuptial_flight_fade_in_duration = 5.0f;
+
+#define MATERIAL_PASS_MAX_AMBIENT_LIGHT_COUNT 1
+#define MATERIAL_PASS_MAX_POINT_LIGHT_COUNT 1
+#define MATERIAL_PASS_MAX_DIRECTIONAL_LIGHT_COUNT 2
+#define MATERIAL_PASS_MAX_SPOTLIGHT_COUNT 1
+#define TERRAIN_PATCH_SIZE 200.0f
+#define TERRAIN_PATCH_RESOLUTION 4
+#define VEGETATION_PATCH_RESOLUTION 1
+
+} // namespace config
+
+#endif // ANTKEEPER_CONFIG_HPP
diff --git a/src/configuration.hpp.in b/src/configuration.hpp.in
deleted file mode 100644
index 6465742..0000000
--- a/src/configuration.hpp.in
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#ifndef ANTKEEPER_CONFIGURATION_HPP
-#define ANTKEEPER_CONFIGURATION_HPP
-
-#include "math/vector-type.hpp"
-
-#define ANTKEEPER_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
-#define ANTKEEPER_VERSION_MINOR @PROJECT_VERSION_MINOR@
-#define ANTKEEPER_VERSION_PATCH @PROJECT_VERSION_PATCH@
-#define ANTKEEPER_VERSION_STRING "@PROJECT_VERSION@"
-
-constexpr math::vector global_forward = {0.0f, 0.0f, -1.0f};
-constexpr math::vector global_up = {0.0f, 1.0f, 0.0f};
-constexpr math::vector global_right = {1.0f, 0.0f, 0.0f};
-
-#define MATERIAL_PASS_MAX_AMBIENT_LIGHT_COUNT 1
-#define MATERIAL_PASS_MAX_POINT_LIGHT_COUNT 1
-#define MATERIAL_PASS_MAX_DIRECTIONAL_LIGHT_COUNT 2
-#define MATERIAL_PASS_MAX_SPOTLIGHT_COUNT 1
-#define TERRAIN_PATCH_SIZE 200.0f
-#define TERRAIN_PATCH_RESOLUTION 4
-#define VEGETATION_PATCH_RESOLUTION 1
-
-#endif // ANTKEEPER_CONFIGURATION_HPP
diff --git a/src/game/menu.cpp b/src/game/menu.cpp
index c08c836..b870eaf 100644
--- a/src/game/menu.cpp
+++ b/src/game/menu.cpp
@@ -23,6 +23,7 @@
#include "animation/animation.hpp"
#include "animation/animator.hpp"
#include "animation/ease.hpp"
+#include "config.hpp"
#include
namespace game {
@@ -62,7 +63,7 @@ void update_text_color(game::context& ctx)
{
auto [name, value] = ctx.menu_item_texts[i];
- const float4& color = (i == *ctx.menu_item_index) ? active_color : inactive_color;
+ const float4& color = (i == *ctx.menu_item_index) ? config::menu_active_color : config::menu_inactive_color;
name->set_color(color);
if (value)
@@ -220,7 +221,7 @@ void setup_animations(game::context& ctx)
{
auto [name, value] = ctx.menu_item_texts[i];
- float4 color = (i == *ctx.menu_item_index) ? active_color : inactive_color;
+ float4 color = (i == *ctx.menu_item_index) ? config::menu_active_color : config::menu_inactive_color;
color[3] = color[3] * opacity;
if (name)
@@ -240,14 +241,14 @@ void fade_in(game::context& ctx, const std::function& end_callback)
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({game::menu::fade_in_duration, 1.0f});
+ opacity_channel->insert_keyframe({config::menu_fade_in_duration, 1.0f});
ctx.menu_fade_animation->set_end_callback(end_callback);
for (std::size_t i = 0; i < ctx.menu_item_texts.size(); ++i)
{
auto [name, value] = ctx.menu_item_texts[i];
- float4 color = (i == *ctx.menu_item_index) ? active_color : inactive_color;
+ float4 color = (i == *ctx.menu_item_index) ? config::menu_active_color : config::menu_inactive_color;
color[3] = 0.0f;
if (name)
@@ -272,7 +273,7 @@ void fade_out(game::context& ctx, const std::function& end_callback)
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({game::menu::fade_out_duration, 0.0f});
+ opacity_channel->insert_keyframe({config::menu_fade_out_duration, 0.0f});
ctx.menu_fade_animation->set_end_callback(end_callback);
ctx.menu_fade_animation->stop();
@@ -357,7 +358,7 @@ void setup_controls(game::context& ctx)
(
[&ctx](const mouse_moved_event& event)
{
- const float padding = game::menu::mouseover_padding * ctx.menu_font.get_font_metrics().size;
+ const float padding = config::menu_mouseover_padding * ctx.menu_font.get_font_metrics().size;
for (std::size_t i = 0; i < ctx.menu_item_texts.size(); ++i)
{
@@ -377,15 +378,15 @@ void setup_controls(game::context& ctx)
max_y = std::max(max_y, value_bounds.max_point.y);
}
- const auto& viewport = ctx.app->get_viewport_dimensions();
- const float x = static_cast(event.x - viewport[0] / 2);
- const float y = static_cast((viewport[1] - event.y + 1) - viewport[1] / 2);
-
min_x -= padding;
min_y -= padding;
max_x += padding;
max_y += padding;
+ const auto& viewport = ctx.app->get_viewport_dimensions();
+ const float x = static_cast(event.x - viewport[0] / 2);
+ const float y = static_cast((viewport[1] - event.y + 1) - viewport[1] / 2);
+
if (x >= min_x && x <= max_x)
{
if (y >= min_y && y <= max_y)
@@ -403,6 +404,8 @@ void setup_controls(game::context& ctx)
(
[&ctx](const mouse_button_pressed_event& event)
{
+ const float padding = config::menu_mouseover_padding * ctx.menu_font.get_font_metrics().size;
+
for (std::size_t i = 0; i < ctx.menu_item_texts.size(); ++i)
{
auto [name, value] = ctx.menu_item_texts[i];
@@ -421,6 +424,11 @@ void setup_controls(game::context& ctx)
max_y = std::max(max_y, value_bounds.max_point.y);
}
+ min_x -= padding;
+ min_y -= padding;
+ max_x += padding;
+ max_y += padding;
+
const auto& viewport = ctx.app->get_viewport_dimensions();
const float x = static_cast(event.x - viewport[0] / 2);
const float y = static_cast((viewport[1] - event.y + 1) - viewport[1] / 2);
diff --git a/src/game/menu.hpp b/src/game/menu.hpp
index 39dbb69..44e1329 100644
--- a/src/game/menu.hpp
+++ b/src/game/menu.hpp
@@ -25,27 +25,6 @@
namespace game {
namespace menu {
-/// Delay, in seconds, to when menu input should be activated.
-static constexpr float input_delay = 0.025f;
-
-/// RGBA color of active menu items.
-static constexpr float4 active_color{1.0f, 1.0f, 1.0f, 1.0f};
-
-/// RGBA color of inactive menu items.
-static constexpr float4 inactive_color{1.0f, 1.0f, 1.0f, 0.5f};
-
-/// Opacity of the menu background.
-static constexpr float bg_opacity = 2.0f / 4.0f;
-
-/// Padding of the mouseover bounds, as a percentage of the font size.
-static constexpr float mouseover_padding = 0.1f;
-
-/// Duration of the menu fade in animation
-static constexpr float fade_in_duration = 0.25f;
-
-/// Duration of the menu fade out animation
-static constexpr float fade_out_duration = 0.125f;
-
void init_menu_item_index(game::context& ctx, const std::string& menu_name);
void setup_controls(game::context& ctx);
void setup_animations(game::context& ctx);
diff --git a/src/game/state/boot.cpp b/src/game/state/boot.cpp
index c0476a1..5a30fbe 100644
--- a/src/game/state/boot.cpp
+++ b/src/game/state/boot.cpp
@@ -82,7 +82,7 @@
#include "input/gamepad.hpp"
#include "input/mouse.hpp"
#include "input/keyboard.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
#include "input/scancode.hpp"
#include "game/fonts.hpp"
#include "game/controls.hpp"
@@ -788,7 +788,7 @@ void boot::setup_animation()
ctx.menu_bg_fade_in_animation->set_interpolator(ease::out_cubic);
animation_channel* channel = ctx.menu_bg_fade_in_animation->add_channel(0);
channel->insert_keyframe({0.0f, 0.0f});
- channel->insert_keyframe({game::menu::fade_in_duration, game::menu::bg_opacity});
+ channel->insert_keyframe({config::menu_fade_in_duration, config::menu_bg_opacity});
ctx.menu_bg_fade_in_animation->set_frame_callback(menu_bg_frame_callback);
ctx.menu_bg_fade_in_animation->set_start_callback
(
@@ -808,8 +808,8 @@ void boot::setup_animation()
{
ctx.menu_bg_fade_out_animation->set_interpolator(ease::out_cubic);
animation_channel* channel = ctx.menu_bg_fade_out_animation->add_channel(0);
- channel->insert_keyframe({0.0f, game::menu::bg_opacity});
- channel->insert_keyframe({game::menu::fade_out_duration, 0.0f});
+ channel->insert_keyframe({0.0f, config::menu_bg_opacity});
+ channel->insert_keyframe({config::menu_fade_out_duration, 0.0f});
ctx.menu_bg_fade_out_animation->set_frame_callback(menu_bg_frame_callback);
ctx.menu_bg_fade_out_animation->set_end_callback
(
diff --git a/src/game/state/main-menu.cpp b/src/game/state/main-menu.cpp
index aba481c..39d68bc 100644
--- a/src/game/state/main-menu.cpp
+++ b/src/game/state/main-menu.cpp
@@ -31,6 +31,7 @@
#include "animation/screen-transition.hpp"
#include "animation/ease.hpp"
#include "application.hpp"
+#include "config.hpp"
#include
namespace game {
@@ -129,7 +130,7 @@ main_menu::main_menu(game::context& ctx, bool fade_in):
// Start fade out to white
ctx.fade_transition_color->set_value({1, 1, 1});
- ctx.fade_transition->transition(1.0f, false, ease::out_cubic, false, change_state_nuptial_flight);
+ ctx.fade_transition->transition(config::new_colony_fade_out_duration, false, ease::out_cubic, false, change_state_nuptial_flight);
};
auto select_options_callback = [this, &ctx]()
{
@@ -194,7 +195,7 @@ main_menu::main_menu(game::context& ctx, bool fade_in):
game::menu::fade_out(ctx, nullptr);
// Fade to black then quit
- ctx.fade_transition->transition(0.5f, false, ease::out_cubic, false, std::bind(&application::close, ctx.app));
+ ctx.fade_transition->transition(config::quit_fade_out_duration, false, ease::out_cubic, false, std::bind(&application::close, ctx.app));
};
// Build list of menu select callbacks
@@ -224,7 +225,7 @@ main_menu::main_menu(game::context& ctx, bool fade_in):
if (fade_in)
{
// Fade in from black
- ctx.fade_transition->transition(1.0f, true, ease::out_cubic);
+ ctx.fade_transition->transition(config::title_fade_in_duration, true, ease::out_cubic);
}
else
{
@@ -261,7 +262,7 @@ void main_menu::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({game::menu::fade_in_duration, 1.0f});
+ opacity_channel->insert_keyframe({config::menu_fade_in_duration, 1.0f});
title_fade_animation.stop();
title_fade_animation.play();
}
@@ -271,7 +272,7 @@ void main_menu::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({game::menu::fade_out_duration, 0.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/state/nuptial-flight.cpp b/src/game/state/nuptial-flight.cpp
index 5c2619d..d54502f 100644
--- a/src/game/state/nuptial-flight.cpp
+++ b/src/game/state/nuptial-flight.cpp
@@ -40,6 +40,7 @@
#include
#include
#include "state-machine.hpp"
+#include "config.hpp"
namespace game {
namespace state {
@@ -115,7 +116,7 @@ nuptial_flight::nuptial_flight(game::context& ctx):
// Queue fade in
ctx.fade_transition_color->set_value({1, 1, 1});
- ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition, 5.0f, true, ease::out_sine, true, nullptr));
+ ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition, config::nuptial_flight_fade_in_duration, true, ease::out_sine, true, nullptr));
// Queue control setup
ctx.function_queue.push(std::bind(&nuptial_flight::enable_controls, this));
diff --git a/src/game/state/pause-menu.cpp b/src/game/state/pause-menu.cpp
index 025ebf3..ca49af0 100644
--- a/src/game/state/pause-menu.cpp
+++ b/src/game/state/pause-menu.cpp
@@ -29,6 +29,7 @@
#include "scene/text.hpp"
#include "debug/logger.hpp"
#include "animation/screen-transition.hpp"
+#include "config.hpp"
namespace game {
namespace state {
@@ -147,7 +148,7 @@ pause_menu::pause_menu(game::context& ctx):
// Fade out to black then return to main menu
ctx.fade_transition_color->set_value({0, 0, 0});
- ctx.fade_transition->transition(1.0f, false, ease::out_cubic, false, fade_out_callback);
+ ctx.fade_transition->transition(config::quit_fade_out_duration, false, ease::out_cubic, false, fade_out_callback);
};
auto select_quit_callback = [&ctx]()
{
@@ -165,7 +166,7 @@ pause_menu::pause_menu(game::context& ctx):
// Fade out to black then quit
ctx.fade_transition_color->set_value({0, 0, 0});
- ctx.fade_transition->transition(1.0f, false, ease::out_cubic, false, std::bind(&application::close, ctx.app));
+ ctx.fade_transition->transition(config::quit_fade_out_duration, false, ease::out_cubic, false, std::bind(&application::close, ctx.app));
};
// Build list of menu select callbacks
diff --git a/src/game/world.cpp b/src/game/world.cpp
index 69969c2..4c1fcb2 100644
--- a/src/game/world.cpp
+++ b/src/game/world.cpp
@@ -48,7 +48,7 @@
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include "render/material-flags.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
namespace game {
namespace world {
diff --git a/src/render/passes/material-pass.cpp b/src/render/passes/material-pass.cpp
index a3629be..29a0b69 100644
--- a/src/render/passes/material-pass.cpp
+++ b/src/render/passes/material-pass.cpp
@@ -18,7 +18,7 @@
*/
#include "render/passes/material-pass.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
#include "resources/resource-manager.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
@@ -41,7 +41,7 @@
#include "scene/directional-light.hpp"
#include "scene/point-light.hpp"
#include "scene/spot-light.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
#include
#include
@@ -208,8 +208,8 @@ void material_pass::render(const render::context& ctx, render::queue& queue) con
directional_light_texture_opacities[directional_light_count] = directional_light->get_light_texture_opacity_tween().interpolate(ctx.alpha);
math::transform light_transform = light->get_transform_tween().interpolate(ctx.alpha);
- float3 forward = light_transform.rotation * global_forward;
- float3 up = light_transform.rotation * global_up;
+ float3 forward = light_transform.rotation * config::global_forward;
+ float3 up = light_transform.rotation * config::global_up;
float4x4 light_view = math::look_at(light_transform.translation, light_transform.translation + forward, up);
float2 scale = directional_light->get_light_texture_scale_tween().interpolate(ctx.alpha);
diff --git a/src/render/passes/shadow-map-pass.cpp b/src/render/passes/shadow-map-pass.cpp
index e76618e..4258357 100644
--- a/src/render/passes/shadow-map-pass.cpp
+++ b/src/render/passes/shadow-map-pass.cpp
@@ -31,7 +31,7 @@
#include "scene/light.hpp"
#include "geom/view-frustum.hpp"
#include "geom/aabb.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
#include "math/math.hpp"
#include
#include
@@ -138,8 +138,8 @@ void shadow_map_pass::render(const render::context& ctx, render::queue& queue) c
// Calculate a view-projection matrix from the directional light's transform
math::transform light_transform = light->get_transform_tween().interpolate(ctx.alpha);
- float3 forward = light_transform.rotation * global_forward;
- float3 up = light_transform.rotation * global_up;
+ float3 forward = light_transform.rotation * config::global_forward;
+ float3 up = light_transform.rotation * config::global_up;
float4x4 light_view = math::look_at(light_transform.translation, light_transform.translation + forward, up);
float4x4 light_projection = math::ortho_half_z(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
float4x4 light_view_projection = light_projection * light_view;
diff --git a/src/render/renderer.cpp b/src/render/renderer.cpp
index c0db19e..18b8e9a 100644
--- a/src/render/renderer.cpp
+++ b/src/render/renderer.cpp
@@ -30,7 +30,7 @@
#include "gl/drawing-mode.hpp"
#include "math/math.hpp"
#include "geom/projection.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
#include
#include
@@ -95,8 +95,8 @@ void renderer::render(float t, float dt, float alpha, const scene::collection& c
// Update render context with camera parameters
ctx.camera = camera;
ctx.camera_transform = camera->get_transform_tween().interpolate(alpha);
- ctx.camera_forward = ctx.camera_transform.rotation * global_forward;
- ctx.camera_up = ctx.camera_transform.rotation * global_up;
+ ctx.camera_forward = ctx.camera_transform.rotation * config::global_forward;
+ ctx.camera_up = ctx.camera_transform.rotation * config::global_up;
ctx.clip_near = camera->get_view_frustum().get_near(); ///< TODO: tween this
// Create render queue
diff --git a/src/scene/billboard.cpp b/src/scene/billboard.cpp
index 4eb8c8e..02151c0 100644
--- a/src/scene/billboard.cpp
+++ b/src/scene/billboard.cpp
@@ -18,7 +18,7 @@
*/
#include "scene/billboard.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
namespace scene {
@@ -28,7 +28,7 @@ billboard::billboard():
world_bounds(local_bounds),
material(nullptr),
type(billboard_type::flat),
- alignment_axis(global_up)
+ alignment_axis(config::global_up)
{}
billboard::billboard(const billboard& other)
diff --git a/src/scene/camera.cpp b/src/scene/camera.cpp
index 4ca83d8..aae6020 100644
--- a/src/scene/camera.cpp
+++ b/src/scene/camera.cpp
@@ -18,7 +18,7 @@
*/
#include "scene/camera.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
#include "animation/ease.hpp"
#include "math/constants.hpp"
#include "math/interpolation.hpp"
@@ -28,8 +28,8 @@ namespace scene {
static float4x4 interpolate_view(const camera* camera, const float4x4& x, const float4x4& y, float a)
{
math::transform transform = camera->get_transform_tween().interpolate(a);
- float3 forward = transform.rotation * global_forward;
- float3 up = transform.rotation * global_up;
+ float3 forward = transform.rotation * config::global_forward;
+ float3 up = transform.rotation * config::global_up;
return math::look_at(transform.translation, transform.translation + forward, up);
}
@@ -184,8 +184,8 @@ void camera::update_tweens()
void camera::transformed()
{
// Recalculate view and view-projection matrices
- float3 forward = get_rotation() * global_forward;
- float3 up = get_rotation() * global_up;
+ float3 forward = get_rotation() * config::global_forward;
+ float3 up = get_rotation() * config::global_up;
view[1] = math::look_at(get_translation(), get_translation() + forward, up);
view_projection[1] = projection[1] * view[1];
diff --git a/src/scene/directional-light.cpp b/src/scene/directional-light.cpp
index 356d207..58a029b 100644
--- a/src/scene/directional-light.cpp
+++ b/src/scene/directional-light.cpp
@@ -18,20 +18,20 @@
*/
#include "directional-light.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
#include "math/math.hpp"
namespace scene {
static float3 interpolate_direction(const float3& x, const float3& y, float a)
{
- math::quaternion q0 = math::rotation(global_forward, x);
- math::quaternion q1 = math::rotation(global_forward, y);
- return math::normalize(math::slerp(q0, q1, a) * global_forward);
+ math::quaternion q0 = math::rotation(config::global_forward, x);
+ math::quaternion q1 = math::rotation(config::global_forward, y);
+ return math::normalize(math::slerp(q0, q1, a) * config::global_forward);
}
directional_light::directional_light():
- direction(global_forward, interpolate_direction),
+ direction(config::global_forward, interpolate_direction),
light_texture(nullptr),
light_texture_opacity(1.0f, math::lerp),
light_texture_scale({1.0f, 1.0f}, math::lerp)
@@ -66,7 +66,7 @@ void directional_light::update_tweens()
void directional_light::transformed()
{
- direction[1] = math::normalize(get_transform().rotation * global_forward);
+ direction[1] = math::normalize(get_transform().rotation * config::global_forward);
}
} // namespace scene
diff --git a/src/scene/spot-light.cpp b/src/scene/spot-light.cpp
index c460ba1..b620aa4 100644
--- a/src/scene/spot-light.cpp
+++ b/src/scene/spot-light.cpp
@@ -18,7 +18,7 @@
*/
#include "spot-light.hpp"
-#include "configuration.hpp"
+#include "config.hpp"
#include "math/math.hpp"
#include
@@ -26,13 +26,13 @@ namespace scene {
static float3 interpolate_direction(const float3& x, const float3& y, float a)
{
- math::quaternion q0 = math::rotation(global_forward, x);
- math::quaternion q1 = math::rotation(global_forward, y);
- return math::normalize(math::slerp(q0, q1, a) * global_forward);
+ math::quaternion q0 = math::rotation(config::global_forward, x);
+ math::quaternion q1 = math::rotation(config::global_forward, y);
+ return math::normalize(math::slerp(q0, q1, a) * config::global_forward);
}
spot_light::spot_light():
- direction(global_forward, interpolate_direction),
+ direction(config::global_forward, interpolate_direction),
attenuation(float3{1, 0, 0}, math::lerp),
cutoff(float2{math::pi, math::pi}, math::lerp),
cosine_cutoff(float2{std::cos(math::pi), std::cos(math::pi)}, math::lerp)
@@ -60,7 +60,7 @@ void spot_light::update_tweens()
void spot_light::transformed()
{
- direction[1] = math::normalize(get_transform().rotation * global_forward);
+ direction[1] = math::normalize(get_transform().rotation * config::global_forward);
}
} // namespace scene