mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Updated Box2D to 2.3.2-git.
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
|
||||
#define B2_DEBUG_SOLVER 0
|
||||
|
||||
bool g_blockSolve = true;
|
||||
|
||||
struct b2ContactPositionConstraint
|
||||
{
|
||||
b2Vec2 localPoints[b2_maxManifoldPoints];
|
||||
@@ -213,7 +215,7 @@ void b2ContactSolver::InitializeVelocityConstraints()
|
||||
}
|
||||
|
||||
// If we have two points, then prepare the block solver.
|
||||
if (vc->pointCount == 2)
|
||||
if (vc->pointCount == 2 && g_blockSolve)
|
||||
{
|
||||
b2VelocityConstraintPoint* vcp1 = vc->points + 0;
|
||||
b2VelocityConstraintPoint* vcp2 = vc->points + 1;
|
||||
@@ -341,29 +343,32 @@ void b2ContactSolver::SolveVelocityConstraints()
|
||||
}
|
||||
|
||||
// Solve normal constraints
|
||||
if (vc->pointCount == 1)
|
||||
if (pointCount == 1 || g_blockSolve == false)
|
||||
{
|
||||
b2VelocityConstraintPoint* vcp = vc->points + 0;
|
||||
for (int32 i = 0; i < pointCount; ++i)
|
||||
{
|
||||
b2VelocityConstraintPoint* vcp = vc->points + i;
|
||||
|
||||
// Relative velocity at contact
|
||||
b2Vec2 dv = vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA);
|
||||
// Relative velocity at contact
|
||||
b2Vec2 dv = vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA);
|
||||
|
||||
// Compute normal impulse
|
||||
float32 vn = b2Dot(dv, normal);
|
||||
float32 lambda = -vcp->normalMass * (vn - vcp->velocityBias);
|
||||
// Compute normal impulse
|
||||
float32 vn = b2Dot(dv, normal);
|
||||
float32 lambda = -vcp->normalMass * (vn - vcp->velocityBias);
|
||||
|
||||
// b2Clamp the accumulated impulse
|
||||
float32 newImpulse = b2Max(vcp->normalImpulse + lambda, 0.0f);
|
||||
lambda = newImpulse - vcp->normalImpulse;
|
||||
vcp->normalImpulse = newImpulse;
|
||||
// b2Clamp the accumulated impulse
|
||||
float32 newImpulse = b2Max(vcp->normalImpulse + lambda, 0.0f);
|
||||
lambda = newImpulse - vcp->normalImpulse;
|
||||
vcp->normalImpulse = newImpulse;
|
||||
|
||||
// Apply contact impulse
|
||||
b2Vec2 P = lambda * normal;
|
||||
vA -= mA * P;
|
||||
wA -= iA * b2Cross(vcp->rA, P);
|
||||
// Apply contact impulse
|
||||
b2Vec2 P = lambda * normal;
|
||||
vA -= mA * P;
|
||||
wA -= iA * b2Cross(vcp->rA, P);
|
||||
|
||||
vB += mB * P;
|
||||
wB += iB * b2Cross(vcp->rB, P);
|
||||
vB += mB * P;
|
||||
wB += iB * b2Cross(vcp->rB, P);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user