Package com.github.stephengold.joltjni
Class CharacterVirtual
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.CharacterBase
com.github.stephengold.joltjni.CharacterVirtual
- All Implemented Interfaces:
ConstCharacterBase,ConstCharacterVirtual,ConstJoltPhysicsObject,RefTarget,AutoCloseable,Comparable<ConstJoltPhysicsObject>
A character implemented without a rigid body.
-
Constructor Summary
ConstructorsConstructorDescriptionCharacterVirtual(long characterVa) Instantiate a character with the specified native object assigned but not owned.CharacterVirtual(ConstCharacterVirtualSettings settings, RVec3Arg location, QuatArg orientation, long userData, PhysicsSystem system) Instantiate a character with a new native object assigned. -
Method Summary
Modifier and TypeMethodDescriptioncancelVelocityTowardsSteepSlopes(Vec3Arg desiredVelocity) Convert the specified velocity to one that won't climb steep slopes.booleancanWalkStairs(Vec3Arg desiredVelocity) Test whether the character has moved onto a steep slope.voidextendedUpdate(float deltaTime, Vec3Arg gravity, ExtendedUpdateSettings settings, BroadPhaseLayerFilter bpFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator) Apply a combination of Update, StickToFloor, and WalkStairs.Access the list of contacts.Calculate the location of the character's center of mass.Calculate the local-to-system transform of the character's center of mass.floatReturn the thickness of the character's padding.Access the char-vs-char collision interface.booleanTest whether enhanced internal edge removal is enabled.floatReturn the maximum angle for merging during hit reduction.Return the ID of the inner body.Return the linear velocity of the character.Access the (application-provided) contact listener.floatgetMass()Return the character's mass.booleanTest whether the last collision check discarded one or more hits.intReturn the maximum number of hits to be collected.floatReturn the maximum force applied to other bodies.floatReturn how quickly penetration is resolved.Copy the location of the character.intCount the active references to the nativeCharacterVirtual.Copy the orientation of the character.Copy the local offset applied to the shape.longReturn the character's user data: can be used for anything.Calculate the character's local-to-system coordinate transform.booleanhasCollidedWith(ConstBodyId bodyId) Test whether the character is in contact with or collided with the specified body during the previous time step.booleanhasCollidedWith(ConstCharacterVirtual otherCharacter) Test whether the character is in contact with or has collided with the specified character during the previous time step.voidReplace the char-vs-char collision interface.voidMark the nativeCharacterVirtualas embedded.voidsetEnhancedInternalEdgeRemoval(boolean enable) Enable or disable enhanced internal edge removal.voidsetHitReductionCosMaxAngle(float cosine) Alter the maximum angle for merging during hit reduction.voidsetInnerBodyShape(ConstShape shape) Alter the shape of the inner body.voidsetLinearVelocity(Vec3Arg velocity) Alter the character's linear velocity.voidsetListener(CharacterContactListener listener) Replace the contact listener.voidsetMass(float mass) Alter the character's mass.voidsetMaxNumHits(int maxHits) Alter the maximum number of hits to be collected.voidsetMaxStrength(float force) Alter the maximum force applied to bodies.voidsetPenetrationRecoverySpeed(float fraction) Alter how quickly penetration is resolved.voidsetPosition(RVec3Arg location) Relocate the character.voidsetRotation(QuatArg orientation) Re-orient the character.voidsetShapeOffset(Vec3Arg offset) Alter the shape offset.voidsetUserData(long userData) Alter the user data.toRef()Create a counted reference to the nativeCharacterVirtual.voidUpdate the estimated ground velocity.Methods inherited from class com.github.stephengold.joltjni.CharacterBase
getCosMaxSlopeAngle, getGroundBodyId, getGroundMaterial, getGroundNormal, getGroundPosition, getGroundState, getGroundSubShapeId, getGroundUserData, getGroundVelocity, getShape, getUp, isSlopeTooSteep, isSupported, restoreState, saveState, setMaxSlopeAngle, setUpMethods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, startCleaner, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstCharacterBase
getCosMaxSlopeAngle, getGroundBodyId, getGroundMaterial, getGroundNormal, getGroundPosition, getGroundState, getGroundSubShapeId, getGroundUserData, getGroundVelocity, getShape, getUp, isSlopeTooSteep, isSupported, saveStateMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, va
-
Constructor Details
-
CharacterVirtual
public CharacterVirtual(long characterVa) Instantiate a character with the specified native object assigned but not owned.For use in custom contact listeners.
- Parameters:
characterVa- the virtual address of the native object to assign (not zero)
-
CharacterVirtual
public CharacterVirtual(ConstCharacterVirtualSettings settings, RVec3Arg location, QuatArg orientation, long userData, PhysicsSystem system) Instantiate a character with a new native object assigned.- Parameters:
settings- the settings to use (not null, unaffected)location- the desired initial location (in system coordinates, not null, unaffected)orientation- the desired initial orientation (in system coordinates, not null, unaffected)userData- the desired user-data valuesystem- the system to which the character will be added (not null)
-
-
Method Details
-
extendedUpdate
public void extendedUpdate(float deltaTime, Vec3Arg gravity, ExtendedUpdateSettings settings, BroadPhaseLayerFilter bpFilter, ObjectLayerFilter olFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator) Apply a combination of Update, StickToFloor, and WalkStairs.- Parameters:
deltaTime- the time step to simulategravity- the gravity acceleration vector (in meters per second squared, not null, unaffected)settings- settings to use (not null, unaffected)bpFilter- to test whether the character collides with a broad-phase layer (not null, unaffected)olFilter- to test whether the character collides with an object layer (not null, unaffected)bodyFilter- to test whether the character collides with a body (not null, unaffected)shapeFilter- to test whether the character collides with a shape (not null, unaffected)allocator- for temporary allocations (not null)
-
getCharacterVsCharacterCollision
Access the char-vs-char collision interface.- Returns:
- the pre-existing object, or
nullif none
-
getListener
Access the (application-provided) contact listener.- Returns:
- the pre-existing instance, or
nullif none
-
setCharacterVsCharacterCollision
Replace the char-vs-char collision interface.- Parameters:
cvcInterface- the desired interface (not null)
-
setEnhancedInternalEdgeRemoval
public void setEnhancedInternalEdgeRemoval(boolean enable) Enable or disable enhanced internal edge removal.- Parameters:
enable- true to enable, false to disable (default=?)
-
setHitReductionCosMaxAngle
public void setHitReductionCosMaxAngle(float cosine) Alter the maximum angle for merging during hit reduction.- Parameters:
cosine- the cosine of the desired maximum angle, or -1 to disable hit reduction (default=?)
-
setInnerBodyShape
Alter the shape of the inner body. Invoke this after a successful invocation ofsetShape().- Parameters:
shape- the desired shape (not null, unaffected, default=?)
-
setLinearVelocity
Alter the character's linear velocity.- Parameters:
velocity- the desired velocity vector (meters per second in system coordinates, default=?)
-
setListener
Replace the contact listener.- Parameters:
listener- the desired listener
-
setMass
public void setMass(float mass) Alter the character's mass.- Parameters:
mass- the desired mass (in kilograms, default=?)
-
setMaxNumHits
public void setMaxNumHits(int maxHits) Alter the maximum number of hits to be collected.- Parameters:
maxHits- the desired limit (≥0, default=?)
-
setMaxStrength
public void setMaxStrength(float force) Alter the maximum force applied to bodies.- Parameters:
force- the desired force limit (in Newtons, default=?)
-
setPenetrationRecoverySpeed
public void setPenetrationRecoverySpeed(float fraction) Alter how quickly penetration is resolved.- Parameters:
fraction- the desired resolution fraction (0→never resolved, 1→all in one update, default=?)
-
setPosition
Relocate the character.- Parameters:
location- the desired location (in system coordinates, default=?)
-
setRotation
Re-orient the character.- Parameters:
orientation- the desired orientation (in system coordinates, default=?)
-
setShapeOffset
Alter the shape offset.- Parameters:
offset- the desired offset (in local coordinates, default=?)
-
setUserData
public void setUserData(long userData) Alter the user data.- Parameters:
userData- the desired value
-
updateGroundVelocity
public void updateGroundVelocity()Update the estimated ground velocity. -
cancelVelocityTowardsSteepSlopes
Convert the specified velocity to one that won't climb steep slopes. The character is unaffected.- Specified by:
cancelVelocityTowardsSteepSlopesin interfaceConstCharacterVirtual- Parameters:
desiredVelocity- velocity vector (in system coordinates, not null, unaffected)- Returns:
- a new velocity vector (in system coordinates)
-
canWalkStairs
Test whether the character has moved onto a steep slope. The character is unaffected.- Specified by:
canWalkStairsin interfaceConstCharacterVirtual- Parameters:
desiredVelocity- velocity vector (in system coordinates, not null, unaffected)- Returns:
- true if too step to walk, otherwise false
-
getActiveContacts
Access the list of contacts. The character is unaffected.- Specified by:
getActiveContactsin interfaceConstCharacterVirtual- Returns:
- a new JVM object with the pre-existing native object assigned
-
getCenterOfMassPosition
Calculate the location of the character's center of mass. The character is unaffected.- Specified by:
getCenterOfMassPositionin interfaceConstCharacterVirtual- Returns:
- a new location vector (in system coordinates)
-
getCenterOfMassTransform
Calculate the local-to-system transform of the character's center of mass. The character is unaffected.- Specified by:
getCenterOfMassTransformin interfaceConstCharacterVirtual- Returns:
- a new coordinate transform matrix
-
getCharacterPadding
public float getCharacterPadding()Return the thickness of the character's padding. The character is unaffected.- Specified by:
getCharacterPaddingin interfaceConstCharacterVirtual- Returns:
- the thickness (in meters)
-
getEnhancedInternalEdgeRemoval
public boolean getEnhancedInternalEdgeRemoval()Test whether enhanced internal edge removal is enabled. The character is unaffected.- Specified by:
getEnhancedInternalEdgeRemovalin interfaceConstCharacterVirtual- Returns:
- true if enabled, otherwise false
-
getHitReductionCosMaxAngle
public float getHitReductionCosMaxAngle()Return the maximum angle for merging during hit reduction. The character is unaffected.- Specified by:
getHitReductionCosMaxAnglein interfaceConstCharacterVirtual- Returns:
- the cosine of the maximum angle, or -1 if hit reduction is disabled
-
getInnerBodyId
Return the ID of the inner body. The character is unaffected.- Specified by:
getInnerBodyIdin interfaceConstCharacterVirtual- Returns:
- the ID, or
nullif none
-
getLinearVelocity
Return the linear velocity of the character. The character is unaffected.- Specified by:
getLinearVelocityin interfaceConstCharacterVirtual- Returns:
- a new velocity vector (meters per second in system coordinates)
-
getMass
public float getMass()Return the character's mass. The character is unaffected.- Specified by:
getMassin interfaceConstCharacterVirtual- Returns:
- the mass (in kilograms)
-
getMaxHitsExceeded
public boolean getMaxHitsExceeded()Test whether the last collision check discarded one or more hits. The character is unaffected.- Specified by:
getMaxHitsExceededin interfaceConstCharacterVirtual- Returns:
- true if discarded hits, otherwise false
-
getMaxNumHits
public int getMaxNumHits()Return the maximum number of hits to be collected. The character is unaffected.- Specified by:
getMaxNumHitsin interfaceConstCharacterVirtual- Returns:
- the limit (≥0)
-
getMaxStrength
public float getMaxStrength()Return the maximum force applied to other bodies. The character is unaffected.- Specified by:
getMaxStrengthin interfaceConstCharacterVirtual- Returns:
- the force (in Newtons)
-
getPenetrationRecoverySpeed
public float getPenetrationRecoverySpeed()Return how quickly penetration is resolved. The character is unaffected.- Specified by:
getPenetrationRecoverySpeedin interfaceConstCharacterVirtual- Returns:
- the resolution fraction (0=never resolved, 1=all in one update)
-
getPosition
Copy the location of the character. The character is unaffected.- Specified by:
getPositionin interfaceConstCharacterVirtual- Returns:
- a new location vector (in system coordinates)
-
getRotation
Copy the orientation of the character. The character is unaffected.- Specified by:
getRotationin interfaceConstCharacterVirtual- Returns:
- a new rotation quaternion (in system coordinates)
-
getShapeOffset
Copy the local offset applied to the shape. The character is unaffected.- Specified by:
getShapeOffsetin interfaceConstCharacterVirtual- Returns:
- a new offset vector (in local coordinates)
-
getUserData
public long getUserData()Return the character's user data: can be used for anything. The character is unaffected.- Specified by:
getUserDatain interfaceConstCharacterVirtual- Returns:
- the value
-
getWorldTransform
Calculate the character's local-to-system coordinate transform. The character is unaffected.- Specified by:
getWorldTransformin interfaceConstCharacterVirtual- Returns:
- a new transform matrix
-
hasCollidedWith
Test whether the character is in contact with or collided with the specified body during the previous time step. The character is unaffected.- Specified by:
hasCollidedWithin interfaceConstCharacterVirtual- Parameters:
bodyId- the ID of the body to test against (not null, unaffected)- Returns:
- true if contact or collision, otherwise false
-
hasCollidedWith
Test whether the character is in contact with or has collided with the specified character during the previous time step. The current character is unaffected.- Specified by:
hasCollidedWithin interfaceConstCharacterVirtual- Parameters:
otherCharacter- the character to test against (not null, unaffected)- Returns:
- true if contact or collision, otherwise false
-
getRefCount
public int getRefCount()Count the active references to the nativeCharacterVirtual. The character is unaffected.- Specified by:
getRefCountin interfaceRefTarget- Returns:
- the count (≥0)
-
setEmbedded
public void setEmbedded()Mark the nativeCharacterVirtualas embedded.- Specified by:
setEmbeddedin interfaceRefTarget
-
toRef
Create a counted reference to the nativeCharacterVirtual.- Specified by:
toRefin interfaceRefTarget- Specified by:
toRefin classCharacterBase- Returns:
- a new JVM object with a new native object assigned
-