[colobot] 344/390: Corrected the problem with pendown() hanging the game (fixes #203)

Didier Raboud odyx at moszumanska.debian.org
Fri Jun 12 14:22:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch upstream/latest
in repository colobot.

commit 1c655aeda0aeb89e9d6c39938e9e8b5a1a6a35b1
Author: Tomasz Kapuściński <tomaszkax86 at gmail.com>
Date:   Wed May 6 21:59:29 2015 +0200

    Corrected the problem with pendown() hanging the game (fixes #203)
---
 src/math/geometry.h     | 6 +++++-
 src/physics/physics.cpp | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/math/geometry.h b/src/math/geometry.h
index 595046e..5755777 100644
--- a/src/math/geometry.h
+++ b/src/math/geometry.h
@@ -517,7 +517,11 @@ inline Math::Vector NormalToPlane(const Math::Vector &p1, const Math::Vector &p2
  */
 inline Math::Vector SegmentPoint(const Math::Vector &p1, const Math::Vector &p2, float dist)
 {
-    return p1 + (p2 - p1) * dist;
+    Math::Vector direction = p2 - p1;
+    
+    direction.Normalize();
+
+    return p1 + direction * dist;
 }
 
 //! Returns the distance between given point and a plane
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index 5a6be89..26a8779 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -3818,9 +3818,12 @@ void CPhysics::WheelParticle(int color, float width)
         {
             dist1 = Math::Distance(m_wheelParticlePos[0], goal1);
             if ( dist1 < step )  break;
+
             dist2 = Math::Distance(m_wheelParticlePos[1], goal2);
+
             wheel1 = Math::SegmentPoint(m_wheelParticlePos[0], goal1, step);
-            wheel2 = Math::SegmentPoint(m_wheelParticlePos[1], goal2, step*dist2/dist1);
+            wheel2 = Math::SegmentPoint(m_wheelParticlePos[1], goal2, step * dist2 / dist1);
+
             if ( m_linMotion.realSpeed.x >= 0.0f )
             {
                 m_particle->CreateWheelTrace(m_wheelParticlePos[0], m_wheelParticlePos[1], wheel1, wheel2, parti);
@@ -3829,6 +3832,7 @@ void CPhysics::WheelParticle(int color, float width)
             {
                 m_particle->CreateWheelTrace(m_wheelParticlePos[1], m_wheelParticlePos[0], wheel2, wheel1, parti);
             }
+
             m_wheelParticlePos[0] = wheel1;
             m_wheelParticlePos[1] = wheel2;
         }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list