java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.ShapeRefC
- All Implemented Interfaces:
ConstJoltPhysicsObject
,ConstShape
,AutoCloseable
,Comparable<JoltPhysicsObject>
A counted reference to a
ConstShape
. (native type:
RefConst<Shape>
)-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
copyDebugTriangles
(FloatBuffer storeBuffer) Copy the vertex coordinates of the shape's debug mesh to the specified buffer.int
Count the triangles in the shape's debug mesh.void
draw
(DebugRenderer renderer, RMat44Arg comTransform, Vec3Arg scale, ConstColor color, boolean useMaterialColors, boolean wireframe) Draw the shape using the specified renderer.void
drawGetSupportFunction
(DebugRenderer renderer, RMat44Arg comTransform, Vec3Arg scale, ConstColor color, boolean drawSupportDirection) Draw the support function with the convex radius added back on.Locate the shape's center of mass.float
Return the radius of the largest sphere that fits inside the shape.getLeafShape
(int subShapeId, int[] storeRemainderId) Access the leaf shape for the specified sub-shape ID.Return a bounding box that includes the convex radius.Copy the shape's mass properties.getMaterial
(int subShapeId) Access the material of the specified sub-shape.getPtr()
Temporarily access the referencedConstShape
.long
Return the shape's revision count, which is automatically incremented each time the shape is altered.getStats()
Copy the statistics.int
Count how many bits are used to address leaf shapes.Return the shape's subtype.getType()
Return the shape's type.getWorldSpaceBounds
(Mat44Arg comTransform, Vec3Arg scale) Return the bounding box including convex radius.getWorldSpaceBounds
(RMat44Arg comTransform, Vec3Arg scale) Return the bounding box including convex radius.boolean
isValidScale
(Vec3Arg scale) Test whether the specified scale vector is valid for wrapping the current shape in aScaledShape
.makeScaleValid
(Vec3Arg scale) Transform the specified scale vector such that it will be valid for wrapping the current shape in aScaledShape
.boolean
Test whether the shape can be used in a dynamic/kinematic body.void
saveBinaryState
(StreamOut stream) Save the shape to the specified binary stream.long
targetVa()
Return the address of the nativeShape
.toRefC()
Create another counted reference to the nativeShape
.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, toString, va
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject
-
Constructor Details
-
ShapeRefC
public ShapeRefC()Instantiate an empty reference.
-
-
Method Details
-
getPtr
Temporarily access the referencedConstShape
.- Returns:
- a new JVM object with the pre-existing native object assigned
-
copyDebugTriangles
Copy the vertex coordinates of the shape's debug mesh to the specified buffer. The shape is unaffected.- Specified by:
copyDebugTriangles
in interfaceConstShape
- Parameters:
storeBuffer
- the buffer to fill with vertex coordinates (not null, modified)
-
countDebugTriangles
public int countDebugTriangles()Count the triangles in the shape's debug mesh. The shape is unaffected.- Specified by:
countDebugTriangles
in interfaceConstShape
- Returns:
- the count (>0)
-
draw
public void draw(DebugRenderer renderer, RMat44Arg comTransform, Vec3Arg scale, ConstColor color, boolean useMaterialColors, boolean wireframe) Draw the shape using the specified renderer. The shape is unaffected.- Specified by:
draw
in interfaceConstShape
- Parameters:
renderer
- the renderer to use (not null)comTransform
- the coordinate transform from the shape's center of mass to system coordinates (not null, unaffected)scale
- the desired scaling (not null, unaffected)color
- the desired color ifuseMaterialColors
is false (not null, unaffected)useMaterialColors
-true
to use the color in the shape's materialwireframe
-true
to draw a wire frame,false
for solid triangles
-
drawGetSupportFunction
public void drawGetSupportFunction(DebugRenderer renderer, RMat44Arg comTransform, Vec3Arg scale, ConstColor color, boolean drawSupportDirection) Draw the support function with the convex radius added back on. The shape is unaffected.- Specified by:
drawGetSupportFunction
in interfaceConstShape
- Parameters:
renderer
- the renderer to use (not null)comTransform
- transform to apply (not null, unaffected)scale
- scaling to apply (not null, unaffected)color
- the color using for drawing (not null, unaffected)drawSupportDirection
- the direction to draw
-
getCenterOfMass
Locate the shape's center of mass. The shape is unaffected.- Specified by:
getCenterOfMass
in interfaceConstShape
- Returns:
- a new location vector
-
getInnerRadius
public float getInnerRadius()Return the radius of the largest sphere that fits inside the shape. The shape is unaffected.- Specified by:
getInnerRadius
in interfaceConstShape
- Returns:
- the radius (≥0)
-
getLeafShape
Access the leaf shape for the specified sub-shape ID.- Specified by:
getLeafShape
in interfaceConstShape
- Parameters:
subShapeId
- an ID that indicates the path to the desired leaf shape (not null, unaffected)storeRemainderId
- storage for the remainder of the ID after removing the path to the leaf shape (not null, modified)- Returns:
- a new JVM object with the pre-existing native object assigned, or
null
if the ID is invalid
-
getLocalBounds
Return a bounding box that includes the convex radius. The shape is unaffected.- Specified by:
getLocalBounds
in interfaceConstShape
- Returns:
- a new, mutable box (relative to the shape's center of mass)
-
getMassProperties
Copy the shape's mass properties. The shape is unaffected.- Specified by:
getMassProperties
in interfaceConstShape
- Returns:
- a new, mutable properties object
-
getMaterial
Access the material of the specified sub-shape. The shape is unaffected.- Specified by:
getMaterial
in interfaceConstShape
- Parameters:
subShapeId
- which sub-shape- Returns:
- a new JVM object with the pre-existing native object assigned
-
getRevisionCount
public long getRevisionCount()Return the shape's revision count, which is automatically incremented each time the shape is altered. The shape is unaffected.- Specified by:
getRevisionCount
in interfaceConstShape
- Returns:
- the count
-
getStats
Copy the statistics. The shape is unaffected.- Specified by:
getStats
in interfaceConstShape
- Returns:
- a new object
-
getSubShapeIdBitsRecursive
public int getSubShapeIdBitsRecursive()Count how many bits are used to address leaf shapes. The shape is unaffected.- Specified by:
getSubShapeIdBitsRecursive
in interfaceConstShape
- Returns:
- the number of bits (≥0)
-
getSubType
Return the shape's subtype. The shape is unaffected.- Specified by:
getSubType
in interfaceConstShape
- Returns:
- an enum value (not null)
-
getType
Return the shape's type. The shape is unaffected.- Specified by:
getType
in interfaceConstShape
- Returns:
- an enum value (not null)
-
getWorldSpaceBounds
Return the bounding box including convex radius. The shape is unaffected.- Specified by:
getWorldSpaceBounds
in interfaceConstShape
- Parameters:
comTransform
- the center-of-mass transform to apply to the shape (not null, unaffected)scale
- the scale factors to apply to the shape (not null, unaffected)- Returns:
- a new, mutable box (in system coordinates)
-
getWorldSpaceBounds
Return the bounding box including convex radius. The shape is unaffected.- Specified by:
getWorldSpaceBounds
in interfaceConstShape
- Parameters:
comTransform
- the center-of-mass transform to apply to the shape (not null, unaffected)scale
- the scale factors to apply to the shape (not null, unaffected)- Returns:
- a new, mutable box (in system coordinates)
-
isValidScale
Test whether the specified scale vector is valid for wrapping the current shape in aScaledShape
. The current shape is unaffected.- Specified by:
isValidScale
in interfaceConstShape
- Parameters:
scale
- the proposed scale vector (not null, unaffected)- Returns:
true
if valid, otherwisefalse
-
makeScaleValid
Transform the specified scale vector such that it will be valid for wrapping the current shape in aScaledShape
. The current shape is unaffected.- Specified by:
makeScaleValid
in interfaceConstShape
- Parameters:
scale
- the proposed scale vector (not null, unaffected)- Returns:
- a new scale vector
-
mustBeStatic
public boolean mustBeStatic()Test whether the shape can be used in a dynamic/kinematic body. The shape is unaffected.- Specified by:
mustBeStatic
in interfaceConstShape
- Returns:
true
if it can be only be static, otherwisefalse
-
saveBinaryState
Save the shape to the specified binary stream. The shape is unaffected.- Specified by:
saveBinaryState
in interfaceConstShape
- Parameters:
stream
- the stream to write to (not null)
-
targetVa
public long targetVa()Return the address of the nativeShape
. No objects are affected.- Specified by:
targetVa
in interfaceConstJoltPhysicsObject
- Overrides:
targetVa
in classJoltPhysicsObject
- Returns:
- a virtual address (not zero)
-
toRefC
Create another counted reference to the nativeShape
.- Specified by:
toRefC
in interfaceConstShape
- Returns:
- a new JVM object with a new native object assigned
-