فهرست منبع

Added HeightFieldShape::GetSubShapeCoordinates

Updated release notes
Jorrit Rouwe 11 ماه پیش
والد
کامیت
d5480bd958

+ 4 - 0
Docs/APIChanges.md

@@ -4,6 +4,10 @@ This document lists all breaking API changes by date and by release tag. Note th
 
 Changes that make some state saved through SaveBinaryState from a prior version of the library unreadable by the new version is marked as *SBS*. See [Saving Shapes](https://jrouwe.github.io/JoltPhysics/#saving-shapes) for further information.
 
+## Changes between v5.1.0 and latest
+
+* 20240823 - Added virtual function Shape::GetLeafShape. If you have custom shapes, you may need to override this function and provide an implementation. (d7f08b83670ea6d0842e231f50ad2a175f56f949)
+
 ## Changes between v5.0.0 and v5.1.0
 
 * 20240811 - Added cmake options to toggle exception-handling and RTTI. CPP_EXCEPTIONS_ENABLED enables exceptions, CPP_RTTI_ENABLED enables RTTI. Before this change RTTI was off for MSVC and on for other compilers. Exceptions were on for all builds. You may need to set these options if your build relies on these C++ features. (760974d733ed24ea268a3bb9a8ef391b8ac503c7)

+ 3 - 0
Docs/ReleaseNotes.md

@@ -7,6 +7,9 @@ For breaking API changes see [this document](https://github.com/jrouwe/JoltPhysi
 ### New functionality
 
 * Added PlaneShape. An infinite plane. Negative half space is considered solid.
+* Use MeshShapeSettings::mPerTriangleUserData at about 25% memory increase to get per triangle user data through MeshShape::GetTriangleUserData
+* Added Shape::GetLeafShape function to be able to get a leaf shape given a sub shape ID
+* Added HeightFieldShape::GetSubShapeCoordinates to get the triangle coordinates of a particular sub shape ID
 
 ### Bug fixes
 

+ 5 - 0
Jolt/Physics/Collision/Shape/HeightFieldShape.cpp

@@ -1437,6 +1437,11 @@ void HeightFieldShape::DecodeSubShapeID(const SubShapeID &inSubShapeID, uint &ou
 	outY = id / mSampleCount;
 }
 
+void HeightFieldShape::GetSubShapeCoordinates(const SubShapeID &inSubShapeID, uint &outX, uint &outY, uint &outTriangleIndex) const
+{
+	DecodeSubShapeID(inSubShapeID, outX, outY, outTriangleIndex);
+}
+
 const PhysicsMaterial *HeightFieldShape::GetMaterial(const SubShapeID &inSubShapeID) const
 {
 	// Decode ID

+ 7 - 0
Jolt/Physics/Collision/Shape/HeightFieldShape.h

@@ -193,6 +193,13 @@ 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;
 
+	/// Returns the coordinates of the triangle that a sub shape ID represents
+	/// @param inSubShapeID The sub shape ID to decode
+	/// @param outX X coordinate of the triangle (in the range [0, mSampleCount - 2])
+	/// @param outY Y coordinate of the triangle (in the range [0, mSampleCount - 2])
+	/// @param outTriangleIndex Triangle within the quad (0 = lower triangle or 1 = upper triangle)
+	void							GetSubShapeCoordinates(const SubShapeID &inSubShapeID, uint &outX, uint &outY, uint &outTriangleIndex) 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; }