java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.Shape
com.github.stephengold.joltjni.HeightFieldShape
- All Implemented Interfaces:
ConstJoltPhysicsObject
,ConstShape
,RefTarget
,AutoCloseable
,Comparable<JoltPhysicsObject>
A
Shape
to represent a surface defined by a matrix of heights.-
Method Summary
Modifier and TypeMethodDescriptionint
Return the block size.getPosition
(int x, int y) Copy the location of specified sample.getSurfaceNormal
(int subShapeId, Vec3Arg localLocation) Calculate the normal to the surface at the specified surface location.boolean
isNoCollision
(int x, int y) Test whether the shape has a hole at the specified sample.boolean
projectOntoSurface
(Vec3Arg localLocation, Vec3 storeSurfaceLocation, int[] storeSubShapeId) Project the specified location along the Y axis to find a location on the surface.void
setHeights
(int startX, int startY, int sizeX, int sizeY, FloatBuffer heights, int stride, TempAllocator allocator) Alter the heights for a rectangular sub-matrix.void
setHeights
(int startX, int startY, int sizeX, int sizeY, FloatBuffer heights, int stride, TempAllocator allocator, float cosThresholdAngle) Alter the heights for a rectangular sub-matrix.Methods inherited from class com.github.stephengold.joltjni.Shape
copyDebugTriangles, countDebugTriangles, draw, drawGetSupportFunction, getCenterOfMass, getInnerRadius, getLeafShape, getLocalBounds, getMassProperties, getMaterial, getRefCount, getRevisionCount, getStats, getSubShapeIdBitsRecursive, getSubType, getType, getWorldSpaceBounds, getWorldSpaceBounds, isValidScale, makeScaleValid, mustBeStatic, saveBinaryState, setEmbedded, sRestoreFromBinaryState, toRef, toRefC
Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, 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, targetVa
-
Method Details
-
getBlockSize
public int getBlockSize()Return the block size. The shape is unaffected.- Returns:
- the number of height values in a block
-
getPosition
Copy the location of specified sample. The shape is unaffected.- Parameters:
x
- the X coordinate of the sample (≥0, <sampleCount)y
- the Y coordinate of the sample (≥0, <sampleCount)- Returns:
- a new location vector
-
getSurfaceNormal
Calculate the normal to the surface at the specified surface location.- Parameters:
subShapeId
- which sub-shape to uselocalLocation
- the location relative to the shape's center of mass (not null, unaffected)- Returns:
- a new direction vector
-
isNoCollision
public boolean isNoCollision(int x, int y) Test whether the shape has a hole at the specified sample. The shape is unaffected.- Parameters:
x
- the X coordinate of the sample (≥0, <sampleCount)y
- the Y coordinate of the sample (≥0, <sampleCount)- Returns:
true
if there's a hole, otherwisefalse
-
projectOntoSurface
public boolean projectOntoSurface(Vec3Arg localLocation, Vec3 storeSurfaceLocation, int[] storeSubShapeId) Project the specified location along the Y axis to find a location on the surface.- Parameters:
localLocation
- the location relative to the shape's center of mass (not null, unaffected)storeSurfaceLocation
- storage for the surface location (not null, modified)storeSubShapeId
- storage for the sub-shape ID (not null, modified)- Returns:
true
if a valid surface location was found, otherwisefalse
-
setHeights
public void setHeights(int startX, int startY, int sizeX, int sizeY, FloatBuffer heights, int stride, TempAllocator allocator) Alter the heights for a rectangular sub-matrix.- Parameters:
startX
- the index of the start row (multiple of the block size, ≥0, <sampleCount
)startY
- the index of the start column (multiple of the block size, ≥0, <sampleCount
)sizeX
- the number of affected rows (multiple of the block size, ≥0, ≤sampleCount-startX
)sizeY
- the number of affected columns (multiple of the block size, ≥0, ≤sampleCount-startY
)heights
- the height values to setstride
- stride between consecutive rows inheights
(in floats)allocator
- for temporary allocations (not null)
-
setHeights
public void setHeights(int startX, int startY, int sizeX, int sizeY, FloatBuffer heights, int stride, TempAllocator allocator, float cosThresholdAngle) Alter the heights for a rectangular sub-matrix.- Parameters:
startX
- the index of the start row (multiple of the block size, ≥0, <sampleCount
)startY
- the index of the start column (multiple of the block size, ≥0, <sampleCount
)sizeX
- the number of affected rows (multiple of the block size, ≥0, ≤sampleCount-startX
)sizeY
- the number of affected columns (multiple of the block size, ≥0, ≤sampleCount-startY
)heights
- the height values to setstride
- stride between consecutive rows inheights
(in floats)allocator
- for temporary allocations (not null)cosThresholdAngle
- cosine of the threshold angle (default=0.996195)
-