// Request Games © All rights reserved // Source/TengriPlatformer/Movement/Collision/TengriCollisionResolver.h #pragma once #include "CoreMinimal.h" #include "Kismet/BlueprintFunctionLibrary.h" #include "TengriPlatformer/Domains/Movement/Config/TengriMovementConfig.h" #include "TengriPlatformer/Domains/Movement/Collision/TengriSweepResult.h" #include "TengriCollisionResolver.generated.h" class UCapsuleComponent; /** * Static collision resolution utilities for Tengri Movement System. * Handles swept collision, wall sliding, step-up, and ground snapping. */ UCLASS() class TENGRIPLATFORMER_API UTengriCollisionResolver : public UBlueprintFunctionLibrary { GENERATED_BODY() public: // ════════════════════════════════════════════════════════════════════ // MAIN RESOLUTION // ════════════════════════════════════════════════════════════════════ /** * Resolve movement with collision: slide along walls, step up obstacles. * @param WorldContext - Object providing world context * @param StartLocation - Starting position * @param DesiredDelta - Desired movement this frame * @param Capsule - Collision capsule * @param Thresholds - Surface classification thresholds * @param MaxStepHeight - Maximum step-up height * @param MaxIterations - Maximum slide iterations * @return Final position and collision info */ static FTengriSweepResult ResolveMovement( const UObject* WorldContext, const FVector& StartLocation, const FVector& DesiredDelta, const UCapsuleComponent* Capsule, const FSurfaceThresholds& Thresholds, float MaxStepHeight, int32 MaxIterations ); // ════════════════════════════════════════════════════════════════════ // PRIMITIVES // ════════════════════════════════════════════════════════════════════ /** Perform a simple capsule sweep from Start to End */ static FTengriSweepResult PerformSweep( const UObject* WorldContext, const FVector& Start, const FVector& End, const UCapsuleComponent* Capsule ); /** Attempt to step up over an obstacle */ static bool StepUp( const UObject* WorldContext, const FVector& StartLocation, const FVector& DesiredDelta, const FHitResult& ImpactHit, const UCapsuleComponent* Capsule, float MaxStepHeight, FVector& OutLocation ); /** Snap character to ground surface below */ static bool SnapToGround( const UObject* WorldContext, const UCapsuleComponent* Capsule, float SnapDistance, const FSurfaceThresholds& Thresholds, FVector& OutLocation, FHitResult& OutHit ); // ════════════════════════════════════════════════════════════════════ // VELOCITY MATH // ════════════════════════════════════════════════════════════════════ /** Remove velocity component going into the surface */ static FVector ClipVelocity(const FVector& Velocity, const FVector& Normal); /** Project velocity along surface, preserving magnitude */ static FVector ProjectVelocity(const FVector& Velocity, const FVector& Normal); };