From e431c58c0e5bde1689ef0be0d02588ee22c99c82 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Wed, 19 May 2021 20:22:03 -0400 Subject: Ignoring general SAT rotations for now, going to focus on redoing the original demos --- 2d/_collisions/polygon_polygon/dist/output.wasm | Bin 56810 -> 56473 bytes 2d/_collisions/polygon_polygon/main.cpp | 11 +- .../rectangle_rectangle/dist/output.wasm | Bin 55607 -> 55719 bytes 2d/_collisions/rectangle_rectangle/main.cpp | 8 +- roadmap.html | 264 ++++++++++++--------- roadmap.html.content | 108 +++++++++ upload.sh | 2 +- 7 files changed, 275 insertions(+), 118 deletions(-) create mode 100644 roadmap.html.content diff --git a/2d/_collisions/polygon_polygon/dist/output.wasm b/2d/_collisions/polygon_polygon/dist/output.wasm index e355676..d008042 100755 Binary files a/2d/_collisions/polygon_polygon/dist/output.wasm and b/2d/_collisions/polygon_polygon/dist/output.wasm differ diff --git a/2d/_collisions/polygon_polygon/main.cpp b/2d/_collisions/polygon_polygon/main.cpp index 916a057..b928f02 100644 --- a/2d/_collisions/polygon_polygon/main.cpp +++ b/2d/_collisions/polygon_polygon/main.cpp @@ -331,12 +331,13 @@ 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); + // @TODO: Most of my 2D rotational work is pretty broken. Let's ignore it for the time being; + 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; - second->rotationalVelocity = second->rotationalVelocity - secondPerp.dot(collisionNormal * impulseMagnitude) / second->momentOfInertia; + // first->rotationalVelocity = first->rotationalVelocity + firstPerp.dot(collisionNormal * impulseMagnitude) / first->momentOfInertia; + // second->rotationalVelocity = second->rotationalVelocity - secondPerp.dot(collisionNormal * impulseMagnitude) / second->momentOfInertia; } void update(float32 deltaTimeSeconds, void* userData) { @@ -393,15 +394,19 @@ void update(float32 deltaTimeSeconds, void* userData) { for (int p = 0; p < 4; p++) { ConvexPolygon* polygon = &polygons[p]; if (polygon->body.position.x <= 0.f) { + polygon->body.position.x = 0.f; polygon->body.velocity = polygon->body.velocity - Vector2 { 1.f, 0.f } * (2 * (polygon->body.velocity.dot(Vector2 { 1.f, 0.f }))); } if (polygon->body.position.y <= 0.f) { + polygon->body.position.y = 0.f; polygon->body.velocity = polygon->body.velocity - Vector2 { 0.f, 1.f } * (2 * (polygon->body.velocity.dot(Vector2 { 0.f, 1.f }))); } if (polygon->body.position.x >= 640.f) { + polygon->body.position.x = 640.f; polygon->body.velocity = polygon->body.velocity - Vector2 { -1.f, 0.f } * (2 * (polygon->body.velocity.dot(Vector2{ -1.f, 0.f }))); } if (polygon->body.position.y >= 480.f) { + polygon->body.position.y = 480.f; polygon->body.velocity = polygon->body.velocity - Vector2 { 0.f, -1.f } * (2 * (polygon->body.velocity.dot(Vector2 { 0.f, -1.f }))) ; } } diff --git a/2d/_collisions/rectangle_rectangle/dist/output.wasm b/2d/_collisions/rectangle_rectangle/dist/output.wasm index 5a17a67..f61e371 100755 Binary files a/2d/_collisions/rectangle_rectangle/dist/output.wasm and b/2d/_collisions/rectangle_rectangle/dist/output.wasm differ diff --git a/2d/_collisions/rectangle_rectangle/main.cpp b/2d/_collisions/rectangle_rectangle/main.cpp index 99dafe5..689ea11 100644 --- a/2d/_collisions/rectangle_rectangle/main.cpp +++ b/2d/_collisions/rectangle_rectangle/main.cpp @@ -398,19 +398,25 @@ void update(float32 deltaTimeSeconds, void* userData) { } } - // Check collisions with walls + // Check collisions with walls. + // @NOTE: Setting the position backwards by a small amount _could_ move it into another object, but we are ignoring that circumstance + // for now, as it is very unlikely. for (int r = 0; r < 4; r++) { Rectangle* rect = &rectangleList[r]; if (rect->body.position.x <= 0.f) { + rect->body.position.x = 0.f; rect->body.velocity = rect->body.velocity - Vector2 { 1.f, 0.f } * (2 * (rect->body.velocity.dot(Vector2 { 1.f, 0.f }))); } if (rect->body.position.y <= 0.f) { + rect->body.position.y = 0.f; rect->body.velocity = rect->body.velocity - Vector2 { 0.f, 1.f } * (2 * (rect->body.velocity.dot(Vector2 { 0.f, 1.f }))); } if (rect->body.position.x >= 640.f) { + rect->body.position.x = 640.f; rect->body.velocity = rect->body.velocity - Vector2 { -1.f, 0.f } * (2 * (rect->body.velocity.dot(Vector2{ -1.f, 0.f }))); } if (rect->body.position.y >= 480.f) { + rect->body.position.y = 480.f; rect->body.velocity = rect->body.velocity - Vector2 { 0.f, -1.f } * (2 * (rect->body.velocity.dot(Vector2 { 0.f, -1.f }))) ; } } diff --git a/roadmap.html b/roadmap.html index 912e8c6..9e5e82e 100644 --- a/roadmap.html +++ b/roadmap.html @@ -1,124 +1,162 @@ - - - - - - Roadmap - - - -
-

Physics for Games

-
-
- -
-

May/June 2021: More Collisions

-
    -
  • SAT Collisions for Convex Polygons with Explanation
  • -
  • Pill Collisions
  • -
  • Remove (or hide) ellipse collision pages for now
  • -
  • 3D scene setup
  • -
  • 3D scene basic physics with spheres bouncing around a scene
  • -
-

- Obviously, the month of April did not go as planned. I got caught up with a number of tasks that I couldn't handle, - namely, the pill collisions. These, as I discovered, were quite unfeasible and involved a lot of complex maths - that I didn't quite yet understand. They are also unreasonable for game development's sake, so I will ditch that - effort and focus on doing other things. This, of course, is not time entirely wasted, as I now I have a somewhat - better understanding of why ellipses (and by extension ellipsoids, although I am not entirely sure of this). I should - instead try to figure out the intersection using pills, not ellipses. Pills are simply 2D shapes made of a - rectangle in the middle and two half-circles at either ends. This is a far less expensive collision to calculate. -
- I also failed when it came to getting a good physics collision system going. This stemmed from a general misunderstanding - of moment of inertia and how it can properly be implemented for each shape. I think I am getting a better grip on it now, - however. -
- And that brings me to May/June. I am combining these two months because I am quite busy in May with family stuff, - and hence won't be able to give my full attention to the project. That being said, as a high-level goal, I hope to - get some more 2D collisions going, and maybe move onto 3D fairly soon. For 3D, I would simply like to get the physics - simulation up and running with simple objects (spheres, cubes, etc.). From there, I want to begin exploring more complex - physics simulation topics like oct-trees, multiple collision resolution, etc. We will see what happens, but I am optimistic, - so long as I stay the course. -

-
-
-

April 2021: Ground Work and Initial Collisions

-
    -
  • Orthographic rendering basics
  • -
  • Uniform build Process for WebAssembly
  • -
  • WASM Framework with simulation loop
  • -
-
-

2D Collisions with Descriptions

-
    -
  • Ellipse-Line Collision
  • -
  • Ellipse-Ellipse Collisions
  • -
  • Ellipse-Circle Collisions
  • -
  • Ellipse-Square Collisions
  • -
  • Rectangle-Line Collisions
  • -
  • Circle-Line Collisions (Redo)
  • -
  • Rectangle-Circle Collision
  • -
-
-

Brief Wasm Series

-
    -
  • Getting started with WASM docs
  • -
  • Wasm examples
  • -
-

- Everything above has a due date of April 30th, 2021. None of it is that hard, so this should be a very doable timeline. -

-
-
+ section ul li.halfway:before { + content: '⚠' + } + + section ul li.failed:before { + content: '✗' + } + +
+
+

May/June 2021: More Collisions

+
    +
  • SAT Collisions for Convex Polygons with Explanation
  • +
  • Pill Collisions
  • +
  • Remove (or hide) ellipse collision pages for now
  • +
  • 3D scene setup
  • +
  • 3D scene basic physics with spheres bouncing around a scene
  • +
+

+ Obviously, the month of April did not go as planned. I got caught up with a number of tasks that I couldn't handle, + namely, the pill collisions. These, as I discovered, were quite unfeasible and involved a lot of complex maths + that I didn't quite yet understand. They are also unreasonable for game development's sake, so I will ditch that + effort and focus on doing other things. This, of course, is not time entirely wasted, as I now I have a somewhat + better understanding of why ellipses (and by extension ellipsoids, although I am not entirely sure of this). I should + instead try to figure out the intersection using pills, not ellipses. Pills are simply 2D shapes made of a + rectangle in the middle and two half-circles at either ends. This is a far less expensive collision to calculate. +

+ I also failed when it came to getting a good physics collision system going. This stemmed from a general misunderstanding + of moment of inertia and how it can properly be implemented for each shape. I think I am getting a better grip on it now, + however. +

+ And that brings me to May/June. I am combining these two months because I am quite busy in May with family stuff, + and hence won't be able to give my full attention to the project. That being said, as a high-level goal, I hope to + get some more 2D collisions going, and maybe move onto 3D fairly soon. For 3D, I would simply like to get the physics + simulation up and running with simple objects (spheres, cubes, etc.). From there, I want to begin exploring more complex + physics simulation topics like oct-trees, multiple collision resolution, etc. We will see what happens, but I am optimistic, + so long as I stay the course. +

+
+
+
+

April 2021: Ground Work and Initial Collisions

+
    +
  • Orthographic rendering basics
  • +
  • Uniform build Process for WebAssembly
  • +
  • WASM Framework with simulation loop
  • +
+

2D Collisions with Descriptions

+
    +
  • Ellipse-Line Collision
  • +
  • Ellipse-Ellipse Collisions
  • +
  • Ellipse-Circle Collisions
  • +
  • Ellipse-Square Collisions
  • +
  • Rectangle-Line Collisions
  • +
  • Circle-Line Collisions (Redo)
  • +
  • Rectangle-Circle Collision
  • +
+

Brief Wasm Series

+
    +
  • Getting started with WASM docs
  • +
  • Wasm examples
  • +
+

+ Everything above has a due date of April 30th, 2021. None of it is that hard, so this should be a very doable timeline. +

+
+
+ diff --git a/roadmap.html.content b/roadmap.html.content new file mode 100644 index 0000000..5509dc8 --- /dev/null +++ b/roadmap.html.content @@ -0,0 +1,108 @@ + + +
+
+

May/June 2021: More Collisions

+
    +
  • SAT Collisions for Convex Polygons with Explanation
  • +
  • Pill Collisions
  • +
  • Remove (or hide) ellipse collision pages for now
  • +
  • 3D scene setup
  • +
  • 3D scene basic physics with spheres bouncing around a scene
  • +
+

+ Obviously, the month of April did not go as planned. I got caught up with a number of tasks that I couldn't handle, + namely, the pill collisions. These, as I discovered, were quite unfeasible and involved a lot of complex maths + that I didn't quite yet understand. They are also unreasonable for game development's sake, so I will ditch that + effort and focus on doing other things. This, of course, is not time entirely wasted, as I now I have a somewhat + better understanding of why ellipses (and by extension ellipsoids, although I am not entirely sure of this). I should + instead try to figure out the intersection using pills, not ellipses. Pills are simply 2D shapes made of a + rectangle in the middle and two half-circles at either ends. This is a far less expensive collision to calculate. +

+ I also failed when it came to getting a good physics collision system going. This stemmed from a general misunderstanding + of moment of inertia and how it can properly be implemented for each shape. I think I am getting a better grip on it now, + however. +

+ And that brings me to May/June. I am combining these two months because I am quite busy in May with family stuff, + and hence won't be able to give my full attention to the project. That being said, as a high-level goal, I hope to + get some more 2D collisions going, and maybe move onto 3D fairly soon. For 3D, I would simply like to get the physics + simulation up and running with simple objects (spheres, cubes, etc.). From there, I want to begin exploring more complex + physics simulation topics like oct-trees, multiple collision resolution, etc. We will see what happens, but I am optimistic, + so long as I stay the course. +

+
+
+
+

April 2021: Ground Work and Initial Collisions

+
    +
  • Orthographic rendering basics
  • +
  • Uniform build Process for WebAssembly
  • +
  • WASM Framework with simulation loop
  • +
+

2D Collisions with Descriptions

+
    +
  • Ellipse-Line Collision
  • +
  • Ellipse-Ellipse Collisions
  • +
  • Ellipse-Circle Collisions
  • +
  • Ellipse-Square Collisions
  • +
  • Rectangle-Line Collisions
  • +
  • Circle-Line Collisions (Redo)
  • +
  • Rectangle-Circle Collision
  • +
+

Brief Wasm Series

+
    +
  • Getting started with WASM docs
  • +
  • Wasm examples
  • +
+

+ Everything above has a due date of April 30th, 2021. None of it is that hard, so this should be a very doable timeline. +

+
+
diff --git a/upload.sh b/upload.sh index ae5767f..0960cbc 100755 --- a/upload.sh +++ b/upload.sh @@ -1 +1 @@ -rsync -a frontend/ root@physicsforgames.com:/var/www/physicsforgames +rsync -a ./ root@physicsforgames.com:/var/www/physicsforgames -- cgit v1.2.1