#include "World/DescentShear.h" #include "World/DescentSDF.h" #include "Core/DescentMath.h" #include "Core/Tuning/DescentTune_World.h" namespace WTune = Descent::Tune::World; namespace Descent::World { FVector FDescentShear::VelocityAt(const FVector& P) { const double H = P.Z - WTune::ShearBaseZ; if (H <= 0.0) { return FVector::ZeroVector; } // Horizontal distance from the canyon's centreline (the canyon runs X -250..850 along Yc(X)); beyond its ends // the nearest end point stands in for the polyline. const double Xc = FMath::Clamp(P.X, WTune::CanyonX0, WTune::CanyonX1); const double Yc = FDescentSDF::CanyonCentre(Xc); const double Dx = Xc - P.X, Dy = Yc - P.Y; const double Dist = FMath::Sqrt(Dx * Dx + Dy * Dy); const double A = Dist - WTune::ShearLatOffset; const double S = FMath::Clamp(H / WTune::ShearVertRamp, 0.0, WTune::ShearMaxPart) + FMath::Clamp(A / WTune::ShearLatRamp, 0.0, WTune::ShearMaxPart); FVector Dir(0.0, 0.0, -1.0); if (Dist > 1e-3) { Dir = FVector(Dx / Dist * WTune::ShearToward, Dy / Dist * WTune::ShearToward, -WTune::ShearDown).GetSafeNormal(); } return Dir * S; } bool FDescentShear::IsWarning(const FVector& P) { return P.Z >= WTune::ShearWarnZ; } }