Skip to content

Commit

Permalink
Revert "use deltas so they don't compound error from mouse offset, #367"
Browse files Browse the repository at this point in the history
This reverts commit fb5af23.
  • Loading branch information
zepumph committed Sep 10, 2024
1 parent 327d4b0 commit 648868e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
7 changes: 0 additions & 7 deletions js/common/model/Mass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
19 changes: 0 additions & 19 deletions js/common/model/PhysicsEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/MassView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
} );
Expand Down

0 comments on commit 648868e

Please sign in to comment.