Class that constructs a HeightFieldShape.
More...
#include <HeightFieldShape.h>
Class that constructs a HeightFieldShape.
◆ HeightFieldShapeSettings() [1/2]
HeightFieldShapeSettings::HeightFieldShapeSettings |
( |
| ) |
|
|
default |
Default constructor for deserialization.
◆ HeightFieldShapeSettings() [2/2]
Create a height field shape of inSampleCount * inSampleCount vertices. The height field is a surface defined by: inOffset + inScale * (x, inSamples[y * inSampleCount + x], y). where x and y are integers in the range x and y e [0, inSampleCount - 1]. inSampleCount: inSampleCount / mBlockSize must be minimally 2 and a power of 2 is the most efficient in terms of performance and storage. inSamples: inSampleCount^2 vertices. inMaterialIndices: (inSampleCount - 1)^2 indices that index into inMaterialList.
◆ CalculateBitsPerSampleForError()
uint32 HeightFieldShapeSettings::CalculateBitsPerSampleForError |
( |
float |
inMaxError | ) |
const |
Given mBlockSize, mSampleCount and mHeightSamples, calculate the amount of bits needed to stay below absolute error inMaxError
- Parameters
-
inMaxError | Maximum allowed error in mHeightSamples after compression (note that this does not take mScale.Y into account) |
- Returns
- Needed bits per sample in the range [1, 8].
◆ Create()
Create a shape according to the settings specified by this object.
Implements ShapeSettings.
◆ DetermineMinAndMaxSample()
void HeightFieldShapeSettings::DetermineMinAndMaxSample |
( |
float & |
outMinValue, |
|
|
float & |
outMaxValue, |
|
|
float & |
outQuantizationScale |
|
) |
| const |
Determine the minimal and maximal value of mHeightSamples (will ignore cNoCollisionValue)
- Parameters
-
outMinValue | The minimal value of mHeightSamples or FLT_MAX if no samples have collision |
outMaxValue | The maximal value of mHeightSamples or -FLT_MAX if no samples have collision |
outQuantizationScale | (value - outMinValue) * outQuantizationScale quantizes a height sample to 16 bits |
◆ mActiveEdgeCosThresholdAngle
float HeightFieldShapeSettings::mActiveEdgeCosThresholdAngle = 0.996195f |
Cosine of the threshold angle (if the angle between the two triangles is bigger than this, the edge is active, note that a concave edge is always inactive). Setting this value too small can cause ghost collisions with edges, setting it too big can cause depenetration artifacts (objects not depenetrating quickly). Valid ranges are between cos(0 degrees) and cos(90 degrees). The default value is cos(5 degrees).
◆ mBitsPerSample
uint32 HeightFieldShapeSettings::mBitsPerSample = 8 |
How many bits per sample to use to compress the height field. Can be in the range [1, 8]. Note that each sample is compressed relative to the min/max value of its block of mBlockSize * mBlockSize pixels so the effective precision is higher. Also note that increasing mBlockSize saves more memory than reducing the amount of bits per sample.
◆ mBlockSize
uint32 HeightFieldShapeSettings::mBlockSize = 2 |
The heightfield is divided in blocks of mBlockSize * mBlockSize * 2 triangles and the acceleration structure culls blocks only, bigger block sizes reduce memory consumption but also reduce query performance. Sensible values are [2, 8], does not need to be a power of 2. Note that at run-time we'll perform one more grid subdivision, so the effective block size is half of what is provided here.
◆ mHeightSamples
Array<float> HeightFieldShapeSettings::mHeightSamples |
An array of mSampleCount^2 height samples. Samples are stored in row major order, so the sample at (x, y) is at index y * mSampleCount + x.
◆ mMaterialIndices
Array<uint8> HeightFieldShapeSettings::mMaterialIndices |
An array of (mSampleCount - 1)^2 material indices.
◆ mMaterials
The materials of square at (x, y) is: mMaterials[mMaterialIndices[x + y * (mSampleCount - 1)]].
◆ mMaterialsCapacity
uint32 HeightFieldShapeSettings::mMaterialsCapacity = 0 |
When bigger than mMaterials.size() the internal material list will be preallocated to support this number of materials. This avoids reallocations when calling HeightFieldShape::SetMaterials with new materials later.
◆ mMaxHeightValue
float HeightFieldShapeSettings::mMaxHeightValue = -cLargeFloat |
Artificial maximum value of mHeightSamples, used for compression and can be used to update the terrain after creating with higher height values. If there are any higher values in mHeightSamples, this value will be ignored.
◆ mMinHeightValue
float HeightFieldShapeSettings::mMinHeightValue = cLargeFloat |
Artificial minimal value of mHeightSamples, used for compression and can be used to update the terrain after creating with lower height values. If there are any lower values in mHeightSamples, this value will be ignored.
◆ mOffset
The height field is a surface defined by: mOffset + mScale * (x, mHeightSamples[y * mSampleCount + x], y). where x and y are integers in the range x and y e [0, mSampleCount - 1].
◆ mSampleCount
uint32 HeightFieldShapeSettings::mSampleCount = 0 |
◆ mScale
The documentation for this class was generated from the following files: