diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-07 02:48:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-07 02:48:28 +0400 |
commit | 3a0593cc3d5de33248b3a7b913a45729c37dc1b4 (patch) | |
tree | 88fcddc5e3c060c87a6313d853315f0efa484a52 /source/gameengine/Ketsji/KX_ObstacleSimulation.cpp | |
parent | 2336aadb80f8602f001b2c5b0bcaacf3ad858f83 (diff) |
code cleanup: dont use function calls like dot_v3v3, pow and sqrt within macros which results in calling the function multiple times needlessly.
also added some comments.
Diffstat (limited to 'source/gameengine/Ketsji/KX_ObstacleSimulation.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_ObstacleSimulation.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index fd47587e2c8..a942f87856c 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -378,13 +378,14 @@ static MT_Point3 nearestPointToObstacle(MT_Point3& pos ,KX_Obstacle* obstacle) MT_Vector3 ab = obstacle->m_pos2 - obstacle->m_pos; if (!ab.fuzzyZero()) { + const MT_Scalar dist = ab.length(); MT_Vector3 abdir = ab.normalized(); MT_Vector3 v = pos - obstacle->m_pos; MT_Scalar proj = abdir.dot(v); - CLAMP(proj, 0, ab.length()); + CLAMP(proj, 0, dist); MT_Point3 res = obstacle->m_pos + abdir*proj; return res; - } + } } case KX_OBSTACLE_CIRCLE : default: |