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

feat(physics): Support Dynamic bodies #927

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

MaxCWhitehead
Copy link
Collaborator

@MaxCWhitehead MaxCWhitehead commented Mar 21, 2024

This is the base of core changes to support ragdolls, allows us to simulate dynamic bodies in rapier.

DynamicBody component may be added to an entity that has KinematicBody, and if enabled, body will simulate physics. Transitioning between kinematic / dynamic and adjusting rapier data + collider is handled on next physics update.

This change should have no impact on existing kinematics, scene queries, etc. Usage of these changes will come in other PR soon.

Switched to fork of rapier (temporarily hopefully):
I switched us to a fork of rapier to fix a bug in which changing a rapier rigidbody from kinematic to dynamic will not put it in active dynamic set, so gravity is not applied. It seems they rely on contact graph to add body to this set, but if not in contact with anything it breaks. I have a PR open for a fix in rapier.

  • I also updated version, slight change in debug draw code is because of changes there.

Some notes on changes:

  • Some helper functions are included for pushing simulation commands for dynamic body that apply changes to rapier body before next physics step.
  • There is a mutate_rigidbody function on CollisionWorld that makes accessing rapier body for immediate mutation slightly more convenient.
  • Previously bodies were created as dynamic (but we used them as kinematic anyway), now they are actually flagged as kinematic in rapier. This does not impact collision events at all.

There's a decent chunk of physics stuff in collision module now, at some point maybe should detangle this, but probably fine for now. I renamed some functions to make things more clear.

dynamic not having gravity applied (not going into active dynamic set).

Update physics debug rendering code as rapier::DebugRenderObject changed
in updated version.
Copy link
Member

@zicklag zicklag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I like how small this diff is. 🚀

@zicklag zicklag added this pull request to the merge queue Mar 21, 2024
Merged via the queue into fishfolk:main with commit 3e15075 Mar 21, 2024
8 of 9 checks passed
@MaxCWhitehead
Copy link
Collaborator Author

Nice. I like how small this diff is. 🚀

There's more haha but going in logical chunks at least so it's not a massive change soup :)

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.

2 participants