Class HeightFieldShapeSettings

All Implemented Interfaces:
ConstHeightFieldShapeSettings, ConstJoltPhysicsObject, ConstSerializableObject, ConstShapeSettings, RefTarget, AutoCloseable, Comparable<JoltPhysicsObject>

public class HeightFieldShapeSettings extends ShapeSettings implements ConstHeightFieldShapeSettings
Settings used to construct a HeightFieldShape.
  • Constructor Details

    • HeightFieldShapeSettings

      public HeightFieldShapeSettings()
      Instantiate the default settings.
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(float[] samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, length≥4, unaffected)
      offsetX - the desired X offset
      offsetY - the desired Y offset
      offsetZ - the desired Z offset
      scaleX - the desired scale factor on the local X axis
      scaleY - the desired scale factor on the local Y axis
      scaleZ - the desired scale factor on the local Z axis
      sampleCount - the number of height values along each edge (≥2*blockSize)
      materialIndices - a material index for each sample (default=null)
      materialList - the list of materials
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(float[] samples, Vec3Arg offset, Vec3Arg scale, int sampleCount)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, length≥4, unaffected)
      offset - (not null, unaffected)
      scale - (not null, unaffected)
      sampleCount - the number of height values along each edge (≥2*blockSize)
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(float[] samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, length≥4, unaffected)
      offset - (not null, unaffected)
      scale - (not null, unaffected)
      sampleCount - the number of height values along each edge (≥2*blockSize)
      materialIndices - a material index for each sample (default=null)
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(float[] samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, length≥4, unaffected)
      offset - (not null, unaffected)
      scale - (not null, unaffected)
      sampleCount - the number of height values along each edge (≥2*blockSize)
      materialIndices - a material index for each sample (default=null)
      materialList - the list of materials
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(FloatBuffer samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, capacity≥4, unaffected)
      offsetX - the desired X offset
      offsetY - the desired Y offset
      offsetZ - the desired Z offset
      scaleX - the desired scale factor on the local X axis
      scaleY - the desired scale factor on the local Y axis
      scaleZ - the desired scale factor on the local Z axis
      sampleCount - the number of height values along each edge (≥2*blockSize)
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(FloatBuffer samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, capacity≥4, unaffected)
      offsetX - the desired X offset
      offsetY - the desired Y offset
      offsetZ - the desired Z offset
      scaleX - the desired scale factor on the local X axis
      scaleY - the desired scale factor on the local Y axis
      scaleZ - the desired scale factor on the local Z axis
      sampleCount - the number of height values along each edge (≥2*blockSize)
      materialIndices - a material index for each sample (default=null)
      materialList - the list of materials
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, capacity≥4, unaffected)
      offset - (not null, unaffected)
      scale - (not null, unaffected)
      sampleCount - the number of height values along each edge (≥2*blockSize)
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, capacity≥4, unaffected)
      offset - (not null, unaffected)
      scale - (not null, unaffected)
      sampleCount - the number of height values along each edge (≥2*blockSize)
      materialIndices - a material index for each sample (default=null)
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList)
      Instantiate settings for the specified samples.
      Parameters:
      samples - array of height values (not null, capacity≥4, unaffected)
      offset - (not null, unaffected)
      scale - (not null, unaffected)
      sampleCount - the number of height values along each edge (≥2*blockSize)
      materialIndices - a material index for each sample (default=null)
      materialList - the list of materials
    • HeightFieldShapeSettings

      public HeightFieldShapeSettings(ConstHeightFieldShapeSettings original)
      Instantiate a copy of the specified settings.
      Parameters:
      original - the settings to copy (not null, unaffected)
  • Method Details

    • getMaterials

      public PhysicsMaterialList getMaterials()
      Access the material list. (native attribute: mMaterials)
      Returns:
      a new JVM object with the pre-existing native object assigned
    • set

      public void set(ConstHeightFieldShapeSettings source)
      Copy the argument to the current settings.
      Parameters:
      source - the settings to copy (not null, unaffected)
    • setActiveEdgeCosThresholdAngle

      public void setActiveEdgeCosThresholdAngle(float cosine)
      Alter the active-edge threshold angle. (native attribute: mActiveEdgeCosThresholdAngle)
      Parameters:
      cosine - the cosine of the desired angle (default=0.996195)
    • setBitsPerSample

      public void setBitsPerSample(int numBits)
      Alter the number of bits per sample to use during compression. (native attribute: mBitsPerSample)
      Parameters:
      numBits - the number of bits (≥1, ≤16, default=8)
    • setBlockSize

      public void setBlockSize(int numRows)
      Alter the block size. (native attribute: mBlockSize)

      For culling purposes, the height field is organized in blocks of 2 * mBlockSize * mBlockSize triangles.

      Sensible values range from 2 to 8.

      Parameters:
      numRows - the desired block size (in rows, default=2)
    • setHeightSample

      public void setHeightSample(int sampleIndex, float height)
      Alter the height of the specified sample.
      Parameters:
      sampleIndex - the array index (≥0, <sampleCount^2)
      height - the desired height, or cNoCollisionValue for no collision
    • setHeightSample

      public void setHeightSample(int x, int y, float height)
      Alter the height of the specified sample.
      Parameters:
      x - the X index of the sample (≥0, <sampleCount)
      y - the Y index of the sample (≥0, <sampleCount)
      height - the desired height, or cNoCollisionValue for no collision
    • setMaterial

      public void setMaterial(int materialIndex, PhysicsMaterialRef reference)
      Alter the material reference for the specified list index.
      Parameters:
      materialIndex - the list index at which to put the reference (≥0)
      reference - the reference to store (not null)
    • setMaterialIndex

      public void setMaterialIndex(int squareIndex, int materialIndex)
      Alter the material index of the specified square.
      Parameters:
      squareIndex - the index of the square (≥0, <(sampleCount-1)^2)
      materialIndex - the desired material index
    • setMaterialIndex

      public void setMaterialIndex(int x, int y, int materialIndex)
      Alter the material index for the specified square.
      Parameters:
      x - the X index of the square (≥0, <sampleCount-1)
      y - the Y index of the square (≥0, <sampleCount-1)
      materialIndex - the desired index into the material list (≥0)
    • setMaterials

      public void setMaterials(PhysicsMaterialList list)
      Replace the existing material list with a copy of the specified list. (native attribute: mMaterials)
      Parameters:
      list - the desired material for each material index
    • setMaterialsCapacity

      public void setMaterialsCapacity(int numRefs)
      Alter the artificial minimum capacity for the created shape's material list. (native attribute: mMaterialsCapacity)
      Parameters:
      numRefs - the desired minimum capacity (in refs, default=0)
    • setMaxHeightValue

      public void setMaxHeightValue(float maxHeight)
      Alter the artificial maximum height. (native attribute: mMaxHeightValue)
      Parameters:
      maxHeight - the desired height value (default=-1e15)
    • setMinHeightValue

      public void setMinHeightValue(float minHeight)
      Alter the artificial minimum height. (native attribute: mMinHeightValue)
      Parameters:
      minHeight - the desired height value (default=1e15)
    • setOffset

      public void setOffset(Vec3Arg offset)
      Alter the offset of the first sample. (native attribute: mOffset)
      Parameters:
      offset - the desired offset vector (not null, unaffected, default=(0,0,0))
    • setSampleCount

      public void setSampleCount(int sampleCount)
      Alter the number of samples along each dimension. (native attribute: mSampleCount)
      Parameters:
      sampleCount - the desired number of samples (≥0, default=0)
    • setScale

      public void setScale(Vec3Arg scale)
      Alter the scale factors. (native attribute: mScale)
      Parameters:
      scale - the desired scale factors (not null, unaffected, default=(1,1,1))
    • calculateBitsPerSampleForError

      public int calculateBitsPerSampleForError(float maxError)
      Calculate the minimum bits per sample that will provide the specified error tolerance. The settings are unaffected.
      Specified by:
      calculateBitsPerSampleForError in interface ConstHeightFieldShapeSettings
      Parameters:
      maxError - the allowable tolerance
      Returns:
      the (hypothetical) bits per sample
    • countHeights

      public int countHeights()
      Count the height samples, including cNoCollisionValue. The settings are unaffected.
      Specified by:
      countHeights in interface ConstHeightFieldShapeSettings
      Returns:
      the actual number of samples in the array (≥0)
    • countMaterials

      public int countMaterials()
      Count the references in the material list, including null refs. The settings are unaffected.
      Specified by:
      countMaterials in interface ConstHeightFieldShapeSettings
      Returns:
      the actual number of references in the list (≥0)
    • countSquares

      public int countSquares()
      Count the squares. The settings are unaffected.
      Specified by:
      countSquares in interface ConstHeightFieldShapeSettings
      Returns:
      the actual number of material indices in the array (≥0)
    • determineMinAndMaxSample

      public void determineMinAndMaxSample(float[] storeMin, float[] storeMax, float[] storeQuantScale)
      Calculate 3 quantization parameters of the current settings. The settings are unaffected.
      Specified by:
      determineMinAndMaxSample in interface ConstHeightFieldShapeSettings
      Parameters:
      storeMin - storage for the minimum height (ignoring cNoCollisionValue) or MIN_VALUE if no samples have collision
      storeMax - storage for the maximum height (ignoring cNoCollisionValue) or MAX_VALUE if no samples have collision
      storeQuantScale - storage for the quantization scale factor
    • getActiveEdgeCosThresholdAngle

      public float getActiveEdgeCosThresholdAngle()
      Return the cosine of the active-edge threshold angle. The settings are unaffected. (native attribute: mActiveEdgeCosThresholdAngle)
      Specified by:
      getActiveEdgeCosThresholdAngle in interface ConstHeightFieldShapeSettings
      Returns:
      the cosine
    • getBitsPerSample

      public int getBitsPerSample()
      Return the number of bits per sample to use during compression. The settings are unaffected. (native attribute: mBitsPerSample)
      Specified by:
      getBitsPerSample in interface ConstHeightFieldShapeSettings
      Returns:
      the number of bits (≥1, ≤16)
    • getBlockSize

      public int getBlockSize()
      Return the block size. The settings are unaffected. (native attribute: mBlockSize)

      For culling purposes, the height field is organized in blocks of 2 * mBlockSize * mBlockSize triangles.

      Sensible values range from 2 to 8.

      Specified by:
      getBlockSize in interface ConstHeightFieldShapeSettings
      Returns:
      the block size (in rows)
    • getHeightSample

      public float getHeightSample(int sampleIndex)
      Return the height of the specified sample. The settings are unaffected.
      Specified by:
      getHeightSample in interface ConstHeightFieldShapeSettings
      Parameters:
      sampleIndex - the array index (≥0, <sampleCount^2)
      Returns:
      the sample height or cNoCollisionValue
    • getHeightSample

      public float getHeightSample(int x, int y)
      Return the height of the specified sample. The settings are unaffected.
      Specified by:
      getHeightSample in interface ConstHeightFieldShapeSettings
      Parameters:
      x - the X index of the sample (≥0, <sampleCount)
      y - the Y index of the sample (≥0, <sampleCount)
      Returns:
      the sample height or cNoCollisionValue
    • getMaterialIndex

      public int getMaterialIndex(int squareIndex)
      Return the material index for the specified square. The settings are unaffected.
      Specified by:
      getMaterialIndex in interface ConstHeightFieldShapeSettings
      Parameters:
      squareIndex - the index of the square (≥0, <(sampleCount-1)^2)
      Returns:
      an index into the material list (≥0)
    • getMaterialIndex

      public int getMaterialIndex(int x, int y)
      Return the material index for the specified square. The settings are unaffected.
      Specified by:
      getMaterialIndex in interface ConstHeightFieldShapeSettings
      Parameters:
      x - the X index of the square (≥0, <sampleCount-1)
      y - the Y index of the square (≥0, <sampleCount-1)
      Returns:
      an index into the material list (≥0)
    • getMaterialRef

      public PhysicsMaterialRefC getMaterialRef(int materialIndex)
      Return a reference to the material for the specified material index.
      Specified by:
      getMaterialRef in interface ConstHeightFieldShapeSettings
      Parameters:
      materialIndex - the index in the local table (≥0)
      Returns:
      a new counted reference to the existing material
    • getMaterialRef

      public PhysicsMaterialRefC getMaterialRef(int x, int y)
      Return a reference to the material for the specified square.
      Specified by:
      getMaterialRef in interface ConstHeightFieldShapeSettings
      Parameters:
      x - the X index of the square (≥0, <sampleCount-1)
      y - the Y index of the square (≥0, <sampleCount-1)
      Returns:
      a new counted reference to the existing material
    • getMaterialRefForSquare

      public PhysicsMaterialRefC getMaterialRefForSquare(int squareIndex)
      Return a reference to the material for the specified square.
      Specified by:
      getMaterialRefForSquare in interface ConstHeightFieldShapeSettings
      Parameters:
      squareIndex - the index of the square (≥0, <(sampleCount-1)^2)
      Returns:
      a new counted reference to the existing material
    • getMaterialsCapacity

      public int getMaterialsCapacity()
      Return the artificial minimum capacity for the created shape's material list. The settings are unaffected. (native attribute: mMaterialsCapacity)
      Specified by:
      getMaterialsCapacity in interface ConstHeightFieldShapeSettings
      Returns:
      the capacity (in refs)
    • getMaxHeightValue

      public float getMaxHeightValue()
      Return the artificial maximum height. The settings are unaffected. (native attribute: mMaxHeightValue)
      Specified by:
      getMaxHeightValue in interface ConstHeightFieldShapeSettings
      Returns:
      the height value
    • getMinHeightValue

      public float getMinHeightValue()
      Return the artificial minimum height. The settings are unaffected. (native attribute: mMinHeightValue)
      Specified by:
      getMinHeightValue in interface ConstHeightFieldShapeSettings
      Returns:
      the height value
    • getOffset

      public Vec3 getOffset()
      Copy the offset of the first sample. The settings are unaffected. (native attribute: mOffset)
      Specified by:
      getOffset in interface ConstHeightFieldShapeSettings
      Returns:
      a new offset vector
    • getSampleCount

      public int getSampleCount()
      Count the samples along each edge. The settings are unaffected. (native attribute: mSampleCount)
      Specified by:
      getSampleCount in interface ConstHeightFieldShapeSettings
      Returns:
      the number of samples (≥0)
    • getScale

      public Vec3 getScale()
      Copy the scale factors. The settings are unaffected. (native attribute: mScale)
      Specified by:
      getScale in interface ConstHeightFieldShapeSettings
      Returns:
      a new scaling vector