From 983d5ac64580991ca9be9859e125d7c8e12b6cab Mon Sep 17 00:00:00 2001 From: Tyler Furtwangler Date: Tue, 28 Dec 2021 10:51:40 -0800 Subject: [PATCH] fix: apply same delta from position to previous position when setParts runs --- src/body/Body.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/body/Body.js b/src/body/Body.js index 3bdc75cf..f2e4d60f 100644 --- a/src/body/Body.js +++ b/src/body/Body.js @@ -418,13 +418,14 @@ var Axes = require('../geometry/Axes'); // sum the properties of all compound parts of the parent body var total = Body._totalProperties(body); + var positionDelta = Vector.sub(body.positionPrev, body.position); body.area = total.area; body.parent = body; body.position.x = total.centre.x; body.position.y = total.centre.y; - body.positionPrev.x = total.centre.x; - body.positionPrev.y = total.centre.y; + body.positionPrev.x = total.centre.x + positionDelta.x; + body.positionPrev.y = total.centre.y + positionDelta.y; Body.setMass(body, total.mass); Body.setInertia(body, total.inertia);