diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-10-09 13:12:13 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-11-10 15:39:20 +0300 |
commit | 3dbc123061aa063efd1fca358f5e295b0ce7b302 (patch) | |
tree | e3d93bedb477a0137201e683b3344c6729da1cc0 /source/gameengine | |
parent | 7bb16a5ccf14604b61cb2776147abb7fb6ad6d42 (diff) |
BGE: allow setting velocity to zero in a motion actuator.
The motion actuator goes out of its way to prevent setting zero velocities,
which should actually be supported. This patch just works around it as a
first test. We should investigate whether the flags
`m_bitLocalFlag.ZeroLinearVelocity` and `m_bitLocalFlag.ZeroAngularVelocity`
are actually needed/desired at all.
One of the issues that's already visible with this simple change, is
that objects aren't actually frozen but still move a little bit; see
test with {F241908}.
Reviewers: lordloki, hg1, moguri, panzergame
Reviewed By: lordloki, panzergame
Differential Revision: https://developer.blender.org/D1545
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_ObjectActuator.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 12abcb250a7..762148d8f76 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -276,8 +276,16 @@ bool KX_ObjectActuator::Update() { parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0); } - if (!m_bitLocalFlag.ZeroLinearVelocity) - { + + if (m_bitLocalFlag.ZeroLinearVelocity) { + if (!m_bitLocalFlag.AddOrSetLinV) { + /* No need to select local or world, as the velocity is zero anyway, + * and setLinearVelocity() converts local to world first. We do need to + * pass a true zero vector, as m_linear_velocity is only fuzzily zero. */ + parent->setLinearVelocity(MT_Vector3(0, 0, 0), false); + } + } + else { if (m_bitLocalFlag.AddOrSetLinV) { parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); } else { @@ -302,8 +310,13 @@ bool KX_ObjectActuator::Update() } } } - if (!m_bitLocalFlag.ZeroAngularVelocity) - { + if (m_bitLocalFlag.ZeroAngularVelocity) { + /* No need to select local or world, as the velocity is zero anyway, + * and setAngularVelocity() converts local to world first. We do need to + * pass a true zero vector, as m_angular_velocity is only fuzzily zero. */ + parent->setAngularVelocity(MT_Vector3(0, 0, 0), false); + } + else { m_active_combined_velocity = true; if (m_damping > 0) { MT_Vector3 angV; |