Quellcode durchsuchen

Added HeightFieldShape::GetMinHeightValue/GetMaxHeightValue

Jorrit Rouwe vor 1 Jahr
Ursprung
Commit
5c9d3b011a
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 5 1
      Jolt/Physics/Collision/Shape/HeightFieldShape.h

+ 5 - 1
Jolt/Physics/Collision/Shape/HeightFieldShape.h

@@ -181,6 +181,10 @@ public:
 	/// 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]
@@ -197,7 +201,7 @@ public:
 	/// @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).