Package com.github.stephengold.joltjni
Class CharacterVirtualRef
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.template.Ref
com.github.stephengold.joltjni.CharacterVirtualRef
- All Implemented Interfaces:
ConstCharacterBase,ConstCharacterVirtual,ConstJoltPhysicsObject,AutoCloseable,Comparable<JoltPhysicsObject>
A counted reference to a
CharacterVirtual. (native type:
Ref<CharacterVirtual>)-
Constructor Summary
Constructors -
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.Copy the list of active 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.Generate settings to reconstruct the character.floatReturn the maximum slope the character can walk on.booleanTest whether enhanced internal edge removal is enabled.intReturn the body ID of the supporting surface.Access the material of the supporting surface.Copy the normal direction at the point of contact with the supporting surface.Copy the location of the point of contact with the supporting surface.Return the relationship between the character and its supporting surface.intIdentify the face on the supporting surface where contact is occurring.longReturn the user data of the supporting surface.Copy the world-space velocity of the supporting surface.floatReturn the maximum angle for merging during hit reduction.intgetId()Return the character's ID.intReturn the ID of the inner body.Copy the linear velocity of the character.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.voidgetPositionAndRotation(RVec3 storeLocation, Quat storeOrientation) Copy the position of the character.getPtr()Temporarily access the referencedCharacterVirtual.intCount the active references to the nativeCharacterVirtual.Copy the orientation of the character.getShape()Access the character's shape.voidUpdate the specified counted reference to refer to the character's shape.Copy the local offset applied to the shape.Generate a TransformedShape that represents the volume occupied by the character.getUp()Copy the character's "up" direction.longReturn the character's user data: can be used for anything.Calculate the character's local-to-system coordinate transform.booleanhasCollidedWith(int 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.booleanisSlopeTooSteep(Vec3Arg normal) Test whether the specified normal direction is too steep.booleanTest whether the character is supported.voidrestoreState(StateRecorder recorder) Restore the character's state from the specified recorder.voidsaveState(StateRecorder recorder) Save the character's state to the specified recorder.voidsetInnerBodyShape(ConstShape shape) Alter the shape of the inner body.voidsetLinearVelocity(float vx, float vy, float vz) Alter the character's linear velocity.voidsetLinearVelocity(Vec3Arg velocity) Alter the character's linear velocity.voidsetPosition(RVec3Arg location) Relocate the character.voidsetRotation(QuatArg orientation) Re-orient the character.booleansetShape(ConstShape shape, float maxPenetrationDepth, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator) Alter the character's shape.voidAlter the character's "up" direction.longtargetVa()Return the address of the nativeCharacterVirtual.toRef()Create another counted reference to the nativeCharacterVirtual.toRefC()Create another counted reference to the nativeCharacterVirtual.voidUpdate the estimated ground velocity.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, 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.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject
-
Constructor Details
-
CharacterVirtualRef
public CharacterVirtualRef()Instantiate an empty reference.
-
-
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, notnull, unaffected)settings- settings to use (notnull, unaffected)bpFilter- to test whether the character collides with a broad-phase layer (notnull, unaffected)olFilter- to test whether the character collides with an object layer (notnull, unaffected)bodyFilter- to test whether the character collides with a body (notnull, unaffected)shapeFilter- to test whether the character collides with a shape (notnull, unaffected)allocator- for temporary allocations (notnull)
-
restoreState
Restore the character's state from the specified recorder.- Parameters:
recorder- the recorder to restore from (notnull)
-
setLinearVelocity
public void setLinearVelocity(float vx, float vy, float vz) Alter the character's linear velocity.- Parameters:
vx- the X component of the desired velocity (in meters per second, default=0)vy- the Y component of the desired velocity (in meters per second, default=0)vz- the Z component of the desired velocity (in meters per second, default=0)
-
setLinearVelocity
Alter the character's linear velocity.- Parameters:
velocity- the desired velocity vector (meters per second in system coordinates, default=(0,0,0))
-
setPosition
Relocate the character.- Parameters:
location- the desired location (in system coordinates, default=(0,0,0))
-
setRotation
Re-orient the character.- Parameters:
orientation- the desired orientation (in system coordinates, default=(0,0,0,1))
-
setShape
public boolean setShape(ConstShape shape, float maxPenetrationDepth, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator) Alter the character's shape.- Parameters:
shape- the desired shape (notnull)maxPenetrationDepth- the maximum acceptable penetration after the alteration, orFloat.MAX_VALUEto skip the checkbroadPhaseLayerFilter- the broadphase filter used to test for collisions (notnull)objectLayerFilter- the object-layer filter used to test for collisions (notnull)bodyFilter- the body filter used to test for collisions (notnull)shapeFilter- the shape filter used to test for collisions (notnull)allocator- the desired allocator (notnull)- Returns:
trueif successful, otherwisefalse
-
setInnerBodyShape
Alter the shape of the inner body. Invoke this after a successful invocation ofsetShape().- Parameters:
shape- the desired shape (notnull, unaffected, default=?)
-
setUp
Alter the character's "up" direction.- Parameters:
up- the desired direction (notnull, unaffected, default=(0,1,0))
-
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, notnull, 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, notnull, unaffected)- Returns:
trueif too step to walk, otherwisefalse
-
getActiveContacts
Copy the list of active contacts. The character is unaffected.- Specified by:
getActiveContactsin interfaceConstCharacterVirtual- Returns:
- a new array of new objects
-
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)
-
getCharacterVirtualSettings
Generate settings to reconstruct the character. The character is unaffected.- Specified by:
getCharacterVirtualSettingsin interfaceConstCharacterVirtual- Returns:
- a new object
-
getCosMaxSlopeAngle
public float getCosMaxSlopeAngle()Return the maximum slope the character can walk on. The character is unaffected.- Specified by:
getCosMaxSlopeAnglein interfaceConstCharacterBase- Returns:
- the cosine of the slope angle
-
getEnhancedInternalEdgeRemoval
public boolean getEnhancedInternalEdgeRemoval()Test whether enhanced internal edge removal is enabled. The character is unaffected.- Specified by:
getEnhancedInternalEdgeRemovalin interfaceConstCharacterVirtual- Returns:
trueif enabled, otherwisefalse
-
getGroundBodyId
public int getGroundBodyId()Return the body ID of the supporting surface. The character is unaffected.- Specified by:
getGroundBodyIdin interfaceConstCharacterBase- Returns:
- the
BodyIDvalue
-
getGroundMaterial
Access the material of the supporting surface. The character is unaffected.- Specified by:
getGroundMaterialin interfaceConstCharacterBase- Returns:
- a new JVM object with the pre-existing native object assigned, or
else
null
-
getGroundNormal
Copy the normal direction at the point of contact with the supporting surface. The character is unaffected.- Specified by:
getGroundNormalin interfaceConstCharacterBase- Returns:
- a new direction vector (in system coordinates)
-
getGroundPosition
Copy the location of the point of contact with the supporting surface. The character is unaffected.- Specified by:
getGroundPositionin interfaceConstCharacterBase- Returns:
- a new location vector (in system coordinates)
-
getGroundState
Return the relationship between the character and its supporting surface. The character is unaffected.- Specified by:
getGroundStatein interfaceConstCharacterBase- Returns:
- an enum value (not
null)
-
getGroundSubShapeId
public int getGroundSubShapeId()Identify the face on the supporting surface where contact is occurring. The character is unaffected.- Specified by:
getGroundSubShapeIdin interfaceConstCharacterBase- Returns:
- a
SubShapeIDvalue
-
getGroundUserData
public long getGroundUserData()Return the user data of the supporting surface. The character is unaffected.- Specified by:
getGroundUserDatain interfaceConstCharacterBase- Returns:
- the 64-bit value
-
getGroundVelocity
Copy the world-space velocity of the supporting surface. The character is unaffected.- Specified by:
getGroundVelocityin interfaceConstCharacterBase- Returns:
- a new velocity vector (meters per second in system coordinates)
-
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
-
getId
public int getId()Return the character's ID. The character is unaffected. (native function: GetID)- Specified by:
getIdin interfaceConstCharacterVirtual- Returns:
- a
CharacterIdvalue
-
getInnerBodyId
public int getInnerBodyId()Return the ID of the inner body. The character is unaffected. (native function: GetInnerBodyID)- Specified by:
getInnerBodyIdin interfaceConstCharacterVirtual- Returns:
- the
BodyIDvalue
-
getLinearVelocity
Copy 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:
trueif discarded hits, otherwisefalse
-
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)
-
getPositionAndRotation
Copy the position of the character. The character is unaffected.- Specified by:
getPositionAndRotationin interfaceConstCharacterVirtual- Parameters:
storeLocation- storage for the location (in system coordinates, notnull, modified)storeOrientation- storage for the orientation (in system coordinates, notnull, modified)
-
getRefCount
public int getRefCount()Count the active references to the nativeCharacterVirtual. The settings are unaffected.- Specified by:
getRefCountin interfaceConstCharacterBase- Returns:
- the count (≥0)
-
getRotation
Copy the orientation of the character. The character is unaffected.- Specified by:
getRotationin interfaceConstCharacterVirtual- Returns:
- a new rotation quaternion (in system coordinates)
-
getShape
Access the character's shape. The character is unaffected.- Specified by:
getShapein interfaceConstCharacterBase- Returns:
- a new immutable JVM object with the pre-existing native object
assigned, or
nullif none
-
getShape
Update the specified counted reference to refer to the character's shape. The character is unaffected.- Specified by:
getShapein interfaceConstCharacterBase- Parameters:
storeRef- storage for the reference (notnull, modified)
-
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)
-
getTransformedShape
Generate a TransformedShape that represents the volume occupied by the character. The character is unaffected.- Specified by:
getTransformedShapein interfaceConstCharacterVirtual- Returns:
- a new object
-
getUp
Copy the character's "up" direction. The character is unaffected.- Specified by:
getUpin interfaceConstCharacterBase- Returns:
- a new direction vector
-
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
public boolean hasCollidedWith(int bodyId) 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- Returns:
trueif contact or collision, otherwisefalse
-
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 (notnull, unaffected)- Returns:
trueif contact or collision, otherwisefalse
-
isSlopeTooSteep
Test whether the specified normal direction is too steep. The character is unaffected.- Specified by:
isSlopeTooSteepin interfaceConstCharacterBase- Parameters:
normal- the surface normal to test (notnull, unaffected)- Returns:
trueif too steep, otherwisefalse
-
isSupported
public boolean isSupported()Test whether the character is supported. The character is unaffected.- Specified by:
isSupportedin interfaceConstCharacterBase- Returns:
trueif supported, otherwisefalse
-
saveState
Save the character's state to the specified recorder. The character is unaffected.- Specified by:
saveStatein interfaceConstCharacterBase- Parameters:
recorder- the recorder to save to (notnull)
-
toRefC
Create another counted reference to the nativeCharacterVirtual.- Specified by:
toRefCin interfaceConstCharacterVirtual- Returns:
- a new JVM object with a new native object assigned
-
getPtr
Temporarily access the referencedCharacterVirtual. -
targetVa
public long targetVa()Return the address of the nativeCharacterVirtual. No objects are affected.- Specified by:
targetVain interfaceConstJoltPhysicsObject- Overrides:
targetVain classJoltPhysicsObject- Returns:
- a virtual address (not zero)
-
toRef
Create another counted reference to the nativeCharacterVirtual.
-