aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/camera.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/camera.cpp b/src/camera.cpp
index e5954a589..df7ea35b1 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -307,7 +307,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
PlayerEyeOffset += player->eye_offset_first;
else
PlayerEyeOffset += player->eye_offset_third;
-
+
// Set head node transformation
m_headnode->setPosition(PlayerEyeOffset+v3f(0,cameratilt*-player->hurt_tilt_strength+fall_bobbing,0));
m_headnode->setRotation(v3f(player->getPitch(), 0, cameratilt*player->hurt_tilt_strength));
@@ -369,7 +369,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
// Seperate camera position for calculation
v3f my_cp = m_camera_position;
-
+
// Reposition the camera for third person view
if (m_camera_mode > CAMERA_MODE_FIRST)
{
@@ -413,7 +413,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
(((s16)(my_cp.Y/BS) - m_camera_offset.Y)/CAMERA_OFFSET_STEP);
m_camera_offset.Z += CAMERA_OFFSET_STEP*
(((s16)(my_cp.Z/BS) - m_camera_offset.Z)/CAMERA_OFFSET_STEP);
-
+
// Set camera node transformation
m_cameranode->setPosition(my_cp-intToFloat(m_camera_offset, BS));
m_cameranode->setUpVector(abs_cam_up);
@@ -466,7 +466,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
wield_position.X -= 50 * sin(pow(digfrac, 0.8f) * M_PI);
wield_position.Y += 24 * sin(digfrac * 1.8 * M_PI);
wield_position.Z += 25 * 0.5;
-
+
// Euler angles are PURE EVIL, so why not use quaternions?
core::quaternion quat_begin(wield_rotation * core::DEGTORAD);
core::quaternion quat_end(v3f(80, 30, 100) * core::DEGTORAD);
@@ -491,15 +491,19 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
// Render distance feedback loop
updateViewingRange(frametime, busytime);
- // If the player seems to be walking on solid ground,
+ // If the player is walking, swimming, or climbing,
// view bobbing is enabled and free_move is off,
// start (or continue) the view bobbing animation.
v3f speed = player->getSpeed();
- if ((hypot(speed.X, speed.Z) > BS) &&
- (player->touching_ground) &&
- (m_cache_view_bobbing == true) &&
- (g_settings->getBool("free_move") == false ||
- !m_gamedef->checkLocalPrivilege("fly")))
+ const bool movement_XZ = hypot(speed.X, speed.Z) > BS;
+ const bool movement_Y = abs(speed.Y) > BS;
+
+ const bool walking = movement_XZ && player->touching_ground;
+ const bool swimming = (movement_XZ || player->swimming_vertical) && player->in_liquid;
+ const bool climbing = movement_Y && player->is_climbing;
+ if ((walking || swimming || climbing) &&
+ m_cache_view_bobbing &&
+ (!g_settings->getBool("free_move") || !m_gamedef->checkLocalPrivilege("fly")))
{
// Start animation
m_view_bobbing_state = 1;
@@ -542,7 +546,7 @@ void Camera::updateViewingRange(f32 frametime_in, f32 busytime_in)
f32 viewing_range_max = g_settings->getFloat("viewing_range_nodes_max");
viewing_range_max = MYMAX(viewing_range_min, viewing_range_max);
-
+
// Immediately apply hard limits
if(m_draw_control.wanted_range < viewing_range_min)
m_draw_control.wanted_range = viewing_range_min;
@@ -639,7 +643,7 @@ void Camera::updateViewingRange(f32 frametime_in, f32 busytime_in)
}
new_range += wanted_range_change;
-
+
//f32 new_range_unclamped = new_range;
new_range = MYMAX(new_range, viewing_range_min);
new_range = MYMIN(new_range, viewing_range_max);