Browse Source

Fix and improve ant morphogenesis

master
C. J. Howard 1 year ago
parent
commit
a313430cb9
16 changed files with 1115 additions and 1067 deletions
  1. +11
    -0
      src/engine/animation/bone.hpp
  2. +3
    -0
      src/engine/animation/skeleton.hpp
  3. +1
    -1
      src/engine/gl/rasterizer.cpp
  4. +1
    -1
      src/engine/gl/vertex-array.cpp
  5. +0
    -3
      src/engine/render/material.cpp
  6. +5
    -5
      src/engine/render/passes/material-pass.cpp
  7. +929
    -803
      src/game/ant/ant-morphogenesis.cpp
  8. +2
    -2
      src/game/ant/ant-morphogenesis.hpp
  9. +18
    -13
      src/game/controls.cpp
  10. +2
    -2
      src/game/controls.hpp
  11. +2
    -2
      src/game/game.cpp
  12. +11
    -3
      src/game/game.hpp
  13. +119
    -227
      src/game/states/nest-selection-state.cpp
  14. +7
    -1
      src/game/states/nest-selection-state.hpp
  15. +3
    -3
      src/game/states/nuptial-flight-state.cpp
  16. +1
    -1
      src/game/states/nuptial-flight-state.hpp

+ 11
- 0
src/engine/animation/bone.hpp View File

@ -62,6 +62,17 @@ struct bone_index_compare
return (static_cast<std::uint32_t>(parent_index) << 16) | index; return (static_cast<std::uint32_t>(parent_index) << 16) | index;
} }
/**
* Sets the parent of a bone.
*
* @param[out] child Bone to reparent.
* @param[in] parent New parent bone.
*/
inline void reparent_bone(bone& child, bone parent) noexcept
{
child = ((parent & bone_index_mask) << 16) | (child & bone_index_mask);
}
/** /**
* Constructs an orphan bone identifier. * Constructs an orphan bone identifier.
* *

+ 3
- 0
src/engine/animation/skeleton.hpp View File

@ -25,6 +25,7 @@
#include <engine/utility/hash/fnv1a.hpp> #include <engine/utility/hash/fnv1a.hpp>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector>
/** /**
* Skeletal animation skeleton. * Skeletal animation skeleton.
@ -37,6 +38,8 @@ struct skeleton
/// Inverse skeleton-space bind pose of the skeleton. /// Inverse skeleton-space bind pose of the skeleton.
pose inverse_bind_pose; pose inverse_bind_pose;
std::vector<bone> bones;
/// Maps bone names to bone identifiers. /// Maps bone names to bone identifiers.
std::unordered_map<hash::fnv1a32_t, bone> bone_map; std::unordered_map<hash::fnv1a32_t, bone> bone_map;
}; };

+ 1
- 1
src/engine/gl/rasterizer.cpp View File

@ -161,7 +161,7 @@ void rasterizer::draw_elements(const vertex_array& vao, drawing_mode mode, std::
bound_vao = &vao; bound_vao = &vao;
} }
glDrawElements(gl_mode, static_cast<GLsizei>(count), gl_type, (const GLvoid*)offset);
glDrawElements(gl_mode, static_cast<GLsizei>(count), gl_type, reinterpret_cast<const GLvoid*>(offset));
} }
} // namespace gl } // namespace gl

+ 1
- 1
src/engine/gl/vertex-array.cpp View File

@ -72,7 +72,7 @@ void vertex_array::bind(attribute_location_type location, const vertex_attribute
gl_type, gl_type,
GL_FALSE, GL_FALSE,
static_cast<GLsizei>(attribute.stride), static_cast<GLsizei>(attribute.stride),
(const GLvoid*)attribute.offset
reinterpret_cast<const GLvoid*>(attribute.offset)
); );
glEnableVertexAttribArray(static_cast<GLuint>(location)); glEnableVertexAttribArray(static_cast<GLuint>(location));
} }

+ 0
- 3
src/engine/render/material.cpp View File

@ -210,9 +210,6 @@ static bool load_scalar_property(render::material& material, hash::fnv1a32_t key
// If JSON element is an array // If JSON element is an array
if (json.is_array()) if (json.is_array())
{ {
// Determine size of the array
std::size_t array_size = json.size();
// Create variable // Create variable
auto variable = std::make_shared<render::material_variable<T>>(json.size()); auto variable = std::make_shared<render::material_variable<T>>(json.size());

+ 5
- 5
src/engine/render/passes/material-pass.cpp View File

@ -355,11 +355,11 @@ void material_pass::evaluate_lighting(const render::context& ctx)
spot_light_cutoffs.resize(spot_light_count); spot_light_cutoffs.resize(spot_light_count);
} }
spot_light_colors[spot_light_count] = spot_light.get_scaled_color_tween().interpolate(ctx.alpha) * ctx.exposure;
spot_light_positions[spot_light_count] = spot_light.get_transform_tween().interpolate(ctx.alpha).translation;
spot_light_directions[spot_light_count] = spot_light.get_direction_tween().interpolate(ctx.alpha);
spot_light_attenuations[spot_light_count] = spot_light.get_attenuation_tween().interpolate(ctx.alpha);
spot_light_cutoffs[spot_light_count] = spot_light.get_cosine_cutoff_tween().interpolate(ctx.alpha);
spot_light_colors[index] = spot_light.get_scaled_color_tween().interpolate(ctx.alpha) * ctx.exposure;
spot_light_positions[index] = spot_light.get_transform_tween().interpolate(ctx.alpha).translation;
spot_light_directions[index] = spot_light.get_direction_tween().interpolate(ctx.alpha);
spot_light_attenuations[index] = spot_light.get_attenuation_tween().interpolate(ctx.alpha);
spot_light_cutoffs[index] = spot_light.get_cosine_cutoff_tween().interpolate(ctx.alpha);
break; break;
} }

+ 929
- 803
src/game/ant/ant-morphogenesis.cpp
File diff suppressed because it is too large
View File


+ 2
- 2
src/game/ant/ant-morphogenesis.hpp View File

@ -27,9 +27,9 @@
/** /**
* Generates a 3D model of an ant given its phenome. * Generates a 3D model of an ant given its phenome.
* *
* @param phenome Phenome of an ant.
* @param phenome Ant phenome.
* *
* @return 3D model of the given phenome.
* @return Generated 3D model of the given phenome.
*/ */
[[nodiscard]] std::unique_ptr<render::model> ant_morphogenesis(const ant_phenome& phenome); [[nodiscard]] std::unique_ptr<render::model> ant_morphogenesis(const ant_phenome& phenome);

+ 18
- 13
src/game/controls.cpp View File

@ -125,10 +125,11 @@ void reset_control_profile(::control_profile& profile)
mappings.emplace("pause", std::make_unique<input::key_mapping>(nullptr, input::scancode::escape, 0, false)); mappings.emplace("pause", std::make_unique<input::key_mapping>(nullptr, input::scancode::escape, 0, false));
mappings.emplace("pause", std::make_unique<input::gamepad_button_mapping>(nullptr, input::gamepad_button::start)); mappings.emplace("pause", std::make_unique<input::gamepad_button_mapping>(nullptr, input::gamepad_button::start));
// Pick mate
mappings.emplace("pick_mate", std::make_unique<input::mouse_button_mapping>(nullptr, input::mouse_button::left));
mappings.emplace("pick_mate", std::make_unique<input::mouse_button_mapping>(nullptr, input::mouse_button::middle));
mappings.emplace("pick_mate", std::make_unique<input::mouse_button_mapping>(nullptr, input::mouse_button::right));
// Mouse pick
mappings.emplace("mouse_pick", std::make_unique<input::mouse_button_mapping>(nullptr, input::mouse_button::left));
// Mouse look
mappings.emplace("mouse_look", std::make_unique<input::mouse_button_mapping>(nullptr, input::mouse_button::right));
} }
void apply_control_profile(::game& ctx, const ::control_profile& profile) void apply_control_profile(::game& ctx, const ::control_profile& profile)
@ -167,8 +168,10 @@ void apply_control_profile(::game& ctx, const ::control_profile& profile)
add_mappings(ctx.movement_action_map, ctx.move_down_action, "move_down"); add_mappings(ctx.movement_action_map, ctx.move_down_action, "move_down");
add_mappings(ctx.movement_action_map, ctx.pause_action, "pause"); add_mappings(ctx.movement_action_map, ctx.pause_action, "pause");
// Nuptial flight controls
add_mappings(ctx.nuptial_flight_action_map, ctx.pick_mate_action, "pick_mate");
// Keeper controls
ctx.keeper_action_map.remove_mappings();
add_mappings(ctx.keeper_action_map, ctx.mouse_pick_action, "mouse_pick");
add_mappings(ctx.keeper_action_map, ctx.mouse_look_action, "mouse_look");
} }
void update_control_profile(::game& ctx, ::control_profile& profile) void update_control_profile(::game& ctx, ::control_profile& profile)
@ -232,8 +235,9 @@ void update_control_profile(::game& ctx, ::control_profile& profile)
add_mappings(ctx.movement_action_map, ctx.move_down_action, "move_down"); add_mappings(ctx.movement_action_map, ctx.move_down_action, "move_down");
add_mappings(ctx.movement_action_map, ctx.pause_action, "pause"); add_mappings(ctx.movement_action_map, ctx.pause_action, "pause");
// Nuptial flight controls
add_mappings(ctx.nuptial_flight_action_map, ctx.pick_mate_action, "pick_mate");
// Keeper controls
add_mappings(ctx.keeper_action_map, ctx.mouse_pick_action, "mouse_pick");
add_mappings(ctx.keeper_action_map, ctx.mouse_look_action, "mouse_look");
} }
void setup_window_controls(::game& ctx) void setup_window_controls(::game& ctx)
@ -500,9 +504,9 @@ void enable_game_controls(::game& ctx)
ctx.movement_action_map.enable(); ctx.movement_action_map.enable();
} }
void enable_nuptial_flight_controls(::game& ctx)
void enable_keeper_controls(::game& ctx)
{ {
ctx.nuptial_flight_action_map.enable();
ctx.keeper_action_map.enable();
} }
void disable_window_controls(::game& ctx) void disable_window_controls(::game& ctx)
@ -538,10 +542,11 @@ void disable_game_controls(::game& ctx)
ctx.pause_action.reset(); ctx.pause_action.reset();
} }
void disable_nuptial_flight_controls(::game& ctx)
void disable_keeper_controls(::game& ctx)
{ {
ctx.nuptial_flight_action_map.disable();
ctx.keeper_action_map.disable();
ctx.pick_mate_action.reset();
ctx.mouse_pick_action.reset();
ctx.mouse_look_action.reset();
} }

+ 2
- 2
src/game/controls.hpp View File

@ -56,12 +56,12 @@ void setup_game_controls(::game& ctx);
void enable_window_controls(::game& ctx); void enable_window_controls(::game& ctx);
void enable_menu_controls(::game& ctx); void enable_menu_controls(::game& ctx);
void enable_game_controls(::game& ctx); void enable_game_controls(::game& ctx);
void enable_nuptial_flight_controls(::game& ctx);
void enable_keeper_controls(::game& ctx);
void disable_window_controls(::game& ctx); void disable_window_controls(::game& ctx);
void disable_menu_controls(::game& ctx); void disable_menu_controls(::game& ctx);
void disable_game_controls(::game& ctx); void disable_game_controls(::game& ctx);
void disable_nuptial_flight_controls(::game& ctx);
void disable_keeper_controls(::game& ctx);
#endif // ANTKEEPER_GAME_CONTROLS_HPP #endif // ANTKEEPER_GAME_CONTROLS_HPP

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

@ -839,7 +839,7 @@ void game::setup_rendering()
barycentric_attribute.stride = billboard_vertex_stride; barycentric_attribute.stride = billboard_vertex_stride;
barycentric_attribute.type = gl::vertex_attribute_type::float_32; barycentric_attribute.type = gl::vertex_attribute_type::float_32;
barycentric_attribute.components = 3; barycentric_attribute.components = 3;
attribute_offset += barycentric_attribute.components * sizeof(float);
//attribute_offset += barycentric_attribute.components * sizeof(float);
// Bind vertex attributes to VAO // Bind vertex attributes to VAO
billboard_vao->bind(render::vertex_attribute::position, position_attribute); billboard_vao->bind(render::vertex_attribute::position, position_attribute);
@ -1187,7 +1187,7 @@ void game::setup_controls()
window_action_map.set_event_queue(input_event_queue); window_action_map.set_event_queue(input_event_queue);
menu_action_map.set_event_queue(input_event_queue); menu_action_map.set_event_queue(input_event_queue);
movement_action_map.set_event_queue(input_event_queue); movement_action_map.set_event_queue(input_event_queue);
nuptial_flight_action_map.set_event_queue(input_event_queue);
keeper_action_map.set_event_queue(input_event_queue);
// Default control profile settings // Default control profile settings
control_profile_filename = "controls.cfg"; control_profile_filename = "controls.cfg";

+ 11
- 3
src/game/game.hpp View File

@ -194,7 +194,7 @@ public:
input::action_map window_action_map; input::action_map window_action_map;
input::action_map menu_action_map; input::action_map menu_action_map;
input::action_map movement_action_map; input::action_map movement_action_map;
input::action_map nuptial_flight_action_map;
input::action_map keeper_action_map;
input::mapper input_mapper; input::mapper input_mapper;
input::action fullscreen_action; input::action fullscreen_action;
@ -213,13 +213,21 @@ public:
input::action move_up_action; input::action move_up_action;
input::action move_down_action; input::action move_down_action;
input::action pause_action; input::action pause_action;
input::action pick_mate_action;
input::action mouse_pick_action;
input::action mouse_look_action;
std::vector<std::shared_ptr<::event::subscription>> window_action_subscriptions; std::vector<std::shared_ptr<::event::subscription>> window_action_subscriptions;
std::vector<std::shared_ptr<::event::subscription>> menu_action_subscriptions; std::vector<std::shared_ptr<::event::subscription>> menu_action_subscriptions;
std::vector<std::shared_ptr<::event::subscription>> menu_mouse_subscriptions; std::vector<std::shared_ptr<::event::subscription>> menu_mouse_subscriptions;
std::vector<std::shared_ptr<::event::subscription>> movement_action_subscriptions; std::vector<std::shared_ptr<::event::subscription>> movement_action_subscriptions;
// Control settings
float mouse_pan_sensitivity{1.0f};
float mouse_tilt_sensitivity{1.0f};
bool toggle_mouse_look{false};
bool invert_mouse_pan{false};
bool invert_mouse_tilt{false};
// Debugging // Debugging
math::moving_average<float, 30> average_frame_time; math::moving_average<float, 30> average_frame_time;
std::unique_ptr<scene::text> frame_time_text; std::unique_ptr<scene::text> frame_time_text;
@ -232,7 +240,7 @@ public:
// Queue for scheduling "next frame" function calls // Queue for scheduling "next frame" function calls
std::queue<std::function<void()>> function_queue; std::queue<std::function<void()>> function_queue;
bool mouse_look;
/// Game loop /// Game loop
::loop loop; ::loop loop;

+ 119
- 227
src/game/states/nest-selection-state.cpp View File

@ -157,6 +157,9 @@ nest_selection_state::nest_selection_state(::game& ctx):
// Satisfy first person camera rig constraints // Satisfy first person camera rig constraints
satisfy_first_person_camera_rig_constraints(); satisfy_first_person_camera_rig_constraints();
// Setup controls
setup_controls();
// auto color_checker_archetype = ctx.resource_manager->load<entity::archetype>("color-checker.ent"); // auto color_checker_archetype = ctx.resource_manager->load<entity::archetype>("color-checker.ent");
// color_checker_archetype->create(*ctx.entity_registry); // color_checker_archetype->create(*ctx.entity_registry);
// auto ruler_archetype = ctx.resource_manager->load<entity::archetype>("ruler-10cm.ent"); // auto ruler_archetype = ctx.resource_manager->load<entity::archetype>("ruler-10cm.ent");
@ -195,6 +198,7 @@ nest_selection_state::nest_selection_state(::game& ctx):
[&ctx]() [&ctx]()
{ {
::enable_game_controls(ctx); ::enable_game_controls(ctx);
::enable_keeper_controls(ctx);
} }
); );
@ -211,6 +215,7 @@ nest_selection_state::~nest_selection_state()
// Disable game controls // Disable game controls
::disable_game_controls(ctx); ::disable_game_controls(ctx);
::disable_keeper_controls(ctx);
destroy_first_person_camera_rig(); destroy_first_person_camera_rig();
@ -387,6 +392,120 @@ void nest_selection_state::satisfy_first_person_camera_rig_constraints()
); );
} }
void nest_selection_state::setup_controls()
{
// Enable/toggle mouse look
action_subscriptions.emplace_back
(
ctx.mouse_look_action.get_activated_channel().subscribe
(
[&](const auto& event)
{
if (ctx.toggle_mouse_look)
{
mouse_look = !mouse_look;
}
else
{
mouse_look = true;
}
//ctx.app->set_relative_mouse_mode(mouse_look);
}
)
);
// Disable mouse look
action_subscriptions.emplace_back
(
ctx.mouse_look_action.get_deactivated_channel().subscribe
(
[&](const auto& event)
{
if (!ctx.toggle_mouse_look && mouse_look)
{
mouse_look = false;
//ctx.app->set_relative_mouse_mode(false);
}
}
)
);
// Mouse look
mouse_motion_subscription = ctx.input_manager->get_event_queue().subscribe<input::mouse_moved_event>
(
[&](const auto& event)
{
if (!mouse_look)
{
return;
}
const float mouse_tilt_factor = ctx.mouse_tilt_sensitivity * 0.01f * (ctx.invert_mouse_tilt ? -1.0f : 1.0f);
const float mouse_pan_factor = ctx.mouse_pan_sensitivity * 0.01f * (ctx.invert_mouse_pan ? -1.0f : 1.0f);
ctx.entity_registry->patch<spring_rotation_constraint>
(
first_person_camera_rig_spring_rotation_eid,
[&](auto& component)
{
component.spring.x1[0] -= mouse_pan_factor * static_cast<float>(event.difference.x());
component.spring.x1[1] += mouse_tilt_factor * static_cast<float>(event.difference.y());
component.spring.x1[1] = std::min(math::half_pi<float>, std::max(-math::half_pi<float>, component.spring.x1[1]));
}
);
}
);
// Move forward
action_subscriptions.emplace_back
(
ctx.move_forward_action.get_active_channel().subscribe
(
[&](const auto& event)
{
move_first_person_camera_rig({0, -1}, event.input_value);
}
)
);
// Move back
action_subscriptions.emplace_back
(
ctx.move_back_action.get_active_channel().subscribe
(
[&](const auto& event)
{
move_first_person_camera_rig({0, 1}, event.input_value);
}
)
);
// Move left
action_subscriptions.emplace_back
(
ctx.move_left_action.get_active_channel().subscribe
(
[&](const auto& event)
{
move_first_person_camera_rig({-1, 0}, event.input_value);
}
)
);
// Move right
action_subscriptions.emplace_back
(
ctx.move_right_action.get_active_channel().subscribe
(
[&](const auto& event)
{
move_first_person_camera_rig({1, 0}, event.input_value);
}
)
);
}
void nest_selection_state::enable_controls() void nest_selection_state::enable_controls()
{ {
/* /*
@ -433,49 +552,7 @@ void nest_selection_state::enable_controls()
const float gamepad_tilt_factor = gamepad_tilt_sensitivity * (gamepad_invert_tilt ? -1.0f : 1.0f); const float gamepad_tilt_factor = gamepad_tilt_sensitivity * (gamepad_invert_tilt ? -1.0f : 1.0f);
const float gamepad_pan_factor = gamepad_pan_sensitivity * (gamepad_invert_pan ? -1.0f : 1.0f); const float gamepad_pan_factor = gamepad_pan_sensitivity * (gamepad_invert_pan ? -1.0f : 1.0f);
// Mouse look control
ctx.controls["mouse_look"]->set_activated_callback
(
[&, mouse_look_toggle]()
{
if (mouse_look_toggle)
mouse_look = !mouse_look;
else
mouse_look = true;
ctx.app->set_relative_mouse_mode(mouse_look);
}
);
ctx.controls["mouse_look"]->set_deactivated_callback
(
[&, mouse_look_toggle]()
{
if (!mouse_look_toggle && mouse_look)
{
mouse_look = false;
ctx.app->set_relative_mouse_mode(false);
}
}
);
// Look right control
ctx.controls["look_right_mouse"]->set_active_callback
(
[&, mouse_pan_factor](float value)
{
if (!mouse_look)
return;
ctx.entity_registry->patch<spring_rotation_constraint>
(
first_person_camera_rig_spring_rotation_eid,
[&, mouse_pan_factor](auto& component)
{
component.spring.x1[0] -= mouse_pan_factor * value;
}
);
}
);
ctx.controls["look_right_gamepad"]->set_active_callback ctx.controls["look_right_gamepad"]->set_active_callback
( (
[&, gamepad_pan_factor](float value) [&, gamepad_pan_factor](float value)
@ -490,25 +567,6 @@ void nest_selection_state::enable_controls()
); );
} }
); );
// Look left control
ctx.controls["look_left_mouse"]->set_active_callback
(
[&, mouse_pan_factor](float value)
{
if (!mouse_look)
return;
ctx.entity_registry->patch<spring_rotation_constraint>
(
first_person_camera_rig_spring_rotation_eid,
[&, mouse_pan_factor](auto& component)
{
component.spring.x1[0] += mouse_pan_factor * value;
}
);
}
);
ctx.controls["look_left_gamepad"]->set_active_callback ctx.controls["look_left_gamepad"]->set_active_callback
( (
[&, gamepad_pan_factor](float value) [&, gamepad_pan_factor](float value)
@ -523,26 +581,6 @@ void nest_selection_state::enable_controls()
); );
} }
); );
// Look up control
ctx.controls["look_up_mouse"]->set_active_callback
(
[&, mouse_tilt_factor](float value)
{
if (!mouse_look)
return;
ctx.entity_registry->patch<spring_rotation_constraint>
(
first_person_camera_rig_spring_rotation_eid,
[&, mouse_tilt_factor](auto& component)
{
component.spring.x1[1] -= mouse_tilt_factor * value;
component.spring.x1[1] = std::max(-math::half_pi<float>, component.spring.x1[1]);
}
);
}
);
ctx.controls["look_up_gamepad"]->set_active_callback ctx.controls["look_up_gamepad"]->set_active_callback
( (
[&, gamepad_tilt_factor](float value) [&, gamepad_tilt_factor](float value)
@ -558,26 +596,6 @@ void nest_selection_state::enable_controls()
); );
} }
); );
// Look down control
ctx.controls["look_down_mouse"]->set_active_callback
(
[&, mouse_tilt_factor](float value)
{
if (!mouse_look)
return;
ctx.entity_registry->patch<spring_rotation_constraint>
(
first_person_camera_rig_spring_rotation_eid,
[&, mouse_tilt_factor](auto& component)
{
component.spring.x1[1] += mouse_tilt_factor * value;
component.spring.x1[1] = std::min(math::half_pi<float>, component.spring.x1[1]);
}
);
}
);
ctx.controls["look_down_gamepad"]->set_active_callback ctx.controls["look_down_gamepad"]->set_active_callback
( (
[&, gamepad_tilt_factor](float value) [&, gamepad_tilt_factor](float value)
@ -612,59 +630,6 @@ void nest_selection_state::enable_controls()
} }
); );
// Mouse select control
ctx.controls["select_mouse"]->set_activated_callback
(
[&]()
{
}
);
// Move forward control
ctx.controls["move_forward"]->set_active_callback
(
[&](float value)
{
move_first_person_camera_rig({0, -1}, value);
}
);
// Move back control
ctx.controls["move_back"]->set_active_callback
(
[&](float value)
{
move_first_person_camera_rig({0, 1}, value);
}
);
// Move right control
ctx.controls["move_right"]->set_active_callback
(
[&](float value)
{
move_first_person_camera_rig({1, 0}, value);
}
);
// Move left control
ctx.controls["move_left"]->set_active_callback
(
[&](float value)
{
move_first_person_camera_rig({-1, 0}, value);
}
);
// Action control
ctx.controls["action"]->set_activated_callback
(
[&]()
{
}
);
// Fast-forward // Fast-forward
ctx.controls["fast_forward"]->set_activated_callback ctx.controls["fast_forward"]->set_activated_callback
@ -695,83 +660,10 @@ void nest_selection_state::enable_controls()
::world::set_time_scale(ctx, time_scale); ::world::set_time_scale(ctx, time_scale);
} }
); );
// Setup pause control
ctx.controls["pause"]->set_activated_callback
(
[this, &ctx = this->ctx]()
{
// Disable controls
this->disable_controls();
// Set resume callback
ctx.resume_callback = [this, &ctx]()
{
this->enable_controls();
ctx.resume_callback = nullptr;
};
// Push pause menu state
ctx.state_machine.emplace(std::make_unique<pause_menu_state>(ctx));
}
);
ctx.controls["increase_exposure"]->set_active_callback
(
[&ctx = this->ctx](float)
{
//ctx.astronomy_system->set_exposure_offset(ctx.astronomy_system->get_exposure_offset() - 1.0f);
ctx.surface_camera->set_exposure(ctx.surface_camera->get_exposure() + 2.0f * static_cast<float>(ctx.loop.get_update_period()));
debug::log::info("EV100: " + std::to_string(ctx.surface_camera->get_exposure()));
}
);
ctx.controls["decrease_exposure"]->set_active_callback
(
[&ctx = this->ctx](float)
{
//ctx.astronomy_system->set_exposure_offset(ctx.astronomy_system->get_exposure_offset() + 1.0f);
ctx.surface_camera->set_exposure(ctx.surface_camera->get_exposure() - 2.0f * static_cast<float>(ctx.loop.get_update_period()));
debug::log::info("EV100: " + std::to_string(ctx.surface_camera->get_exposure()));
}
);
*/ */
} }
void nest_selection_state::disable_controls() void nest_selection_state::disable_controls()
{ {
/*
if (mouse_look)
{
mouse_look = false;
ctx.app->set_relative_mouse_mode(false);
}
ctx.controls["mouse_look"]->set_activated_callback(nullptr);
ctx.controls["mouse_look"]->set_deactivated_callback(nullptr);
ctx.controls["look_right_mouse"]->set_active_callback(nullptr);
ctx.controls["look_right_gamepad"]->set_active_callback(nullptr);
ctx.controls["look_left_mouse"]->set_active_callback(nullptr);
ctx.controls["look_left_gamepad"]->set_active_callback(nullptr);
ctx.controls["look_up_mouse"]->set_active_callback(nullptr);
ctx.controls["look_up_gamepad"]->set_active_callback(nullptr);
ctx.controls["look_down_mouse"]->set_active_callback(nullptr);
ctx.controls["look_down_gamepad"]->set_active_callback(nullptr);
ctx.controls["move_up"]->set_active_callback(nullptr);
ctx.controls["move_down"]->set_active_callback(nullptr);
ctx.controls["select_mouse"]->set_activated_callback(nullptr);
ctx.controls["move_forward"]->set_active_callback(nullptr);
ctx.controls["move_back"]->set_active_callback(nullptr);
ctx.controls["move_right"]->set_active_callback(nullptr);
ctx.controls["move_left"]->set_active_callback(nullptr);
ctx.controls["action"]->set_activated_callback(nullptr);
ctx.controls["fast_forward"]->set_activated_callback(nullptr);
ctx.controls["fast_forward"]->set_deactivated_callback(nullptr);
ctx.controls["rewind"]->set_activated_callback(nullptr);
ctx.controls["rewind"]->set_deactivated_callback(nullptr);
ctx.controls["pause"]->set_activated_callback(nullptr);
ctx.controls["increase_exposure"]->set_active_callback(nullptr);
ctx.controls["decrease_exposure"]->set_active_callback(nullptr);
*/
} }

+ 7
- 1
src/game/states/nest-selection-state.hpp View File

@ -37,9 +37,16 @@ private:
void set_first_person_camera_rig_pedestal(float pedestal); void set_first_person_camera_rig_pedestal(float pedestal);
void move_first_person_camera_rig(const float2& direction, float factor); void move_first_person_camera_rig(const float2& direction, float factor);
void satisfy_first_person_camera_rig_constraints(); void satisfy_first_person_camera_rig_constraints();
void setup_controls();
void enable_controls(); void enable_controls();
void disable_controls(); void disable_controls();
std::vector<std::shared_ptr<::event::subscription>> action_subscriptions;
std::shared_ptr<::event::subscription> mouse_motion_subscription;
bool mouse_look{false};
entity::id first_person_camera_rig_eid; entity::id first_person_camera_rig_eid;
entity::id first_person_camera_rig_spring_translation_eid; entity::id first_person_camera_rig_spring_translation_eid;
entity::id first_person_camera_rig_spring_rotation_eid; entity::id first_person_camera_rig_spring_rotation_eid;
@ -55,7 +62,6 @@ private:
float first_person_camera_far_speed; float first_person_camera_far_speed;
float first_person_camera_rig_pedestal_speed; float first_person_camera_rig_pedestal_speed;
float first_person_camera_rig_pedestal; float first_person_camera_rig_pedestal;
bool mouse_look;
}; };
#endif // ANTKEEPER_NEST_SELECTION_STATE_HPP #endif // ANTKEEPER_NEST_SELECTION_STATE_HPP

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

@ -201,7 +201,7 @@ nuptial_flight_state::nuptial_flight_state(::game& ctx):
[&ctx]() [&ctx]()
{ {
::enable_nuptial_flight_controls(ctx);
::enable_keeper_controls(ctx);
::enable_game_controls(ctx); ::enable_game_controls(ctx);
} }
); );
@ -221,7 +221,7 @@ nuptial_flight_state::~nuptial_flight_state()
debug::log::trace("Exiting nuptial flight state..."); debug::log::trace("Exiting nuptial flight state...");
// Disable game controls // Disable game controls
::disable_nuptial_flight_controls(ctx);
::disable_keeper_controls(ctx);
::disable_game_controls(ctx); ::disable_game_controls(ctx);
// Remove text from UI // Remove text from UI
@ -468,7 +468,7 @@ void nuptial_flight_state::setup_controls()
{ {
action_subscriptions.emplace_back action_subscriptions.emplace_back
( (
ctx.pick_mate_action.get_activated_channel().subscribe
ctx.mouse_pick_action.get_activated_channel().subscribe
( (
[&](const auto& event) [&](const auto& event)
{ {

+ 1
- 1
src/game/states/nuptial-flight-state.hpp View File

@ -83,7 +83,7 @@ private:
scene::text selection_text; scene::text selection_text;
// Controls // Controls
bool mouse_look;
bool mouse_look{false};
std::vector<std::shared_ptr<::event::subscription>> action_subscriptions; std::vector<std::shared_ptr<::event::subscription>> action_subscriptions;
}; };

Loading…
Cancel
Save