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

Allow flame_forge2d followBodyComponent to follow body's center of mass instead of position #1947

Closed
mattmyne opened this issue Sep 28, 2022 · 0 comments · Fixed by #1948
Closed

Comments

@mattmyne
Copy link
Contributor

What could be improved

The flame_forge2d camera allows following a BodyComponent with the followBodyComponet method. This method only allows following the body's position vector. It can be improved by optionally allowing the body's center of mass to be followed instead.

Why should this be improved

Rotations in forge2d occur about the body's center of mass, not always its visual center (the position vector). If the two differ then the whole scene appears to wobble as the body rotates, even if it is otherwise stationary.

Any risks?

The proposed addition is an optional named parameter useCenterOfMass for followBodyComponet that will default to false, so no breaking changes will be introduced. To follow center of mass instead, pass "useCenterOfMass: true". Internally this just directs Flame's followVector2 function to reference body.worldCenter rather than body.position, with no impact on performance.

More information

I have prepared a PR.

spydon pushed a commit that referenced this issue Sep 29, 2022
…ass (#1947) (#1948)

This PR adds the optional named parameter useCenterOfMass to followBodyComponent.
It defaults to false so no breaking changes.
Setting true allows camera following that does not "wobble" when an otherwise stationary BodyComponent (with an offset centre of mass) rotates.

Also removed reference to component anchor in documentation/comments since BodyComponent does not use an anchor.

Co-authored-by: Matt Bennett <m.bennett@uncrewed.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant