Skip to content

Commit

Permalink
Character: add 16 public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 25, 2024
1 parent bdc58b7 commit 8f61b4e
Showing 1 changed file with 188 additions and 13 deletions.
201 changes: 188 additions & 13 deletions src/main/java/com/github/stephengold/joltjni/Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,42 @@ public Character(ConstCharacterSettings settings, RVec3Arg location,
// *************************************************************************
// new methods exposed

/**
* Wake up the character using the locking body interface.
*/
public void activate() {
activate(true);
}

/**
* Wake up the character.
*
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void activate(boolean lockBodies) {
long characterVa = va();
activate(characterVa, lockBodies);
}

/**
* Apply an impulse to the character's center of mass, using the locking
* body interface.
*
* @param impulse the impulse vector (kilogram.meters per second in system
* coordinates, not null, unaffected)
*/
public void addImpulse(Vec3Arg impulse) {
addImpulse(impulse, true);
}

/**
* Apply an impulse to the character's center of mass.
*
* @param impulse the impulse vector (kilogram.meters per second in system
* coordinates, not null, unaffected)
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void addImpulse(Vec3Arg impulse, boolean lockBodies) {
long characterVa = va();
Expand All @@ -108,13 +126,23 @@ public void addImpulse(Vec3Arg impulse, boolean lockBodies) {
addImpulse(characterVa, x, y, z, lockBodies);
}

/**
* Add to the character's linear velocity, using the locking body interface.
*
* @param deltaV the change in velocity (meters per second in system
* coordinates, not null, unaffected)
*/
public void addLinearVelocity(Vec3Arg deltaV) {
addLinearVelocity(deltaV, true);
}

/**
* Add to the character's linear velocity.
*
* @param deltaV the change in velocity (meters per second in system
* coordinates, not null, unaffected)
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void addLinearVelocity(Vec3Arg deltaV, boolean lockBodies) {
long characterVa = va();
Expand All @@ -124,6 +152,25 @@ public void addLinearVelocity(Vec3Arg deltaV, boolean lockBodies) {
addLinearVelocity(characterVa, vx, vy, vz, lockBodies);
}

/**
* Add the character to its {@code PhysicsSystem} and activate it, using the
* locking body interface.
*/
public void addToPhysicsSystem() {
addToPhysicsSystem(EActivation.Activate);
}

/**
* Add the character to its {@code PhysicsSystem} using the locking body
* interface.
*
* @param activation whether to activate the character (not null,
* default=Activate)
*/
public void addToPhysicsSystem(EActivation activation) {
addToPhysicsSystem(activation, true);
}

/**
* Add the character to its {@code PhysicsSystem}.
*
Expand All @@ -138,29 +185,59 @@ public void addToPhysicsSystem(EActivation activation, boolean lockBodies) {
addToPhysicsSystem(characterVa, ordinal, lockBodies);
}

/**
* Remove the character from its {@code PhysicsSystem} using the locking
* body interface.
*/
public void removeFromPhysicsSystem() {
removeFromPhysicsSystem(true);
}

/**
* Remove the character from its {@code PhysicsSystem}.
*
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void removeFromPhysicsSystem(boolean lockBodies) {
long characterVa = va();
removeFromPhysicsSystem(characterVa, lockBodies);
}

/**
* Alter the character's object layer, using the locking body interface.
*
* @param layer the index of the desired layer
*/
public void setLayer(int layer) {
setLayer(layer, true);
}

/**
* Alter the character's object layer.
*
* @param layer the index of the desired layer
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void setLayer(int layer, boolean lockBodies) {
long characterVa = va();
setLayer(characterVa, layer, lockBodies);
}

/**
* Alter the character's motion using the locking body interface.
*
* @param linearVelocity the desired linear velocity (meters per second in
* system coordinates, not null, unaffected)
* @param omega the desired angular velocity (radians per second in system
* coordinates, not null, unaffected)
*/
public void setLinearAndAngularVelocity(
Vec3Arg linearVelocity, Vec3Arg omega) {
setLinearAndAngularVelocity(linearVelocity, omega, true);
}

/**
* Alter the character's motion.
*
Expand All @@ -169,7 +246,7 @@ public void setLayer(int layer, boolean lockBodies) {
* @param omega the desired angular velocity (radians per second in system
* coordinates, not null, unaffected)
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void setLinearAndAngularVelocity(Vec3Arg linearVelocity,
Vec3Arg omega, boolean lockBodies) {
Expand All @@ -184,6 +261,16 @@ public void setLinearAndAngularVelocity(Vec3Arg linearVelocity,
characterVa, vx, vy, vz, wx, wy, wz, lockBodies);
}

/**
* Alter the character's linear velocity using the locking body interface.
*
* @param velocity the desired velocity (meters per second in system
* coordinates, not null, unaffected)
*/
public void setLinearVelocity(Vec3Arg velocity) {
setLinearVelocity(velocity, true);
}

/**
* Alter the character's linear velocity.
*
Expand All @@ -200,14 +287,38 @@ public void setLinearVelocity(Vec3Arg velocity, boolean lockBodies) {
setLinearVelocity(characterVa, vx, vy, vz, lockBodies);
}

/**
* Re-locate and activate the character using the locking body interface.
*
* @param location the desired location (in system coordinates, not null,
* unaffected)
*/
public void setPosition(RVec3Arg location) {
setPosition(location, EActivation.Activate, true);
}

/**
* Re-locate the character, optionally activating it, using the locking body
* interface.
*
* @param location the desired location (in system coordinates, not null,
* unaffected)
* @param activation whether to activate the character (not null,
* default=Activate)
*/
public void setPosition(RVec3Arg location, EActivation activation) {
setPosition(location, activation, true);
}

/**
* Re-locate the character, optionally activating it.
*
* @param location the desired location (in system coordinates, not null,
* unaffected)
* @param activation whether to activate the character (not null)
* @param activation whether to activate the character (not null,
* default=Activate)
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void setPosition(
RVec3Arg location, EActivation activation, boolean lockBodies) {
Expand All @@ -219,16 +330,44 @@ public void setPosition(
setPosition(characterVa, locX, locY, locZ, ordinal, lockBodies);
}

/**
* Re-position and activate the character using the locking body interface.
*
* @param location the desired location (in system coordinates, not null,
* unaffected)
* @param orientation the desired orientation (in system coordinates, not
* null, unaffected)
*/
public void setPositionAndRotation(RVec3Arg location, QuatArg orientation) {
setPositionAndRotation(location, orientation, EActivation.Activate);
}

/**
* Re-position the character, optionally activating it.
*
* @param location the desired location (in system coordinates, not null,
* unaffected)
* @param orientation the desired orientation (in system coordinates, not
* null, unaffected)
* @param activation whether to activate the character (not null,
* default=Activate)
*/
public void setPositionAndRotation(RVec3Arg location, QuatArg orientation,
EActivation activation) {
setPositionAndRotation(location, orientation, activation, true);
}

/**
* Re-position the character, optionally activating it.
*
* @param location the desired location (in system coordinates, not null,
* unaffected)
* @param orientation the desired orientation (in system coordinates, not
* null, unaffected)
* @param activation whether to activate the character (not null)
* @param activation whether to activate the character (not null,
* default=Activate)
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void setPositionAndRotation(RVec3Arg location, QuatArg orientation,
EActivation activation, boolean lockBodies) {
Expand All @@ -245,14 +384,37 @@ public void setPositionAndRotation(RVec3Arg location, QuatArg orientation,
qx, qy, qz, qw, ordinal, lockBodies);
}

/**
* Re-orient and activate the character using the locking body interface.
*
* @param orientation the desired orientation (in system coordinates, not
* null, unaffected)
*/
public void setRotation(QuatArg orientation) {
setRotation(orientation, EActivation.Activate);
}

/**
* Re-orient the character, optionally activating it.
*
* @param orientation the desired orientation (in system coordinates, not
* null, unaffected)
* @param activation whether to activate the character (not null,
* default=Activate)
*/
public void setRotation(QuatArg orientation, EActivation activation) {
setRotation(orientation, activation, true);
}

/**
* Re-orient the character, optionally activating it.
*
* @param orientation the desired orientation (in system coordinates, not
* null, unaffected)
* @param activation whether to activate the character (not null)
* @param activation whether to activate the character (not null,
* default=Activate)
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
*/
public void setRotation(QuatArg orientation, EActivation activation,
boolean lockBodies) {
Expand All @@ -265,14 +427,27 @@ public void setRotation(QuatArg orientation, EActivation activation,
setRotation(characterVa, qx, qy, qz, qw, ordinal, lockBodies);
}

/**
* Attempt to alter the character's shape using the locking body interface.
*
* @param shape the desired shape (not null, unaffected)
* @param maxPenetrationDepth the maximum penetration to allow, or MAX_VALUE
* to skip the penetration check
* @return true if the alteration succeeded, otherwise false
*/
public boolean setShape(ConstShape shape, float maxPenetrationDepth) {
boolean result = setShape(shape, maxPenetrationDepth, true);
return result;
}

/**
* Attempt to alter the character's shape.
*
* @param shape the desired shape (not null, unaffected)
* @param maxPenetrationDepth the maximum penetration to allow, or MAX_VALUE
* to skip the penetration check
* @param lockBodies true→use the locking body interface,
* false→use the non-locking body interface
* false→use the non-locking body interface (default=true)
* @return true if the alteration succeeded, otherwise false
*/
public boolean setShape(
Expand Down

0 comments on commit 8f61b4e

Please sign in to comment.