From 5fed98d686fbacf0ccdf106b5892d2fbb53e7cc8 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 2 May 2021 20:26:09 -0400 Subject: Proper intersections of rects using SAT --- .../2d/_collisions/rectangle_line/dist/output.wasm | Bin 50694 -> 50712 bytes frontend/2d/_collisions/rectangle_line/main.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'frontend/2d/_collisions/rectangle_line') diff --git a/frontend/2d/_collisions/rectangle_line/dist/output.wasm b/frontend/2d/_collisions/rectangle_line/dist/output.wasm index dd44607..f23eebd 100755 Binary files a/frontend/2d/_collisions/rectangle_line/dist/output.wasm and b/frontend/2d/_collisions/rectangle_line/dist/output.wasm differ diff --git a/frontend/2d/_collisions/rectangle_line/main.cpp b/frontend/2d/_collisions/rectangle_line/main.cpp index 9ccbc7e..74e1ec2 100644 --- a/frontend/2d/_collisions/rectangle_line/main.cpp +++ b/frontend/2d/_collisions/rectangle_line/main.cpp @@ -246,7 +246,7 @@ void resolveCollision(Rigidbody* first, Rigidbody* second, IntersectionResult* i float32 linearDenomPart = collisionNormal.dot(collisionNormal * (1.f / first->mass + 1.f / second->mass)); float32 rotationalDenomPart = (firstPerpNorm * firstPerpNorm) / first->momentOfInertia + (sndPerpNorm * sndPerpNorm) / second->momentOfInertia; - float32 impulseMagnitude = numerator / (linearDenomPart);// + rotationalDenomPart); + float32 impulseMagnitude = numerator / (linearDenomPart + rotationalDenomPart); first->velocity = first->velocity + (collisionNormal * (impulseMagnitude / first->mass)); second->velocity = second->velocity - (collisionNormal * (impulseMagnitude / second->mass)); first->rotationalVelocity = first->rotationalVelocity + firstPerp.dot(collisionNormal * impulseMagnitude) / first->momentOfInertia; -- cgit v1.2.1