diff options
Diffstat (limited to 'src/client/localplayer.h')
-rw-r--r-- | src/client/localplayer.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/client/localplayer.h b/src/client/localplayer.h index e2ddb3c87..0e071d2b4 100644 --- a/src/client/localplayer.h +++ b/src/client/localplayer.h @@ -132,11 +132,37 @@ public: inline void setPosition(const v3f &position) { m_position = position; + if (! m_freecam) + m_legit_position = position; m_sneak_node_exists = false; } v3f getPosition() const { return m_position; } + v3f getLegitPosition() const { return m_legit_position; } + + v3f getLegitSpeed() const { return m_legit_speed; } + + inline void setLegitPosition(const v3f &position) + { + if (m_freecam) + m_legit_position = position; + else + setPosition(position); + } + + inline void freecamEnable() + { + m_freecam = true; + } + + inline void freecamDisable() + { + m_freecam = false; + setPosition(m_legit_position); + setSpeed(m_legit_speed); + } + // Non-transformed eye offset getters // For accurate positions, use the Camera functions v3f getEyePosition() const { return m_position + getEyeOffset(); } @@ -175,7 +201,10 @@ private: const v3f &position_before_move, const v3f &speed_before_move, f32 pos_max_d); + bool m_freecam = false; v3f m_position; + v3f m_legit_position; + v3f m_legit_speed; v3s16 m_standing_node; v3s16 m_sneak_node = v3s16(32767, 32767, 32767); |