java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.Shape
- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstShape,RefTarget,AutoCloseable,Comparable<JoltPhysicsObject>
- Direct Known Subclasses:
CompoundShape,ConvexShape,DecoratedShape,EmptyShape,HeightFieldShape,MeshShape,PlaneShape,SoftBodyShape
The abstract base class for collision shapes.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcopyDebugTriangles(FloatBuffer storeBuffer) Copy the vertex coordinates of the shape's debug mesh to the specified buffer.intCount the triangles in the shape's debug mesh.voiddraw(DebugRenderer renderer, RMat44Arg comTransform, Vec3Arg scale, ConstColor color, boolean useMaterialColors, boolean wireframe) Draw the shape using the specified renderer.voiddrawGetSupportFunction(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.floatReturn 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.intCount the active references to the nativeShape.longReturn the shape's revision count, which is automatically incremented each time the shape is altered.getStats()Copy the statistics.intCount 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.booleanisValidScale(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.booleanTest whether the shape can be used in a dynamic/kinematic body.voidsaveBinaryState(StreamOut stream) Save the shape to the specified binary stream.scaleShape(Vec3Arg scaleFactors) Scale the current shape, which is unaffected.voidMark the nativeShapeas embedded.protected final voidsetVirtualAddressAsCoOwner(long shapeVa) Assign a native object (assuming there's none already assigned) and designate the JVM object as a co-owner.static ShapeResultsRestoreFromBinaryState(StreamIn stream) Recreate a shape from the specified stream.toRef()Create a counted reference to the nativeShape.toRefC()Create a counted reference to the nativeShape.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, 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, targetVa
-
Method Details
-
sRestoreFromBinaryState
Recreate a shape from the specified stream.- Parameters:
stream- the stream to read (not null)- Returns:
- a new object
-
setVirtualAddressAsCoOwner
protected final void setVirtualAddressAsCoOwner(long shapeVa) Assign a native object (assuming there's none already assigned) and designate the JVM object as a co-owner.- Parameters:
shapeVa- the virtual address of the native object to assign (not zero)
-
copyDebugTriangles
Copy the vertex coordinates of the shape's debug mesh to the specified buffer. The shape is unaffected.- Specified by:
copyDebugTrianglesin 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:
countDebugTrianglesin 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:
drawin 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 ifuseMaterialColorsis false (not null, unaffected)useMaterialColors-trueto use the color in the shape's materialwireframe-trueto draw a wire frame,falsefor 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:
drawGetSupportFunctionin 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:
getCenterOfMassin 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:
getInnerRadiusin interfaceConstShape- Returns:
- the radius (≥0)
-
getLeafShape
Access the leaf shape for the specified sub-shape ID.- Specified by:
getLeafShapein interfaceConstShape- Parameters:
subShapeId- a sub-shape ID that specifies the path to the desired leaf shapestoreRemainderId- storage for the remainder of the sub-shape 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
nullif the ID is invalid
-
getLocalBounds
Return a bounding box that includes the convex radius. The shape is unaffected.- Specified by:
getLocalBoundsin 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:
getMassPropertiesin interfaceConstShape- Returns:
- a new, mutable properties object
-
getMaterial
Access the material of the specified sub-shape. The shape is unaffected.- Specified by:
getMaterialin 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:
getRevisionCountin interfaceConstShape- Returns:
- the count
-
getStats
Copy the statistics. The shape is unaffected.- Specified by:
getStatsin 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:
getSubShapeIdBitsRecursivein interfaceConstShape- Returns:
- the number of bits (≥0)
-
getSubType
Return the shape's subtype. The shape is unaffected.- Specified by:
getSubTypein interfaceConstShape- Returns:
- an enum value (not null)
-
getType
Return the shape's type. The shape is unaffected.- Specified by:
getTypein interfaceConstShape- Returns:
- an enum value (not null)
-
getWorldSpaceBounds
Return the bounding box including convex radius. The shape is unaffected.- Specified by:
getWorldSpaceBoundsin 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:
getWorldSpaceBoundsin 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:
isValidScalein interfaceConstShape- Parameters:
scale- the proposed scale vector (not null, unaffected)- Returns:
trueif 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:
makeScaleValidin 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:
mustBeStaticin interfaceConstShape- Returns:
trueif it can be only be static, otherwisefalse
-
saveBinaryState
Save the shape to the specified binary stream. The shape is unaffected.- Specified by:
saveBinaryStatein interfaceConstShape- Parameters:
stream- the stream to write to (not null)
-
scaleShape
Scale the current shape, which is unaffected.- Specified by:
scaleShapein interfaceConstShape- Parameters:
scaleFactors- the desired scaling on each axis (not null, unaffected)- Returns:
- a new JVM object with a new native object assigned
-
toRefC
Create a counted reference to the nativeShape.- Specified by:
toRefCin interfaceConstShape- Returns:
- a new JVM object with a new native object assigned
-
getRefCount
public int getRefCount()Count the active references to the nativeShape. The shape is unaffected.- Specified by:
getRefCountin interfaceConstShape- Specified by:
getRefCountin interfaceRefTarget- Returns:
- the count (≥0)
-
setEmbedded
public void setEmbedded()Mark the nativeShapeas embedded.- Specified by:
setEmbeddedin interfaceRefTarget
-
toRef
Create a counted reference to the nativeShape.
-