From 648868ea1a2b2ce83cb46bcec0c80793f1a37781 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Tue, 10 Sep 2024 15:13:16 -0600 Subject: [PATCH] Revert "use deltas so they don't compound error from mouse offset, https://github.com/phetsims/density-buoyancy-common/issues/367" This reverts commit fb5af23531ac647ea7a9d92a95052d9a82191c66. --- js/common/model/Mass.ts | 7 ------- js/common/model/PhysicsEngine.ts | 19 ------------------- js/common/view/MassView.ts | 2 +- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/js/common/model/Mass.ts b/js/common/model/Mass.ts index 387d5db7..a6fff454 100644 --- a/js/common/model/Mass.ts +++ b/js/common/model/Mass.ts @@ -532,13 +532,6 @@ export default abstract class Mass extends PhetioObject { this.engine.updatePointerConstraint( this.body, position ); } - /** - * Updates a current drag with a new 2d (x,y) model delta. - */ - public updateDragFromDelta( delta: Vector2 ): void { - this.engine.updatePointerConstraintFromDelta( this.body, delta ); - } - /** * Ends a physics model engine drag. */ diff --git a/js/common/model/PhysicsEngine.ts b/js/common/model/PhysicsEngine.ts index b5d5ae59..bdd978f4 100644 --- a/js/common/model/PhysicsEngine.ts +++ b/js/common/model/PhysicsEngine.ts @@ -401,25 +401,6 @@ export default class PhysicsEngine { pointerConstraint.bodyB.wakeUp(); } - /** - * Updates a pointer constraint so that the body will move by the provided delta value. This can be useful because - * pointerConstraints can be initialized with an offset from, the body origin. - */ - public updatePointerConstraintFromDelta( body: PhysicsEngineBody, deltaVector: Vector2 ): void { - const delta = PhysicsEngine.vectorToP2( deltaVector ); - - const pointerConstraint = this.pointerConstraintMap[ body.id ]; - assert && assert( pointerConstraint, `pointer constraint expected for physics body #${body.id}` ); - - // @ts-expect-error it should have pivotA... - pointerConstraint.pivotA[ 0 ] += delta[ 0 ]; - // @ts-expect-error it should have pivotA... - pointerConstraint.pivotA[ 1 ] += delta[ 1 ]; - - pointerConstraint.bodyA.wakeUp(); - pointerConstraint.bodyB.wakeUp(); - } - /** * Removes a pointer constraint. */ diff --git a/js/common/view/MassView.ts b/js/common/view/MassView.ts index 5771ffaa..e747600d 100644 --- a/js/common/view/MassView.ts +++ b/js/common/view/MassView.ts @@ -138,7 +138,7 @@ export default abstract class MassView extends Disposable { transform: INVERT_Y_TRANSFORM, drag: ( event, listener ) => { mass.grabDragUsageTracker.shouldShowDragCue = false; - mass.updateDragFromDelta( listener.modelDelta ); // Update based on deltas instead of absolute, fixing, https://github.com/phetsims/density-buoyancy-common/issues/367 + mass.updateDrag( mass.matrix.translation.add( listener.modelDelta ) ); }, tandem: Tandem.OPT_OUT } );