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

Fix: Friction disappears when manually applying gravity #224 #156

Merged
merged 6 commits into from
Aug 12, 2022

Conversation

chnicoloso
Copy link

@chnicoloso
Copy link
Author

cc @marcofugaro @codynova (you surface as recent contributors, hoping I can get a review from one of you, thank you!)

@isaac-mason
Copy link
Member

isaac-mason commented Aug 5, 2022

Thanks for this! 🙂

One comment from me:

In this PR, Narrowphase has been changed to always use world.frictionGravity.

If world.gravity is changed after construction, world.frictionGravity will remain the same. As-is, users would need to update both, which is a backwards incompatible change, and maybe also slightly surprising behavior.

Maybe we could add properties like the world.useWorldGravityAsFrictionGravity and world.useFrictionGravityOnZeroGravity flags in p2 to address this?

Let me know what you think!

@chnicoloso
Copy link
Author

@isaac-mason thanks for having a look!

Ah yes, thank you! Great catch. The flags are a good idea, though I would prefer an approach that kept the config matrix as small and simple as possible. How about this:

  • By default, world.frictionGravity is undefined.
  • Narrowphase applies friction using world.frictionGravity || world.gravity.

This way, current behavior is maintained and backwards compatibility is ensured while still allowing users to override friction gravity, if they need to. When the average user changed world.gravity, friction would change with it, no surprises - only users who have explicitly set world.frictionGravity would be expected to manually manage that relationship between world.gravity and world.frictionGravity.

What do you think?

@chnicoloso
Copy link
Author

I updated with the suggestion above. Also, I noticed that dist/ is not in the project's .gitignore. Am I supposed to be building and committing the built package or is there a build/deploy pipeline that takes care of that?

@isaac-mason
Copy link
Member

@chnicoloso that sounds reasonable to me! I'll give this another read-through shortly 🙂

@isaac-mason
Copy link
Member

isaac-mason commented Aug 8, 2022

I believe right now builds are committed to dist on doing a release. There's no pipeline that handles that afaik. Would want someone else to confirm that though!

@isaac-mason
Copy link
Member

isaac-mason commented Aug 8, 2022

Implementation LGTM! readme.md just needs updating to reflect world.frictionGravity defaulting to undefined.

@isaac-mason
Copy link
Member

Could anyone else also give this a review? @marcofugaro / @codynova

@chnicoloso
Copy link
Author

Thanks @isaac-mason! I updated the readme - will hold on building and committing dist until we get confirmation that this is indeed what we want.

@drcmda
Copy link
Member

drcmda commented Aug 11, 2022

i can merge and publish if you guys want? i don't understand the code but from looking at the images it behaves correct.

@chnicoloso
Copy link
Author

chnicoloso commented Aug 12, 2022

Thanks @drcmda! That would be great - so you don't need me to build and commit dist?

Copy link
Member

@marcofugaro marcofugaro left a comment

Choose a reason for hiding this comment

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

Makes sense, thanks!

@marcofugaro
Copy link
Member

marcofugaro commented Aug 12, 2022

Yeah, an example would be useful, but maybe in a future PR if someone wants

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.

4 participants