diff options
author | Matthew Kosarek <mattkae@protonmail.com> | 2021-05-02 20:26:09 -0400 |
---|---|---|
committer | Matthew Kosarek <mattkae@protonmail.com> | 2021-05-02 20:26:09 -0400 |
commit | 5fed98d686fbacf0ccdf106b5892d2fbb53e7cc8 (patch) | |
tree | 58916a6f24c77bb1048088575c04b08812587cbe /frontend/2d/_collisions/rectangle_line | |
parent | 91c646c1022e4fb60a6c55cbb1cfbc5d488a5691 (diff) |
Proper intersections of rects using SAT
Diffstat (limited to 'frontend/2d/_collisions/rectangle_line')
-rwxr-xr-x | frontend/2d/_collisions/rectangle_line/dist/output.wasm | bin | 50694 -> 50712 bytes | |||
-rw-r--r-- | frontend/2d/_collisions/rectangle_line/main.cpp | 2 |
2 files changed, 1 insertions, 1 deletions
diff --git a/frontend/2d/_collisions/rectangle_line/dist/output.wasm b/frontend/2d/_collisions/rectangle_line/dist/output.wasm Binary files differindex dd44607..f23eebd 100755 --- a/frontend/2d/_collisions/rectangle_line/dist/output.wasm +++ b/frontend/2d/_collisions/rectangle_line/dist/output.wasm 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; |