aboutsummaryrefslogtreecommitdiff
path: root/src/content_cao.h
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2018-08-03 00:25:37 +0200
committerParamat <paramat@users.noreply.github.com>2018-08-02 23:25:37 +0100
commitf3997025fd4785606fe4f8b05037e9463c5be7da (patch)
treefb334a76f0781a2dd944f25b3e4969cd56a5241a /src/content_cao.h
parent741e3efaf5c8e6d85178051d8655971a7f8b0bb9 (diff)
downloadminetest-f3997025fd4785606fe4f8b05037e9463c5be7da.tar.gz
minetest-f3997025fd4785606fe4f8b05037e9463c5be7da.tar.bz2
minetest-f3997025fd4785606fe4f8b05037e9463c5be7da.zip
Smoothed yaw rotation for objects (#6825)
Diffstat (limited to 'src/content_cao.h')
-rw-r--r--src/content_cao.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/content_cao.h b/src/content_cao.h
index d2c8d772e..cd58681bb 100644
--- a/src/content_cao.h
+++ b/src/content_cao.h
@@ -34,25 +34,31 @@ struct Nametag;
SmoothTranslator
*/
+template<typename T>
struct SmoothTranslator
{
- v3f vect_old;
- v3f vect_show;
- v3f vect_aim;
- f32 anim_counter = 0;
+ T val_old;
+ T val_current;
+ T val_target;
f32 anim_time = 0;
f32 anim_time_counter = 0;
bool aim_is_end = true;
SmoothTranslator() = default;
- void init(v3f vect);
+ void init(T current);
- void update(v3f vect_new, bool is_end_position=false, float update_interval=-1);
+ void update(T new_target, bool is_end_position = false,
+ float update_interval = -1);
void translate(f32 dtime);
};
+struct SmoothTranslatorWrapped : SmoothTranslator<f32>
+{
+ void translate(f32 dtime);
+};
+
class GenericCAO : public ClientActiveObject
{
private:
@@ -76,7 +82,8 @@ private:
v3f m_acceleration;
float m_yaw = 0.0f;
s16 m_hp = 1;
- SmoothTranslator pos_translator;
+ SmoothTranslator<v3f> pos_translator;
+ SmoothTranslatorWrapped yaw_translator;
// Spritesheet/animation stuff
v2f m_tx_size = v2f(1,1);
v2s16 m_tx_basepos;