Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: practice exercises on 2D/3D Physics - SAT algorithm  (Read 10332 times)

0 Members and 1 Guest are viewing this topic.

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
practice exercises on 2D/3D Physics - SAT algorithm
« on: March 16, 2020, 08:16:55 pm »
This is going to be a bit longer thread dedicated to SAT algorithm and its MTV and SH clipping[for impulse response].


here a simple demo to test the projection of the quad/box onto an arbitrary axis.

every single time i thought that i grasp the dot-product math-vector-entity i end up being was actually fooling myself. I have had to study this elusive entity in depth for once and for good. and here the introduction demo of incoming demos regarding the SAT algorithm.





« Last Edit: April 24, 2021, 05:30:33 am by Mortal »

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: practice exercises on 2D/3D Physics - SAT algorithm
« Reply #1 on: March 18, 2020, 08:12:17 am »
The second demo shows how the SAT algorithm works for testing the AABB detect collision of two quads.

From the previous demo, it is already known that each axis is a potential direction along which we can project the objects. So, all we need to do is find the axis with the smallest amount of overlap between the two objects.
the direction of the projection vector “ARROW” is the same as the axis direction which is the XY plane, and the length of the projection vector is equal to the size of the overlap along that axis.

SFML implemented it efficiently on sf::Rect::intersects, check it here:
https://github.com/SFML/SFML/blob/master/include/SFML/Graphics/Rect.inl#L109


Here the demo:



« Last Edit: April 24, 2021, 05:31:23 am by Mortal »

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: practice exercises on 3D Physics - SAT algorithm
« Reply #2 on: March 21, 2020, 01:15:36 pm »
Testing SAT algorithm on 3D environment.

The principle is the same as 2D except for some tweak to suit the 3D environment. The test was for collision detection and basic physics resopene. it looks working just fine but unfortunately, it is so SLOW,  it is not suitable for 3D games.


Here the demo:

« Last Edit: April 01, 2020, 01:46:14 pm by Mortal »

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: practice exercises on 3D Physics - SAT algorithm
« Reply #3 on: March 22, 2020, 10:21:50 am »
Desperate attempt to optimize the physics simulation.

I added Octree as Broad Phase Collision Detection while SAT is kept for what is called a Narrow Phase Collision Detection, it’s a common technique for optimization, it is used in both Box2D and Pullet3, but still that doesn't help to improve the performance. The frame rate dropped down below 10 FPS which is unacceptable for real time applications / games.

Here demo for latest update:

« Last Edit: April 01, 2020, 01:46:36 pm by Mortal »

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: practice exercises on 2D/3D Physics - SAT algorithm
« Reply #4 on: April 24, 2021, 05:22:34 am »
back to my early 2D/3D physics project on Separating Axis Theorem algorithm  (SAT) and its Minimum Translation Vector (MTV) and The Sutherland–Hodgman algorithm (SH clipping).

i've made some progress but still a bit unstable. here short video about what has been done so far


SAT Collision Detection with MTV




2D Physics Simulation [SAT-MTV-SH Clipping]
« Last Edit: April 24, 2021, 05:58:33 am by Mortal »

 

anything