diff options
author | sfan5 <sfan5@live.de> | 2020-04-14 14:11:33 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2020-04-27 20:45:46 +0200 |
commit | 3475759d1adbd4a64c6250fd87981f783e64f69c (patch) | |
tree | 50e1a4402a2ecc83b6f11a76ff27c7b5b3ac59ad /src/server | |
parent | aef59f2ad9a5a5a217ddadc05c46fd4d23cef47f (diff) | |
download | minetest-3475759d1adbd4a64c6250fd87981f783e64f69c.tar.gz minetest-3475759d1adbd4a64c6250fd87981f783e64f69c.tar.bz2 minetest-3475759d1adbd4a64c6250fd87981f783e64f69c.zip |
Expose collision information to LuaEntity on_step
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/luaentity_sao.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/server/luaentity_sao.cpp b/src/server/luaentity_sao.cpp index 125939241..51e1ca90e 100644 --- a/src/server/luaentity_sao.cpp +++ b/src/server/luaentity_sao.cpp @@ -135,6 +135,8 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) m_last_sent_position_timer += dtime; + collisionMoveResult moveresult, *moveresult_p = nullptr; + // Each frame, parent position is copied if the object is attached, otherwise it's calculated normally // If the object gets detached this comes into effect automatically from the last known origin if(isAttached()) @@ -150,7 +152,6 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) aabb3f box = m_prop.collisionbox; box.MinEdge *= BS; box.MaxEdge *= BS; - collisionMoveResult moveresult; f32 pos_max_d = BS*0.25; // Distance per iteration v3f p_pos = m_base_position; v3f p_velocity = m_velocity; @@ -159,6 +160,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) pos_max_d, box, m_prop.stepheight, dtime, &p_pos, &p_velocity, p_acceleration, this, m_prop.collideWithObjects); + moveresult_p = &moveresult; // Apply results m_base_position = p_pos; @@ -188,8 +190,8 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) } } - if(m_registered){ - m_env->getScriptIface()->luaentity_Step(m_id, dtime); + if(m_registered) { + m_env->getScriptIface()->luaentity_Step(m_id, dtime, moveresult_p); } if (!send_recommended) |