The player is always snapped to 0, 45, 90, 135... degrees. This makes
it more comfortable when walking inside buildings.
static int keyboard_on = 0;
static enum keycode vr_key_pressed = 0, vr_key = 0;
static int we_walk = 0, we_rotate = 0;
static int keyboard_on = 0;
static enum keycode vr_key_pressed = 0, vr_key = 0;
static int we_walk = 0, we_rotate = 0;
+static double degrees45 = 45.0 / 180.0 * M_PI;
static void handle_vr_poses(void)
{
static void handle_vr_poses(void)
{
mercenary_vr_move(1, move_east, move_north, 256, 256);
}
mercenary_vr_move(1, move_east, move_north, 256, 256);
}
+ /* snap orientation to steps of 45 degrees */
- /* change orientation */
mercenary_get_orientation(&roll, &pitch, &yaw);
mercenary_get_orientation(&roll, &pitch, &yaw);
+ yaw = round(yaw / degrees45) * degrees45;
+ /* if we rotate: change orientation */
- mercenary_set_orientation(yaw - 45.0 / 180.0 * M_PI);
- mercenary_set_orientation(yaw + 45.0 / 180.0 * M_PI);
- /* rotate only once */
+ yaw += degrees45;
+ /* rotate only once per stick movement */
+ mercenary_set_orientation(yaw);
}
}
if (joystick_set_x_last && !joystick_set_x)
}
}
if (joystick_set_x_last && !joystick_set_x)