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

docs: Point users to NarrowPhaseConfig::prediction_distance #232

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johanhelsing
Copy link
Contributor

Objective

I tripped up on collisions, because I considered the units as meters, but the default value for prediction distance is 1 (presumably pixels)

Solution

Most of the documentation links to the ContactReportingPlugin when talking about contacts.

So link from there to NarrowPhaseConfig::prediction_distance, so they can follow the trail.

So that they might understand why the get unexpected contacts in 2d
(where it defaults to 1 instead of 0.01, which it defaults to on 3d)
@Jondolf Jondolf added the documentation Improvements or additions to documentation label Nov 10, 2023
@Jondolf
Copy link
Owner

Jondolf commented Nov 10, 2023

The recommended units are currently pixels in 2D and meters in 3D, which applies to the prediction distance as well. Once we add physics scale like pixels_per_meter, 2D can perhaps be handled more conveniently.

I'm a bit unsure if we want to have the part about bodies being considered colliding with the penetration distance in the docs though, because I consider the behavior to be somewhat incorrect. The prediction distance is used just to avoid missing collisions; the narrow phase collects all contacts before the solver starts, and the constraints can later move bodies around into penetrating states, which would only be detected during the next frame without the extra margin. It only causes a collision response if the bodies are actually penetrating though, so people would expect it to skip sending collision events for non-penetrating collisions.

I made an issue about this (#224) and will try to fix it for 0.4

@johanhelsing
Copy link
Contributor Author

johanhelsing commented Nov 10, 2023

Alright, just wanted make sure it's possible to figure out how to use the engine correctly...

Are you sure it's not simpler to just use meters everywhere?

  • get rids of the weirdness surrounding the value of default gravity
  • the actual values of mass, velocities, forces etc. will be in a more natural range that's easier for humans to reason about.
  • Not all games are pixel-based either. 3D games with 2d physics are not uncommon either.
  • Matches the conventions in other 2d physics engines (rapier, Unity/box2d)
  • 2D and 3D have less differences/special cases

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

Successfully merging this pull request may close these issues.

None yet

2 participants