Corrected the problem with pendown() hanging the game (fixes #203)

master
Tomasz Kapuściński 2015-05-06 21:59:29 +02:00
parent 1db9d8bdca
commit 1c655aeda0
2 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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;
}