Skip to content

Commit

Permalink
Added HeightFieldShape::GetMinHeightValue/GetMaxHeightValue
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouwe committed Apr 7, 2024
1 parent 047c7f0 commit 5c9d3b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Jolt/Physics/Collision/Shape/HeightFieldShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ class JPH_EXPORT HeightFieldShape final : public Shape
/// When there is no surface position (because of a hole or because the point is outside the heightfield) the function will return false.
bool ProjectOntoSurface(Vec3Arg inLocalPosition, Vec3 &outSurfacePosition, SubShapeID &outSubShapeID) const;

/// Get the range of height values that this height field can encode. Can be used to determine the allowed range when setting the height values with SetHeights.
float GetMinHeightValue() const { return mOffset.GetY(); }
float GetMaxHeightValue() const { return mOffset.GetY() + mScale.GetY() * HeightFieldShapeConstants::cMaxHeightValue16; }

/// Get the height values of a block of data.
/// Note that the height values are decompressed so will be slightly different from what the shape was originally created with.
/// @param inX Start X position, must be a multiple of mBlockSize and in the range [0, mSampleCount - 1]
Expand All @@ -197,7 +201,7 @@ class JPH_EXPORT HeightFieldShape final : public Shape
/// @param inY Start Y position, must be a multiple of mBlockSize and in the range [0, mSampleCount - 1]
/// @param inSizeX Number of samples in X direction, must be a multiple of mBlockSize and in the range [0, mSampleCount - inX]
/// @param inSizeY Number of samples in Y direction, must be a multiple of mBlockSize and in the range [0, mSampleCount - inX]
/// @param inHeights The new height values to set, must be an array of inSizeX * inSizeY floats, can be cNoCollisionValue.
/// @param inHeights The new height values to set, must be an array of inSizeX * inSizeY floats, can be cNoCollisionValue. Values outside of the range [GetMinHeightValue(), GetMaxHeightValue()] will be clamped.
/// @param inHeightsStride Stride in floats between two consecutive rows of outHeights.
/// @param inAllocator Allocator to use for temporary memory
/// @param inActiveEdgeCosThresholdAngle 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).
Expand Down

0 comments on commit 5c9d3b0

Please sign in to comment.