Browse Source

Move rotation controls to control system and make rotation continuous

master
C. J. Howard 4 years ago
parent
commit
165f4fdea1
3 changed files with 9 additions and 18 deletions
  1. +2
    -16
      src/game/bootloader.cpp
  2. +0
    -2
      src/game/game-context.hpp
  3. +7
    -0
      src/game/systems/control-system.cpp

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

@ -910,18 +910,6 @@ void setup_controls(game_context* ctx)
} }
); );
// Create rotation controls
ctx->rotate_ccw_control = new control();
ctx->rotate_ccw_control->set_activated_callback
(
std::bind(&camera_system::pan, ctx->camera_system, math::radians(90.0f))
);
ctx->rotate_cw_control = new control();
ctx->rotate_cw_control->set_activated_callback
(
std::bind(&camera_system::pan, ctx->camera_system, math::radians(-90.0f))
);
// Create menu back control // Create menu back control
ctx->menu_back_control = new control(); ctx->menu_back_control = new control();
ctx->menu_back_control->set_activated_callback ctx->menu_back_control->set_activated_callback
@ -936,8 +924,6 @@ void setup_controls(game_context* ctx)
ctx->application_controls = new control_set(); ctx->application_controls = new control_set();
ctx->application_controls->add_control(ctx->toggle_fullscreen_control); ctx->application_controls->add_control(ctx->toggle_fullscreen_control);
ctx->application_controls->add_control(ctx->screenshot_control); ctx->application_controls->add_control(ctx->screenshot_control);
ctx->application_controls->add_control(ctx->rotate_ccw_control);
ctx->application_controls->add_control(ctx->rotate_cw_control);
// Create menu control set // Create menu control set
ctx->menu_controls = new control_set(); ctx->menu_controls = new control_set();
@ -952,8 +938,6 @@ void setup_controls(game_context* ctx)
// Application control mappings // Application control mappings
ctx->input_event_router->add_mapping(key_mapping(ctx->toggle_fullscreen_control, nullptr, scancode::f11)); ctx->input_event_router->add_mapping(key_mapping(ctx->toggle_fullscreen_control, nullptr, scancode::f11));
ctx->input_event_router->add_mapping(key_mapping(ctx->screenshot_control, nullptr, scancode::f12)); ctx->input_event_router->add_mapping(key_mapping(ctx->screenshot_control, nullptr, scancode::f12));
ctx->input_event_router->add_mapping(key_mapping(ctx->rotate_ccw_control, nullptr, scancode::q));
ctx->input_event_router->add_mapping(key_mapping(ctx->rotate_cw_control, nullptr, scancode::e));
// Add menu control mappings // Add menu control mappings
ctx->input_event_router->add_mapping(key_mapping(ctx->menu_back_control, nullptr, scancode::escape)); ctx->input_event_router->add_mapping(key_mapping(ctx->menu_back_control, nullptr, scancode::escape));
@ -1021,6 +1005,8 @@ void setup_controls(game_context* ctx)
ctx->input_event_router->add_mapping(game_controller_button_mapping(ctx->control_system->get_descend_control(), nullptr, game_controller_button::a)); ctx->input_event_router->add_mapping(game_controller_button_mapping(ctx->control_system->get_descend_control(), nullptr, game_controller_button::a));
ctx->input_event_router->add_mapping(game_controller_axis_mapping(ctx->control_system->get_zoom_out_control(), nullptr, game_controller_axis::trigger_left, false)); ctx->input_event_router->add_mapping(game_controller_axis_mapping(ctx->control_system->get_zoom_out_control(), nullptr, game_controller_axis::trigger_left, false));
ctx->input_event_router->add_mapping(game_controller_axis_mapping(ctx->control_system->get_zoom_in_control(), nullptr, game_controller_axis::trigger_right, false)); ctx->input_event_router->add_mapping(game_controller_axis_mapping(ctx->control_system->get_zoom_in_control(), nullptr, game_controller_axis::trigger_right, false));
ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_rotate_ccw_control(), nullptr, scancode::q));
ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_rotate_cw_control(), nullptr, scancode::e));
ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_equip_forceps_control(), nullptr, scancode::one)); ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_equip_forceps_control(), nullptr, scancode::one));
ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_equip_brush_control(), nullptr, scancode::two)); ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_equip_brush_control(), nullptr, scancode::two));

+ 0
- 2
src/game/game-context.hpp View File

@ -204,8 +204,6 @@ struct game_context
control* menu_back_control; control* menu_back_control;
control* menu_select_control; control* menu_select_control;
control* screenshot_control; control* screenshot_control;
control* rotate_ccw_control;
control* rotate_cw_control;
control* toggle_fullscreen_control; control* toggle_fullscreen_control;
// Entities // Entities

+ 7
- 0
src/game/systems/control-system.cpp View File

@ -96,6 +96,13 @@ void control_system::update(double t, double dt)
if (zoom_out_control.is_active()) if (zoom_out_control.is_active())
camera_system->zoom(-zoom_speed * dt); camera_system->zoom(-zoom_speed * dt);
// Rotate camera
const float rotation_speed = math::radians(270.0f);
if (rotate_ccw_control.is_active())
camera_system->pan(rotation_speed * dt * std::min<float>(1.0f, rotate_ccw_control.get_current_value()));
if (rotate_cw_control.is_active())
camera_system->pan(-rotation_speed * dt * std::min<float>(1.0f, rotate_cw_control.get_current_value()));
// Move camera // Move camera
float3 movement{0.0f, 0.0f, 0.0f}; float3 movement{0.0f, 0.0f, 0.0f};
if (move_right_control.is_active()) if (move_right_control.is_active())

Loading…
Cancel
Save