#include "camera.h"
#include "debug.h"
+#include "client.h"
#include "main.h" // for g_settings
#include "map.h"
#include "player.h"
-#include "utility.h"
#include <cmath>
const s32 BOBFRAMES = 0x1000000; // must be a power of two
m_time_per_range(30. / 50), // a sane default of 30ms per 50 nodes of range
m_view_bobbing_anim(0),
- m_view_bobbing_state(0)
+ m_view_bobbing_state(0),
+ m_view_bobbing_slow(false)
{
//dstream<<__FUNCTION_NAME<<std::endl;
{
if (m_view_bobbing_state != 0)
{
- s32 offset = MYMAX(dtime * BOBFRAMES, 1);
+ f32 bobspeed = (m_view_bobbing_slow ? (BOBFRAMES / 4) : BOBFRAMES);
+ s32 offset = MYMAX(dtime * bobspeed, 1);
if (m_view_bobbing_state == 2)
{
// Animation is getting turned off
// Set player node transformation
m_playernode->setPosition(player->getPosition());
- //m_playernode->setRotation(v3f(player->getPitch(), -1 * player->getYaw(), 0));
m_playernode->setRotation(v3f(0, -1 * player->getYaw(), 0));
m_playernode->updateAbsolutePosition();
// view bobbing is enabled and free_move is off,
// start (or continue) the view bobbing animation.
v3f speed = player->getSpeed();
- //dstream<<"speed: ("<<speed.X<<","<<speed.Y<<","<<speed.Z<<")"<<std::endl;
if ((hypot(speed.X, speed.Z) > BS) &&
- (fabs(speed.Y) < BS/10) &&
+ (player->touching_ground) &&
(g_settings.getBool("view_bobbing") == true) &&
(g_settings.getBool("free_move") == false))
{
// Stop animation
m_view_bobbing_state = 2;
}
+ m_view_bobbing_slow = player->in_water_stable;
}
void Camera::updateViewingRange(f32 frametime_in)
// If 1, view bobbing is on (player is walking).
// If 2, view bobbing is getting switched off.
s32 m_view_bobbing_state;
+ // If true, view bobbing is slown down (player is swimming)
+ bool m_view_bobbing_slow;
};
#endif