diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2013-02-22 06:31:46 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2013-02-22 06:31:46 +0400 |
commit | 6bac47f8544a6bdc66d439d1d61b4a850d4ad20a (patch) | |
tree | 8204884d00b960cd437a400877c001011653f2c0 /source | |
parent | e663f249780389da25d0250907af332dd991daea (diff) |
BGE: Fix for bug #34349 "Character walkDirection ADD mode -#INF error" reported by Angus Hollands (agoose77). If the walk directions canceled each other out, the actuator would try to normalize a zero vector, which caused the error.
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/Ketsji/KX_ObjectActuator.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 9355ad0adfd..b4ee339568c 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -221,10 +221,14 @@ bool KX_ObjectActuator::Update() if (m_bitLocalFlag.AddOrSetCharLoc) { MT_Vector3 old_dir = parent->GetPhysicsController()->GetWalkDirection(); - MT_Scalar mag = old_dir.length(); - if (mag < MT_EPSILON) - mag = dir.length(); - dir = (dir + old_dir).normalized() * mag; + + if (!old_dir.fuzzyZero()) { + MT_Scalar mag = old_dir.length(); + + dir = dir + old_dir; + if (!dir.fuzzyZero()) + dir = dir.normalized() * mag; + } } // We always want to set the walk direction since a walk direction of (0, 0, 0) should stop the character |