mirror of
https://github.com/luanti-org/luanti.git
synced 2025-11-04 09:15:29 +01:00
Smoothed yaw rotation for objects (#6825)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user