|
@@ -21,6 +21,7 @@
|
|
|
#include <Jolt/Physics/Collision/ActiveEdges.h>
|
|
|
#include <Jolt/Physics/Collision/CollisionDispatch.h>
|
|
|
#include <Jolt/Physics/Collision/SortReverseAndStore.h>
|
|
|
+#include <Jolt/Physics/Collision/CollideSoftBodyVerticesVsTriangles.h>
|
|
|
#include <Jolt/Core/Profiler.h>
|
|
|
#include <Jolt/Core/StringTools.h>
|
|
|
#include <Jolt/Core/StreamIn.h>
|
|
@@ -1796,7 +1797,7 @@ private:
|
|
|
};
|
|
|
|
|
|
template <class Visitor>
|
|
|
-JPH_INLINE void HeightFieldShape::WalkHeightField(Visitor &ioVisitor) const
|
|
|
+void HeightFieldShape::WalkHeightField(Visitor &ioVisitor) const
|
|
|
{
|
|
|
DecodingContext ctx(this);
|
|
|
ctx.WalkHeightField(ioVisitor);
|
|
@@ -1942,9 +1943,50 @@ void HeightFieldShape::CollidePoint(Vec3Arg inPoint, const SubShapeIDCreator &in
|
|
|
// A height field doesn't have volume, so we can't test insideness
|
|
|
}
|
|
|
|
|
|
-void HeightFieldShape::CollideSoftBodyVertices(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, SoftBodyVertex *ioVertices, uint inNumVertices, float inDeltaTime, Vec3Arg inDisplacementDueToGravity, int inCollidingShapeIndex) const
|
|
|
+void HeightFieldShape::CollideSoftBodyVertices(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, SoftBodyVertex *ioVertices, uint inNumVertices, [[maybe_unused]] float inDeltaTime, [[maybe_unused]] Vec3Arg inDisplacementDueToGravity, int inCollidingShapeIndex) const
|
|
|
{
|
|
|
- sCollideSoftBodyVerticesUsingRayCast(*this, inCenterOfMassTransform, inScale, ioVertices, inNumVertices, inDeltaTime, inDisplacementDueToGravity, inCollidingShapeIndex);
|
|
|
+ JPH_PROFILE_FUNCTION();
|
|
|
+
|
|
|
+ struct Visitor : public CollideSoftBodyVerticesVsTriangles
|
|
|
+ {
|
|
|
+ using CollideSoftBodyVerticesVsTriangles::CollideSoftBodyVerticesVsTriangles;
|
|
|
+
|
|
|
+ JPH_INLINE bool ShouldAbort() const
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ JPH_INLINE bool ShouldVisitRangeBlock([[maybe_unused]] int inStackTop) const
|
|
|
+ {
|
|
|
+ return mDistanceStack[inStackTop] < mClosestDistanceSq;
|
|
|
+ }
|
|
|
+
|
|
|
+ JPH_INLINE int VisitRangeBlock(Vec4Arg inBoundsMinX, Vec4Arg inBoundsMinY, Vec4Arg inBoundsMinZ, Vec4Arg inBoundsMaxX, Vec4Arg inBoundsMaxY, Vec4Arg inBoundsMaxZ, UVec4 &ioProperties, int inStackTop)
|
|
|
+ {
|
|
|
+ // Get distance to vertex
|
|
|
+ Vec4 dist_sq = AABox4DistanceSqToPoint(mLocalPosition, inBoundsMinX, inBoundsMinY, inBoundsMinZ, inBoundsMaxX, inBoundsMaxY, inBoundsMaxZ);
|
|
|
+
|
|
|
+ // Sort so that highest values are first (we want to first process closer hits and we process stack top to bottom)
|
|
|
+ return SortReverseAndStore(dist_sq, mClosestDistanceSq, ioProperties, &mDistanceStack[inStackTop]);
|
|
|
+ }
|
|
|
+
|
|
|
+ JPH_INLINE void VisitTriangle([[maybe_unused]] uint inX, [[maybe_unused]] uint inY, [[maybe_unused]] uint inTriangle, Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2)
|
|
|
+ {
|
|
|
+ ProcessTriangle(inV0, inV1, inV2);
|
|
|
+ }
|
|
|
+
|
|
|
+ float mDistanceStack[cStackSize];
|
|
|
+ };
|
|
|
+
|
|
|
+ Visitor visitor(inCenterOfMassTransform, inScale);
|
|
|
+
|
|
|
+ for (SoftBodyVertex *v = ioVertices, *sbv_end = ioVertices + inNumVertices; v < sbv_end; ++v)
|
|
|
+ if (v->mInvMass > 0.0f)
|
|
|
+ {
|
|
|
+ visitor.StartVertex(*v);
|
|
|
+ WalkHeightField(visitor);
|
|
|
+ visitor.FinishVertex(*v, inCollidingShapeIndex);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void HeightFieldShape::sCastConvexVsHeightField(const ShapeCast &inShapeCast, const ShapeCastSettings &inShapeCastSettings, const Shape *inShape, Vec3Arg inScale, [[maybe_unused]] const ShapeFilter &inShapeFilter, Mat44Arg inCenterOfMassTransform2, const SubShapeIDCreator &inSubShapeIDCreator1, const SubShapeIDCreator &inSubShapeIDCreator2, CastShapeCollector &ioCollector)
|