Skip to content

Commit

Permalink
Small changes to refactoring, see #234
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo authored and samreid committed Jul 12, 2024
1 parent 64ca76f commit ea9f0ac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions js/buoyancy/model/applications/BuoyancyApplicationsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export default class BuoyancyApplicationsModel extends DensityBuoyancyModel {

/**
* Computes the heights of the main pool fluid, incorporating the Boat logic.
* NOTE: This does not call super.updateFluid() because we need to handle the boat logic interspersed with the rest of the logic here.
* NOTE: This does not call super.updateFluid() because we need to handle the boat logic with the rest of the logic here.
*/
protected override updateFluid(): void {

Expand Down Expand Up @@ -266,7 +266,7 @@ export default class BuoyancyApplicationsModel extends DensityBuoyancyModel {

protected override getUpdatedSubmergedVolume( mass: Mass, submergedVolume: number ): number {

if ( mass === this.boat && this.boat.isFullySubmerged ) {
if ( mass === this.boat && this.boat.visibleProperty.value && this.boat.isFullySubmerged ) {

// Special consideration for when boat is submerged
// Don't count the fluid inside the boat as part of the volume
Expand All @@ -278,7 +278,8 @@ export default class BuoyancyApplicationsModel extends DensityBuoyancyModel {
}

protected override getUpdatedMassValue( mass: Mass, massValue: number, submergedVolume: number ): number {
if ( mass === this.boat && this.boat.isFullySubmerged ) {

if ( mass === this.boat && this.boat.visibleProperty.value && this.boat.isFullySubmerged ) {

// Special consideration for when boat is submerged
// Don't count the fluid inside the boat as part of the mass
Expand Down Expand Up @@ -306,7 +307,7 @@ export default class BuoyancyApplicationsModel extends DensityBuoyancyModel {
protected override updateVerticalMotion( dt: number ): void {
super.updateVerticalMotion( dt );

if ( dt ) {
if ( dt !== 0 && this.boat.visibleProperty.value ) {
this.boat.updateVerticalMotion( this.pool, dt );
}
}
Expand Down

0 comments on commit ea9f0ac

Please sign in to comment.