aboutsummaryrefslogtreecommitdiff
path: root/src/client/camera.cpp
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2021-10-20 21:51:21 +0200
committerGitHub <noreply@github.com>2021-10-20 21:51:21 +0200
commit0d345dc1bd56068b8d40f8ff712a9263c6ff7517 (patch)
tree3558b64dc2fefc38b3592bc75ce813f80123b23d /src/client/camera.cpp
parent86b44ecd8280d8304aa26a600fc004d40a970020 (diff)
downloadminetest-0d345dc1bd56068b8d40f8ff712a9263c6ff7517.tar.gz
minetest-0d345dc1bd56068b8d40f8ff712a9263c6ff7517.tar.bz2
minetest-0d345dc1bd56068b8d40f8ff712a9263c6ff7517.zip
Fix view bobbing not resetting when resting
partially fixes #11694, also fixes #11692
Diffstat (limited to 'src/client/camera.cpp')
-rw-r--r--src/client/camera.cpp34
1 files changed, 4 insertions, 30 deletions
diff --git a/src/client/camera.cpp b/src/client/camera.cpp
index 48e60c433..7adcf2376 100644
--- a/src/client/camera.cpp
+++ b/src/client/camera.cpp
@@ -186,9 +186,7 @@ void Camera::step(f32 dtime)
m_view_bobbing_anim -= offset;
} else if (m_view_bobbing_anim > 0.75) {
m_view_bobbing_anim += offset;
- }
-
- if (m_view_bobbing_anim < 0.5) {
+ } else if (m_view_bobbing_anim < 0.5) {
m_view_bobbing_anim += offset;
if (m_view_bobbing_anim > 0.5)
m_view_bobbing_anim = 0.5;
@@ -410,41 +408,17 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
f32 bobfrac = my_modf(m_view_bobbing_anim * 2);
f32 bobdir = (m_view_bobbing_anim < 0.5) ? 1.0 : -1.0;
- #if 1
f32 bobknob = 1.2;
f32 bobtmp = sin(pow(bobfrac, bobknob) * M_PI);
- //f32 bobtmp2 = cos(pow(bobfrac, bobknob) * M_PI);
v3f bobvec = v3f(
0.3 * bobdir * sin(bobfrac * M_PI),
-0.28 * bobtmp * bobtmp,
0.);
- //rel_cam_pos += 0.2 * bobvec;
- //rel_cam_target += 0.03 * bobvec;
- //rel_cam_up.rotateXYBy(0.02 * bobdir * bobtmp * M_PI);
- float f = 1.0;
- f *= m_cache_view_bobbing_amount;
- rel_cam_pos += bobvec * f;
- //rel_cam_target += 0.995 * bobvec * f;
- rel_cam_target += bobvec * f;
- rel_cam_target.Z -= 0.005 * bobvec.Z * f;
- //rel_cam_target.X -= 0.005 * bobvec.X * f;
- //rel_cam_target.Y -= 0.005 * bobvec.Y * f;
- rel_cam_up.rotateXYBy(-0.03 * bobdir * bobtmp * M_PI * f);
- #else
- f32 angle_deg = 1 * bobdir * sin(bobfrac * M_PI);
- f32 angle_rad = angle_deg * M_PI / 180;
- f32 r = 0.05;
- v3f off = v3f(
- r * sin(angle_rad),
- r * (cos(angle_rad) - 1),
- 0);
- rel_cam_pos += off;
- //rel_cam_target += off;
- rel_cam_up.rotateXYBy(angle_deg);
- #endif
-
+ rel_cam_pos += bobvec * m_cache_view_bobbing_amount;
+ rel_cam_target += bobvec * m_cache_view_bobbing_amount;
+ rel_cam_up.rotateXYBy(-0.03 * bobdir * bobtmp * M_PI * m_cache_view_bobbing_amount);
}
// Compute absolute camera position and target