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: apply same delta from position to previous position when setParts runs #1

Merged
merged 1 commit into from
Dec 28, 2021

Conversation

tylerfurtwangler
Copy link
Owner

Problem

Currently when setParts is run, it sets the position and positionPrev to the new total parts centre values. This is fine when the body is stable/constant when being set, however for actively moving objects this will cause the new body to have no delta between positions.

This factors in when calculating the new velocity during update: https://github.com/tylerfurtwangler/matter-js/blob/master/src/body/Body.js#L638

Fix

This change uses the existing body positionPrev and position values to come up with a delta to apply to the body to keep the previous relative positions the same during a setParts call.

@tylerfurtwangler tylerfurtwangler merged commit 2a7fd84 into master Dec 28, 2021
@tylerfurtwangler tylerfurtwangler deleted the setPartsPositionFix branch December 28, 2021 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant