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 TypeMethodDescriptionintReturn 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.booleanisNoCollision(int x, int y) Test whether the shape has a hole at the specified sample.booleanprojectOntoSurface(Vec3Arg localLocation, Vec3 storeSurfaceLocation, int[] storeSubShapeId) Project the specified location along the Y axis to find a location on the surface.voidsetHeights(int startX, int startY, int sizeX, int sizeY, FloatBuffer heights, int stride, TempAllocator allocator) Alter the heights for a rectangular sub-matrix.voidsetHeights(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, scaleShape, setEmbedded, setVirtualAddressAsCoOwner, sRestoreFromBinaryState, toRef, toRefCMethods 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
-
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:
trueif 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:
trueif 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)
-