Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized SAT.collides method by precomputing vertex projections #556

Open
wants to merge 52 commits into
base: master
Choose a base branch
from

Conversation

bchevalier
Copy link
Contributor

@bchevalier bchevalier commented Jan 6, 2018

Changes

  • Added a Projection Component.
  • Added a projections property onto bodies that contains the projections of all the body's vertices onto its own axes.
  • Modified Sat._overlapAxes method in order to benefit from the precomputed projections.

Includes #555

Result

  • More lines of codes due to additional Projections component.
  • Roughly 40% performance gain on the SAT.collides method.
  • From 50% to 200% performance loss on the Body.update method.
    N.B the speed-up of the SAT.collides method far outweighs the performance loss of the Body.update method.

Circle Stack: engine performance gain 29.3% (=1.4x)

Before
screen shot 2018-01-06 at 7 39 45 pm

After
screen shot 2018-01-06 at 7 40 05 pm

Mixed Shapes: engine performance gain 24.3% (=1.3x)

Before
screen shot 2018-01-06 at 7 42 37 pm

After
screen shot 2018-01-06 at 7 44 11 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants