From 0ce0c8fcfba655c8db5f53ce8e3ab7adfa59768a Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 21 Nov 2011 11:15:15 +0200 Subject: Improve LuaEntity velocity/acceleration handling (by kahrl); implement staticdata interface to Lua --- src/content_cao.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/content_cao.cpp') diff --git a/src/content_cao.cpp b/src/content_cao.cpp index ca9e22811..f5ef3fb07 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1278,6 +1278,8 @@ LuaEntityCAO::LuaEntityCAO(IGameDef *gamedef): m_meshnode(NULL), m_spritenode(NULL), m_position(v3f(0,10*BS,0)), + m_velocity(v3f(0,0,0)), + m_acceleration(v3f(0,0,0)), m_yaw(0), m_prop(new LuaEntityProperties) { @@ -1455,6 +1457,9 @@ void LuaEntityCAO::updateNodePos() void LuaEntityCAO::step(float dtime, ClientEnvironment *env) { + m_position += dtime * m_velocity + 0.5 * dtime * dtime * m_acceleration; + m_velocity += dtime * m_acceleration; + pos_translator.update(m_position, pos_translator.aim_is_end, pos_translator.anim_time); pos_translator.translate(dtime); updateNodePos(); } @@ -1471,6 +1476,10 @@ void LuaEntityCAO::processMessage(const std::string &data) bool do_interpolate = readU8(is); // pos m_position = readV3F1000(is); + // velocity + m_velocity = readV3F1000(is); + // acceleration + m_acceleration = readV3F1000(is); // yaw m_yaw = readF1000(is); // is_end_position (for interpolation) -- cgit v1.2.3