Skip to content

Commit

Permalink
RigidBodySnapshot: make mutable and add 4 velocity accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jun 20, 2024
1 parent 755e664 commit eddb39d
Showing 1 changed file with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

/**
* Copy certain properties of a {@code PhysicsRigidBody} in order to re-apply
* them later. Immutable.
* them later.
* <p>
* Snapshots are used for rebuilding, so they don't include the collision shape,
* mass, physics space, or position.
Expand Down Expand Up @@ -95,4 +95,40 @@ public void applyTo(PhysicsRigidBody body) {
body.setLinearVelocityDp(linearVelocity);
}
}

/**
* Copy the snapshot's angular velocity.
*
* @param result (not null, unaffected)
*/
public void getAngularVelocity(Vec3d result) {
result.set(angularVelocity);
}

/**
* Copy the snapshot's linear velocity.
*
* @param result (not null, unaffected)
*/
public void getLinearVelocity(Vec3d result) {
result.set(linearVelocity);
}

/**
* Alter the snapshot's angular velocity.
*
* @param vec3d (not null, modified)
*/
public void setAngularVelocity(Vec3d vec3d) {
angularVelocity.set(vec3d);
}

/**
* Alter the snapshot's linear velocity.
*
* @param vec3d (not null, modified)
*/
public void setLinearVelocity(Vec3d vec3d) {
linearVelocity.set(vec3d);
}
}

0 comments on commit eddb39d

Please sign in to comment.