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

Added wakeup to 2D and 3D body impulse and force functions. #53113

Merged
merged 1 commit into from
Sep 28, 2021
Merged

Added wakeup to 2D and 3D body impulse and force functions. #53113

merged 1 commit into from
Sep 28, 2021

Conversation

danger-dan
Copy link
Contributor

@danger-dan danger-dan commented Sep 27, 2021

Wake sleeping bodies on apply force and impulse functions.

Bugsquad edit: 3.x version of #52967.

Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

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

Thanks for porting this fix to 3.x!

These calls should be in PhysicsDirectBodyStateSW class instead of BodySW

I know it's a bit confusing, but the direct body state is what users call directly, while BodySW API is used internally in the physics engine, so it would be overkill to activate the body in this API.

Here's where the direct body state calls for forces and impulses are in 2D for example:

virtual void add_central_force(const Vector2 &p_force) { body->add_central_force(p_force); }
virtual void add_force(const Vector2 &p_offset, const Vector2 &p_force) { body->add_force(p_offset, p_force); }
virtual void add_torque(real_t p_torque) { body->add_torque(p_torque); }
virtual void apply_central_impulse(const Vector2 &p_impulse) { body->apply_central_impulse(p_impulse); }
virtual void apply_impulse(const Vector2 &p_offset, const Vector2 &p_force) { body->apply_impulse(p_offset, p_force); }
virtual void apply_torque_impulse(real_t p_torque) { body->apply_torque_impulse(p_torque); }

@pouleyKetchoupp
Copy link
Contributor

As a note, I'm also removing the 3.3 cherry-pick. This change is generally safe for 3.x, but since it might introduce minor changes in behavior in specific cases, better go through a slower validation process so we can make sure there's no regression.

@danger-dan
Copy link
Contributor Author

Ahh my bad! lots to learn.

@danger-dan
Copy link
Contributor Author

Have amended to wakeup on exposed API functions instead.

@danger-dan
Copy link
Contributor Author

Also I realised I didn't use the wakeup() functions on the equivalent master branch PR. instead I directly used set_active(). Should I change that to also use wakeup()?

@pouleyKetchoupp
Copy link
Contributor

Also I realised I didn't use the wakeup() functions on the equivalent master branch PR. instead I directly used set_active(). Should I change that to also use wakeup()?

Oh, good point, I missed that on the master version. It looks like wakeup() is safer, would be great to change it.

Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

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

Looks great!

@akien-mga akien-mga merged commit 1dfddae into godotengine:3.x Sep 28, 2021
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants