2#include "Engine/Component/ArcadeGliderFlightModel.h"
3#include "Engine/Component/LogicComponent.h"
4#include "Engine/World/WindField.h"
7#include <glm/gtc/quaternion.hpp>
280 void tick(
double deltaTime )
override;
461 float hysteresis = 0.0f
473 glm::vec3 & outBodyForward,
474 float & outForwardAmount,
475 float & outRightAmount
492 const glm::vec3 & origin,
493 glm::vec3 & outHitPoint,
494 glm::vec3 & outHitNormal,
495 float & outHitFraction
500 glm::vec3
collideAndSlide(
const glm::vec3 & startPos,
const glm::vec3 & displacement );
Logic(Entities::Scene *owningScene)
Constructs a logic component owned by a scene.
Component that manages a physics rigid body for an entity.
bool areArmsSpread(const HandData &leftHand, const HandData &rightHand, float hysteresis=0.0f) const
glm::vec3 lastSafeLandingPosition_
Input::InputManager * inputManager_
static constexpr float DEBUG_LOG_INTERVAL
glm::vec3 collideAndSlide(const glm::vec3 &startPos, const glm::vec3 &displacement)
void resetGliderStateTo(GliderState state)
Resets velocity and persistent flight state, then sets the current movement state.
static constexpr float GRIP_THRESHOLD
void updateWalkingInput(float dt)
void tick(double deltaTime) override
Advances locomotion and writes the updated player position.
void beginPlay() override
Initializes runtime state when the owning actor begins play.
glm::vec3 getHeadForward() const
Returns the headset forward vector in world space.
const GliderConfig & getConfig() const
Returns the current glider tuning values.
bool sweepGround(const glm::vec3 &origin, glm::vec3 &outHitPoint, glm::vec3 &outHitNormal, float &outHitFraction) const
PhysicsBody * physicsBody_
bool drawImGui() override
Draws and edits glider state in the engine ImGui inspector.
bool handleFlightCollision(const glm::vec3 ¤tPos, glm::vec3 &desiredPos)
glm::vec3 buildGlideDirection(const HandData &leftHand, const HandData &rightHand, glm::vec3 &outBodyForward, float &outForwardAmount, float &outRightAmount) const
bool isEnabled() const
Returns whether locomotion processing is enabled.
glm::vec3 getHeadWorldPosition() const
Returns the headset world position.
Rendering::Headset * headset_
bool isFrozen() const
Returns whether movement is frozen.
bool rightStickSnapTurnArmed_
static constexpr float CAPSULE_TOTAL_HALF
Half of the complete capsule height, including one radius.
float getSpeed() const
Returns the magnitude of the current locomotion velocity.
static constexpr int MAX_SLIDE_ITERATIONS
static constexpr float SKIN_WIDTH
static constexpr bool IsUnique
This component type is unique per actor.
GliderState currentState_
GliderState getState() const
Returns the current movement state.
std::string getComponentName() const override
Returns the component registry name.
void setDebugLogging(bool enabled)
Enables or disables glider debug logging and debug drawing.
bool isDebugLogging() const
Returns whether glider debug logging and debug drawing are enabled.
ArcadeGliderState flightState_
static const char * stateToString(GliderState state)
Converts a glider state to a display string.
bool hasLastSafeLandingPosition_
PhysicsBody * getPhysicsBody() const
Returns the physics body controlled by this component.
void updateLastSafeLanding(const glm::vec3 &position, bool stableWalkableGround, float dt)
bool areHandsTucked(const HandData &leftHand, const HandData &rightHand) const
void setConfig(const GliderConfig &config)
Replaces the active glider tuning values.
const DebugSnapshot & getDebugSnapshot() const
Returns diagnostics from the most recent tick.
void endPlay() override
Stops component play and calls the base Logic lifecycle hook.
void setFrozen(bool frozen)
Freezes or unfreezes player movement.
void resetToLastSafeLanding()
void updateGlidingVelocity(const HandData &leftHand, const HandData &rightHand, float dt)
HandData getHandData(Input::Hand hand) const
World::WindSample lastWindSample_
static constexpr const char * ComponentName
Component registry name.
glm::vec3 getVelocity() const
Returns the current locomotion velocity.
static constexpr float CAPSULE_HALF_HEIGHT
Half of the cylinder section height used by glider sweep tests.
void setEnabled(bool enabled)
Enables or disables locomotion processing.
VrGlider(Entities::Scene *owningScene, Rendering::Headset *headset, Input::InputManager *inputManager, PhysicsBody *physicsBody)
Creates a VR glider locomotion component.
void teleportPlayer(const glm::vec3 &position)
DebugSnapshot debugSnapshot_
static constexpr float CAPSULE_RADIUS
Radius of the player capsule used by glider sweep tests.
~VrGlider() override=default
Destroys the component without owning the headset, input handler, or physics body.
float landingCheckpointTimer_
bool canStartGlidingFromWalking(const glm::vec3 ¤tPos, glm::vec3 &outTakeoffPos) const
ArcadeGliderTuning makeFlightTuning() const
glm::quat getHeadOrientation() const
Returns the headset world orientation.
bool bothGripsWerePressed_
GliderConfig & getConfig()
Returns mutable glider tuning values.
Owns scene entities, actor lifetime, and the scene graph root.
Owns the OpenXR session, XR swapchain, eye transforms, and per-frame XR submission state.
GliderState
Movement mode used by Engine::Components::VrGlider.
@ STALLED
Arms spread but speed is below the configured stall threshold.
@ FALLING
Airborne with gravity and horizontal momentum only.
@ WALKING
Grounded locomotion driven by the left thumbstick.
@ GLIDING
Arms spread; hand pose controls direction and climb or dive.
Persistent state carried between arcade glider simulation steps.
Stores the config values for the glider. Can be used to change the flight behavior of the glider move...
Diagnostics captured from the most recent tick() call.
float landingCheckpointTimer
Time accumulated toward saving the current landing checkpoint.
bool rightHandValid
True when the right-hand pose was valid.
bool leftTriggerPressed
True when the left trigger exceeds the configured grip threshold.
glm::vec3 headWorldPosition
Headset world position.
glm::vec3 groundHitNormal
World-space normal returned by the ground sweep.
int snapTurnDirection
Snap-turn direction, -1 for right, 1 for left, and 0 for none.
bool rightTriggerPressed
True when the right trigger exceeds the configured grip threshold.
float playerYawRadians
Accumulated player yaw applied by walking snap turns.
float palmTilt
Average palm tilt input passed to the flight model.
float capsuleRadius
Capsule radius used by sweep tests.
float rightGrip
Right grip analog value in the range reported by the XR input handler.
float diveDemand
Requested dive amount returned by the flight model.
GliderState previousState
State before this frame's transition logic.
glm::vec3 takeoffTestPosition
Candidate player position tested for walking takeoff clearance.
bool collisionReset
Reserved collision reset flag.
bool hasLastSafeLanding
True after a stable landing checkpoint has been recorded.
bool leftHandValid
True when the left-hand pose was valid.
float groundHitFraction
Hit fraction returned by the ground sweep.
bool bothGripsPressed
True when both grip values exceed the configured grip threshold.
float windMomentumDelta
Momentum gained or lost from wind during this frame.
glm::vec3 velocityAfterUpdate
Velocity after movement, collision, and state updates.
float stallRecoveryTimer
Current stall recovery timer.
bool snapTurnTriggered
True during the frame where a snap turn was applied.
GliderState currentState
State after this frame's transition logic.
bool tickSkipped
True when the component skipped movement for the frame.
bool isBraking
True when the current hand pose requests braking.
bool isClimbing
True when the current palm tilt requests climb.
float rightHandCylinderDistance
Horizontal distance from headset vertical axis to right hand.
float leftHandDistance
Distance from headset to left hand.
bool missingInputHandler
True when the component has no XR input handler pointer.
float groundDistance
Downward sweep distance to the detected ground.
World::WindSample windSample
Wind sample read at the player position.
bool isDiving
True when the current palm tilt requests dive.
glm::vec2 rightThumbstick
Right thumbstick value sampled from the XR input handler.
bool missingPhysicsBody
True when the component has no physics body pointer.
float dragDelta
Momentum lost to drag during this frame.
glm::vec3 playerPosition
Player locomotion-root position.
bool isStalled
True when the flight model is stalled.
float rightTrigger
Right trigger analog value in the range reported by the XR input handler.
glm::vec3 collisionPushOut
Push-out vector applied after collision.
float smoothedGroundY
Smoothed capsule-center Y position used while walking.
float collisionMaxPenetration
Maximum penetration reported by contact testing.
float windAlignment
Alignment between glide direction and sampled wind direction.
bool collisionImpact
True when the flight sweep hit another collider.
bool armsSpreadWithHysteresis
True when hand positions pass the arm-spread test with configured hysteresis.
float leftHandCylinderDistance
Horizontal distance from headset vertical axis to left hand.
bool isNearGround
True when ground is close enough to affect state transitions.
bool debugLogging
Debug logging flag sampled during the frame.
bool armsSpread
True when hand positions pass the arm-spread test without hysteresis.
float climbMomentumDelta
Momentum spent on climb during this frame.
bool frozen
Frozen flag sampled during the frame.
bool groundYInitialized
True after the smoothed walking ground height has an initial value.
float leftTrigger
Left trigger analog value in the range reported by the XR input handler.
glm::vec3 groundHitPoint
Capsule-center hit point returned by the ground sweep.
glm::vec3 velocityBeforeUpdate
Velocity before this frame's movement update.
glm::vec3 horizontalAim
Horizontal glide direction derived from hand pose.
glm::vec3 collisionTestPosition
Position tested by the flight collision sweep.
bool groundDetected
True when the downward capsule sweep found walkable or non-walkable ground.
float capsuleCylinderHeight
Cylinder section height used by the sweep capsule.
bool takeoffBlocked
True when takeoff was requested but blocked by clearance or latching.
glm::vec3 headLocalPosition
Headset local position inside the XR play space.
float verticalVelocity
Vertical velocity returned by the flight model.
bool takeoffArmed
True when the player can request takeoff from walking.
bool bothGripsWerePressed
Grip latch state from the previous grip-toggle update.
bool collisionTested
True when flight collision logic ran this frame.
float rightAmount
Right control amount derived from hand pose.
glm::vec3 windContribution
Wind velocity applied to the flight model.
float climbDemand
Requested climb amount returned by the flight model.
glm::vec3 collisionGroundNormal
Surface normal returned by the flight collision sweep.
float forwardAmount
Forward control amount derived from hand pose.
float capsuleTotalHeight
Total capsule height used by sweep tests.
bool respawnTriggered
True during the frame where fall reset triggered.
bool recoveredStall
True during the frame where the flight model recovered from stall.
bool enteredStall
True during the frame where the flight model entered stall.
float momentum
Horizontal speed component used as glider momentum.
glm::vec3 physicsBodyVelocity
Linear velocity read back from the attached physics body.
float leftGrip
Left grip analog value in the range reported by the XR input handler.
bool enabled
Runtime enabled flag sampled during the frame.
glm::vec3 desiredPosition
Requested player position before the final headset and physics body write.
bool takeoffRequested
True when arms were spread while walking.
bool missingHeadset
True when the component has no headset pointer.
bool snapTurnArmed
True when the right stick has returned to the deadzone and can trigger another snap turn.
glm::vec3 bodyForward
Horizontal body-forward direction used by gliding and walking.
bool groundIsWalkable
True when the ground normal passes GliderConfig::maxWalkableSlope.
bool handsTucked
True when both hands are close to the headset vertical axis.
float rightHandDistance
Distance from headset to right hand.
glm::vec3 targetVelocity
Velocity returned by the flight model before collision response.
glm::vec3 headForward
Headset forward direction in world space.
glm::vec3 lastSafeLandingPosition
Last stable walkable position used for respawn.
Hand position and orientation data relative to head.
glm::vec3 relativePosition
glm::vec3 fingerDirection
Runtime tuning values for Engine::Components::VrGlider.
float respawnHeightOffset
Vertical offset added when respawning at the last safe landing point.
float stallExtraDrag
Extra drag applied while stalled.
float groundRayLength
Downward sweep distance for ground detection.
float tuckDistance
Maximum horizontal distance from the headset axis for hands to count as tucked.
float maxClimbRate
Maximum upward speed requested by palm tilt.
float climbMomentumCost
Horizontal momentum spent per unit of climb demand.
float diveMomentumGain
Horizontal momentum gained per unit of dive demand.
float headwindPenalty
Momentum penalty applied when flying into wind.
float walkSpeed
Maximum walking speed on walkable ground.
float maxStepHeight
Reserved step-height value for walking movement.
float stallSpeed
Horizontal speed below which a climbing glider enters stall.
float walkTakeoffMomentum
Minimum horizontal speed applied when taking off from walking.
float fallingTerminalVelocity
Maximum downward speed while falling.
float snapTurnThreshold
Right thumbstick X value required to trigger a walking snap turn.
float highSpeedDrag
Additional drag applied as speed increases.
float armSpreadHysteresis
Extra arm-spread distance required before leaving the current gliding state.
float groundSmoothSpeed
Exponential smoothing rate used when following ground height.
float stallSinkSpeed
Downward speed while stalled.
float flightCollisionFallSpeed
Downward velocity applied after hitting a non-walkable surface in flight.
float walkTakeoffLiftSpeed
Upward velocity applied when taking off from walking.
glm::vec3 spawnPosition
Position used by spawn reset and as the initial safe landing position.
float groundHoverOffset
Vertical offset kept above walkable ground.
float momentumDrag
Baseline horizontal momentum drag applied by the flight model.
float windAlignmentPower
Exponent applied to wind alignment before adding wind momentum.
float gravity
Downward acceleration applied while falling.
float fallResetY
World Y position below which the glider respawns at the last safe landing point.
float stallDiveSinkScale
Scale applied to dive sink while stalled.
float landingCheckpointSettleTime
Time spent settled on walkable ground before updating the landing checkpoint.
float emergencyMaxSpeed
Hard velocity clamp for flight-model safety.
float minGlideSink
Minimum downward speed maintained during normal gliding.
float minArmSpreadDistance
Minimum distance each hand must be from the headset before arms count as spread.
float windMomentumGain
Horizontal momentum gained from aligned wind.
float glideTurnRate
Direction interpolation rate toward the current glide input.
float maxWalkableSlope
Minimum ground-normal Y component accepted as walkable.
float diveSinkRate
Downward speed requested by full dive input.
float walkTakeoffClearance
Upward clearance sweep distance required before walking takeoff.
float windDiminishingSpeed
Speed at which wind acceleration starts diminishing.
float stallRecoveryDelay
Time above recovery speed before a stall exits.
float stickDeadzone
Thumbstick magnitude ignored as input noise.
float crosswindTurnRate
Steering influence from crosswind.
float stallRecoverySpeed
Horizontal speed required before stall recovery can complete.
float snapTurnDegrees
Yaw angle applied by one walking snap turn.
Wind field result at one world-space point.