aboutsummaryrefslogtreecommitdiff
path: root/src/content_cao.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-12 13:14:44 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:39 +0200
commit23adfff4fea9c1ad49e7bc4cd08341c2e1fded78 (patch)
tree7401d4ad3e91e4949b4a55b454eb573b63e6d33c /src/content_cao.h
parentb35adfbd2dd434d0b75b91b0b4784ef5cdef2ae0 (diff)
downloadminetest-23adfff4fea9c1ad49e7bc4cd08341c2e1fded78.tar.gz
minetest-23adfff4fea9c1ad49e7bc4cd08341c2e1fded78.tar.bz2
minetest-23adfff4fea9c1ad49e7bc4cd08341c2e1fded78.zip
Scripting WIP
Diffstat (limited to 'src/content_cao.h')
-rw-r--r--src/content_cao.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/content_cao.h b/src/content_cao.h
index 3231a190f..72cb94eb7 100644
--- a/src/content_cao.h
+++ b/src/content_cao.h
@@ -35,6 +35,7 @@ struct SmoothTranslator
v3f vect_old;
v3f vect_show;
v3f vect_aim;
+ bool aim_is_end;
f32 anim_counter;
f32 anim_time;
f32 anim_time_counter;
@@ -53,6 +54,7 @@ struct SmoothTranslator
vect_old = vect;
vect_show = vect;
vect_aim = vect;
+ aim_is_end = true;
anim_counter = 0;
anim_time = 0;
anim_time_counter = 0;
@@ -63,8 +65,9 @@ struct SmoothTranslator
init(vect_show);
}
- void update(v3f vect_new)
+ void update(v3f vect_new, bool is_end_position=false)
{
+ aim_is_end = is_end_position;
vect_old = vect_show;
vect_aim = vect_new;
if(anim_time < 0.001 || anim_time > 1.0)
@@ -85,8 +88,11 @@ struct SmoothTranslator
moveratio = anim_time_counter / anim_time;
// Move a bit less than should, to avoid oscillation
moveratio = moveratio * 0.5;
- if(moveratio > 1.5)
- moveratio = 1.5;
+ float move_end = 1.5;
+ if(aim_is_end)
+ move_end = 1.0;
+ if(moveratio > move_end)
+ moveratio = move_end;
vect_show = vect_old + vect_move * moveratio;
}