X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=blobdiff_plain;f=src%2FcollisionManager.cpp;h=72dcd6bd9fe9895c4e4a9cc4522a9e85133e08f5;hb=e86c86b38b25bcb463943dc166b60f236aa4af10;hp=8aa2dc78ba2c3380cc4bf03ea41f84a9c16c0762;hpb=aa2791cf43a9ddd3a288e504db08e11d03439653;p=physics.git diff --git a/src/collisionManager.cpp b/src/collisionManager.cpp index 8aa2dc7..72dcd6b 100644 --- a/src/collisionManager.cpp +++ b/src/collisionManager.cpp @@ -228,8 +228,8 @@ void applyCollision(Ball* b1, Ball* b2) return; // a few values to simplify the equations - const Vector2& normal = cInfo.normal; - const Vector2& point = cInfo.point; + const Vector2& normal = cInfo.m_vecNormal; + const Vector2& point = cInfo.m_vecPoint; float m1 = b1->mass; float m2 = b2->mass; @@ -259,7 +259,7 @@ void applyCollision(Polygon* pPoly, Ball* pBall) return; float fCoR = pBall->CoR; - Vector2 vecNorm = cInfo.normal; + Vector2 vecNorm = cInfo.m_vecNormal; Vector2 vecVelo = pBall->velocityRaw(); @@ -273,8 +273,8 @@ void applyCollision(Polygon* pPoly, Ball* pBall) // CoR penetration fix, adds the jitters // from center to point - //Vector2 CollP = normal / normal.Length * Ball.Radius; - //Ball.Position = Info.Point + CollP; + Vector2 vecCollP = vecNorm / vecNorm.length() * pBall->radius; + pBall->applyNudge(cInfo.m_vecPoint + vecCollP - pBall->positionRaw()); } bool getInfo(const Ball* b1, const Ball* b2, CollisionInfo* pcInfo) @@ -305,8 +305,8 @@ bool getInfo(const Ball* b1, const Ball* b2, CollisionInfo* pcInfo) if ((v1 - v2).dot(p1 - p2) >= 0) return false; - pcInfo->point = p1 - (p1 - p2) * r1 / (r1 + r2); - pcInfo->normal = p1 - p2; + pcInfo->m_vecPoint = p1 - (p1 - p2) * r1 / (r1 + r2); + pcInfo->m_vecNormal = p1 - p2; return true; } @@ -356,8 +356,8 @@ bool getInfo(const Polygon* pPoly, const Ball* pBall, CollisionInfo* pcInfo) return false; - pcInfo->point = vecTotVec / iTot + vecPos; - pcInfo->normal = vecPos - pcInfo->point; + pcInfo->m_vecPoint = vecTotVec / iTot + vecPos; + pcInfo->m_vecNormal = vecPos - pcInfo->m_vecPoint; return true; }