Wieldmesh: Natural orientation depending on pitch (#5490)
authorkilbith <jeanpatrick.guerrero@gmail.com>
Fri, 31 Mar 2017 19:57:08 +0000 (21:57 +0200)
committerLoic Blot <loic.blot@unix-experience.fr>
Fri, 31 Mar 2017 20:00:05 +0000 (22:00 +0200)
src/camera.cpp

index a7679e43adb581eb88832176d0f5f4050041db94..d5c337fe82e6ffd671af4622237ecac7e26f50e0 100644 (file)
@@ -404,9 +404,12 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
        m_cameranode->setAspectRatio(m_aspect);
        m_cameranode->setFOV(m_fov_y);
 
+       float wieldmesh_offset_Y = -35 + player->getPitch() * 0.05;
+       wieldmesh_offset_Y = rangelim(wieldmesh_offset_Y, -52, -32);
+
        // Position the wielded item
        //v3f wield_position = v3f(45, -35, 65);
-       v3f wield_position = v3f(55, -35, 65);
+       v3f wield_position = v3f(55, wieldmesh_offset_Y, 65);
        //v3f wield_rotation = v3f(-100, 120, -100);
        v3f wield_rotation = v3f(-100, 120, -100);
        wield_position.Y += fabs(m_wield_change_timer)*320 - 40;