The result with Chaos is not wrong, rather it returns a correct correction vector, that vector is perfectly horizontal to the teleport buried against the landscape mesh.
Therefore, teleportation will fail.
The following workarounds provide developer-friendly results. This code is almost identical to the hack in GJKContactPointImp.
template <typename QueryGeomType> bool FHeightField::OverlapGeomImp(const QueryGeomType& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD) const ... TTriangle<FReal> TriangleConvex(A, B, C); if (InnerMTD) { if (bOneSidedHeightField) // workaround begins { // This code is similar to the hack in GJKContactPointImp FReal Penetration = 0; TVec3<FReal> ClosestA(0); TVec3<FReal> ClosestB(0); TVec3<FReal> Normal(0); const TAABB<FReal, 3> Bounds = QueryGeom.BoundingBox(); const float ApproximateSizeOfObject = Bounds.Extents()[Bounds.LargestAxis()]; const float ApproximateDistToObject = FVec3::DistSquared(QueryTM.GetLocation(), A); const float SweepLength = ApproximateSizeOfObject + ApproximateDistToObject; const FVec3 TriNormal = Offset.GetUnsafeNormal(); const FRigidTransform3 QueryStartTM(QueryTM.GetLocation() + TriNormal * SweepLength, QueryTM.GetRotation()); if (GJKRaycast2(TriangleConvex, QueryGeom, QueryStartTM, -TriNormal, SweepLength, Penetration, ClosestB, Normal, 0.f, true)) { // Use Deepest MTD. if (Penetration > InnerMTD->Penetration) { InnerMTD->Penetration = Penetration; InnerMTD->Normal = Normal; } return true; } } else // workaround ends { TVec3<FReal> TriangleNormal(0); FReal Penetration = 0; TVec3<FReal> ClosestA(0); TVec3<FReal> ClosestB(0); int32 ClosestVertexIndexA, ClosestVertexIndexB; if (GJKPenetration(TriangleConvex, QueryGeom, QueryTM, Penetration, ClosestA, ClosestB, TriangleNormal, ClosestVertexIndexA, ClosestVertexIndexB, Thickness, 0.0f, TVector<FReal, 3>(0, 0, -1))) { // Use Deepest MTD. if (Penetration > InnerMTD->Penetration) { InnerMTD->Penetration = Penetration; InnerMTD->Normal = TriangleNormal; } return true; } } return false; }
[Image Removed][Image Removed]
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-119029 in the post.
0 |
Component | UE - Simulation - Physics |
---|---|
Affects Versions | 4.26-chaos, 5.1 |
Created | Jun 25, 2021 |
---|---|
Resolved | May 19, 2023 |
Updated | Aug 16, 2023 |