|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
VR locomotion component that switches between walking, falling, gliding, and stalled flight. More...
#include <VrGliderComponent.h>
Classes | |
| struct | DebugSnapshot |
| Diagnostics captured from the most recent tick() call. More... | |
| struct | HandData |
| Hand position and orientation data relative to head. More... | |
Public Member Functions | |
| VrGlider (Entities::Scene *owningScene, Rendering::Headset *headset, Input::InputManager *inputManager, PhysicsBody *physicsBody) | |
| Creates a VR glider locomotion component. | |
| ~VrGlider () override=default | |
| Destroys the component without owning the headset, input handler, or physics body. | |
| std::string | getComponentName () const override |
| Returns the component registry name. | |
| void | beginPlay () override |
| Initializes runtime state when the owning actor begins play. | |
| void | tick (double deltaTime) override |
| Advances locomotion and writes the updated player position. | |
| void | endPlay () override |
| Stops component play and calls the base Logic lifecycle hook. | |
| bool | drawImGui () override |
| Draws and edits glider state in the engine ImGui inspector. | |
| GliderState | getState () const |
| Returns the current movement state. | |
| glm::vec3 | getVelocity () const |
| Returns the current locomotion velocity. | |
| float | getSpeed () const |
| Returns the magnitude of the current locomotion velocity. | |
| const GliderConfig & | getConfig () const |
| Returns the current glider tuning values. | |
| GliderConfig & | getConfig () |
| Returns mutable glider tuning values. | |
| void | setConfig (const GliderConfig &config) |
| Replaces the active glider tuning values. | |
| void | setEnabled (bool enabled) |
| Enables or disables locomotion processing. | |
| bool | isEnabled () const |
| Returns whether locomotion processing is enabled. | |
| void | setFrozen (bool frozen) |
| Freezes or unfreezes player movement. | |
| void | resetGliderStateTo (GliderState state) |
| Resets velocity and persistent flight state, then sets the current movement state. | |
| PhysicsBody * | getPhysicsBody () const |
| Returns the physics body controlled by this component. | |
| const DebugSnapshot & | getDebugSnapshot () const |
| Returns diagnostics from the most recent tick. | |
| bool | isFrozen () const |
| Returns whether movement is frozen. | |
| 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. | |
| Public Member Functions inherited from Engine::Components::Logic | |
| Logic (Entities::Scene *owningScene) | |
| Constructs a logic component owned by a scene. | |
| Logic (const Entities::SpawnContext &context) | |
| Constructs a logic component from spawn context data. | |
| virtual | ~Logic ()=default |
| Destroys the logic component. | |
| virtual bool | drawImGuiName () |
| Used to alter the name of the entity in the outliner. | |
| bool | hasBegunPlay () const |
| Checks whether beginPlay() has been called without a matching endPlay(). | |
| bool | canTick () const |
| Checks if the component is currently set to tick. | |
| void | setCanTick (bool enable) |
| Enables or disables ticking for this component. | |
| Entities::Entity * | getOwningEntity () const |
| Gets the entity this component belongs to. | |
Static Public Member Functions | |
| static const char * | stateToString (GliderState state) |
| Converts a glider state to a display string. | |
Static Public Attributes | |
| static constexpr bool | IsUnique = true |
| This component type is unique per actor. | |
| static constexpr const char * | ComponentName = "VrGlider" |
| Component registry name. | |
| static constexpr float | CAPSULE_RADIUS = 0.3f |
| Radius of the player capsule used by glider sweep tests. | |
| static constexpr float | CAPSULE_HALF_HEIGHT = 0.7f |
| Half of the cylinder section height used by glider sweep tests. | |
| static constexpr float | CAPSULE_TOTAL_HALF = 1.0f |
| Half of the complete capsule height, including one radius. | |
| Static Public Attributes inherited from Engine::Components::Logic | |
| static constexpr bool | IsUnique = false |
| Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique =
true; if needed. | |
| static constexpr const char * | ComponentName = "Logic" |
| Fallback component type name. Derived classes may override getComponentName() for custom labels. | |
Private Member Functions | |
| HandData | getHandData (Input::Hand hand) const |
| bool | areArmsSpread (const HandData &leftHand, const HandData &rightHand, float hysteresis=0.0f) const |
| bool | areHandsTucked (const HandData &leftHand, const HandData &rightHand) const |
| void | updateGlidingVelocity (const HandData &leftHand, const HandData &rightHand, float dt) |
| ArcadeGliderTuning | makeFlightTuning () const |
| glm::vec3 | buildGlideDirection (const HandData &leftHand, const HandData &rightHand, glm::vec3 &outBodyForward, float &outForwardAmount, float &outRightAmount) const |
| glm::vec3 | getHeadWorldPosition () const |
| Returns the headset world position. | |
| glm::quat | getHeadOrientation () const |
| Returns the headset world orientation. | |
| glm::vec3 | getHeadForward () const |
| Returns the headset forward vector in world space. | |
| bool | canStartGlidingFromWalking (const glm::vec3 ¤tPos, glm::vec3 &outTakeoffPos) const |
| bool | handleFlightCollision (const glm::vec3 ¤tPos, glm::vec3 &desiredPos) |
| bool | sweepGround (const glm::vec3 &origin, glm::vec3 &outHitPoint, glm::vec3 &outHitNormal, float &outHitFraction) const |
| void | updateWalkingInput (float dt) |
| glm::vec3 | collideAndSlide (const glm::vec3 &startPos, const glm::vec3 &displacement) |
| void | updateLastSafeLanding (const glm::vec3 &position, bool stableWalkableGround, float dt) |
| void | teleportPlayer (const glm::vec3 &position) |
| void | resetToLastSafeLanding () |
| void | resetToSpawn () |
Private Attributes | |
| Rendering::Headset * | headset_ = nullptr |
| Input::InputManager * | inputManager_ = nullptr |
| PhysicsBody * | physicsBody_ = nullptr |
| GliderConfig | config_ |
| GliderState | currentState_ = GliderState::FALLING |
| bool | takeoffArmed_ = true |
| glm::vec3 | velocity_ { 0.0f } |
| bool | enabled_ = true |
| bool | frozen_ = true |
| bool | debugLogging_ = true |
| float | debugLogTimer_ = 0.0f |
| bool | bothGripsWerePressed_ = false |
| ArcadeGliderState | flightState_ {} |
| World::WindSample | lastWindSample_ {} |
| DebugSnapshot | debugSnapshot_ {} |
| glm::vec3 | lastSafeLandingPosition_ { 0.0f, 10.0f, 0.0f } |
| bool | hasLastSafeLandingPosition_ = false |
| float | landingCheckpointTimer_ = 0.0f |
| float | playerYaw_ = 0.0f |
| bool | rightStickSnapTurnArmed_ = true |
| float | smoothedGroundY_ = 0.0f |
| bool | groundYInitialized_ = false |
Static Private Attributes | |
| static constexpr float | DEBUG_LOG_INTERVAL = 0.5f |
| static constexpr float | GRIP_THRESHOLD = 0.8f |
| static constexpr float | SKIN_WIDTH = 0.02f |
| static constexpr int | MAX_SLIDE_ITERATIONS = 3 |
Additional Inherited Members | |
| Protected Member Functions inherited from Engine::Components::Logic | |
| Entities::Scene * | getScene () const |
| Gets the scene this component belongs to. | |
| Core::SceneManager * | getSceneManager () const |
| Helper to get the SceneManager from the owning scene. | |
VR locomotion component that switches between walking, falling, gliding, and stalled flight.
VrGlider reads headset pose, hand poses, grip input, triggers, and thumbsticks from the XR runtime. It writes the locomotion root to the headset and attached Engine::Components::PhysicsBody. The component starts frozen so the player can put on the headset before movement begins. Press and release both grips to toggle the frozen state.
Add this component to an actor with a kinematic Engine::Components::PhysicsBody. The collision sweeps assume a player capsule matching Engine::Components::VrGlider::CAPSULE_RADIUS and Engine::Components::VrGlider::CAPSULE_HALF_HEIGHT.
Definition at line 114 of file VrGliderComponent.h.
| Engine::Components::VrGlider::VrGlider | ( | Entities::Scene * | owningScene, |
| Rendering::Headset * | headset, | ||
| Input::InputManager * | inputManager, | ||
| PhysicsBody * | physicsBody ) |
Creates a VR glider locomotion component.
The component reads from headset and inputHandler every tick. The component teleports physicsBody to the computed locomotion-root position and writes its linear velocity. Passing nullptr for any runtime dependency leaves the component enabled but causes movement ticks to be skipped.
| owningScene | Scene that owns this component. |
| headset | Headset interface used for head pose and locomotion-root updates. |
| inputManager | XR input handler used for hand poses, grips, triggers, and thumbsticks. |
| physicsBody | Kinematic physics body used for collision sweeps and velocity reporting. |
|
overridedefault |
Destroys the component without owning the headset, input handler, or physics body.
|
nodiscardprivate |
|
nodiscardprivate |
|
overridevirtual |
Initializes runtime state when the owning actor begins play.
The component applies the current snap-turn yaw to the headset and seeds the last safe landing position from GliderConfig::spawnPosition.
Reimplemented from Engine::Components::Logic.
|
nodiscardprivate |
|
private |
|
private |
|
overridevirtual |
Draws and edits glider state in the engine ImGui inspector.
The inspector exposes runtime flags, current diagnostics, collision state, wind state, and GliderConfig tuning values.
Reimplemented from Engine::Components::Logic.
|
overridevirtual |
Stops component play and calls the base Logic lifecycle hook.
Reimplemented from Engine::Components::Logic.
|
inlinenodiscardoverridevirtual |
Returns the component registry name.
Reimplemented from Engine::Components::Logic.
Definition at line 261 of file VrGliderComponent.h.
References ComponentName.
|
inline |
Returns mutable glider tuning values.
Changes affect subsequent ticks and the ImGui tuning panel.
Definition at line 337 of file VrGliderComponent.h.
References config_.
|
inlinenodiscard |
Returns the current glider tuning values.
Definition at line 325 of file VrGliderComponent.h.
References config_.
|
inlinenodiscard |
Returns diagnostics from the most recent tick.
Definition at line 404 of file VrGliderComponent.h.
References debugSnapshot_.
|
nodiscardprivate |
|
nodiscardprivate |
Returns the headset forward vector in world space.
|
nodiscardprivate |
Returns the headset world orientation.
|
nodiscardprivate |
Returns the headset world position.
|
inlinenodiscard |
Returns the physics body controlled by this component.
Definition at line 398 of file VrGliderComponent.h.
References physicsBody_.
|
inlinenodiscard |
Returns the magnitude of the current locomotion velocity.
Definition at line 316 of file VrGliderComponent.h.
References velocity_.
|
inlinenodiscard |
Returns the current movement state.
Definition at line 298 of file VrGliderComponent.h.
References currentState_.
|
inlinenodiscard |
Returns the current locomotion velocity.
Definition at line 307 of file VrGliderComponent.h.
References velocity_.
|
private |
|
inlinenodiscard |
Returns whether glider debug logging and debug drawing are enabled.
Definition at line 428 of file VrGliderComponent.h.
References debugLogging_.
|
inlinenodiscard |
Returns whether locomotion processing is enabled.
Definition at line 368 of file VrGliderComponent.h.
References enabled_.
|
inlinenodiscard |
Returns whether movement is frozen.
Definition at line 410 of file VrGliderComponent.h.
References frozen_.
|
nodiscardprivate |
| void Engine::Components::VrGlider::resetGliderStateTo | ( | GliderState | state | ) |
Resets velocity and persistent flight state, then sets the current movement state.
This does not teleport the player. Use it to recover from a bad state or to force a known locomotion mode from UI or gameplay code.
| state | New movement state. |
|
private |
|
private |
|
inline |
Replaces the active glider tuning values.
| config | New configuration copied into the component. |
Definition at line 346 of file VrGliderComponent.h.
References config_.
|
inline |
Enables or disables glider debug logging and debug drawing.
| enabled | true to emit periodic log messages and draw glider debug helpers. |
Definition at line 419 of file VrGliderComponent.h.
References debugLogging_.
|
inline |
Enables or disables locomotion processing.
Disabled components still exist and keep their current state. Ticks are skipped while disabled.
| enabled | true to process movement ticks, false to skip movement ticks. |
Definition at line 359 of file VrGliderComponent.h.
References enabled_.
| void Engine::Components::VrGlider::setFrozen | ( | bool | frozen | ) |
Freezes or unfreezes player movement.
Freezing resets velocity and switches the component to GliderState::FALLING. Unfreezing also resets velocity and starts from GliderState::FALLING. The player can toggle this state by pressing and releasing both grips.
| frozen | true to skip movement while still sampling debug input, false to move normally. |
|
staticnodiscard |
Converts a glider state to a display string.
| state | State to convert. |
|
private |
|
private |
|
overridevirtual |
Advances locomotion and writes the updated player position.
The tick reads XR input, updates the movement state, applies walking or flight movement, handles capsule sweeps, updates the attached physics body, and records Engine::Components::VrGlider::DebugSnapshot diagnostics. Movement is skipped when disabled, frozen, or missing a runtime dependency.
| deltaTime | Frame duration in seconds. |
Reimplemented from Engine::Components::Logic.
|
private |
|
private |
|
private |
|
private |
Definition at line 526 of file VrGliderComponent.h.
|
staticconstexpr |
Half of the cylinder section height used by glider sweep tests.
Definition at line 122 of file VrGliderComponent.h.
|
staticconstexpr |
Radius of the player capsule used by glider sweep tests.
Definition at line 121 of file VrGliderComponent.h.
|
staticconstexpr |
Half of the complete capsule height, including one radius.
Definition at line 123 of file VrGliderComponent.h.
|
staticconstexpr |
Component registry name.
Definition at line 119 of file VrGliderComponent.h.
Referenced by getComponentName().
|
private |
Definition at line 514 of file VrGliderComponent.h.
Referenced by getConfig(), getConfig(), and setConfig().
|
private |
Definition at line 515 of file VrGliderComponent.h.
Referenced by getState().
|
staticconstexprprivate |
Definition at line 523 of file VrGliderComponent.h.
|
private |
Definition at line 521 of file VrGliderComponent.h.
Referenced by isDebugLogging(), and setDebugLogging().
|
private |
Definition at line 522 of file VrGliderComponent.h.
|
private |
Definition at line 531 of file VrGliderComponent.h.
Referenced by getDebugSnapshot().
|
private |
Definition at line 519 of file VrGliderComponent.h.
Referenced by isEnabled(), and setEnabled().
|
private |
Definition at line 529 of file VrGliderComponent.h.
|
private |
Definition at line 520 of file VrGliderComponent.h.
Referenced by isFrozen().
|
staticconstexprprivate |
Definition at line 527 of file VrGliderComponent.h.
|
private |
Definition at line 542 of file VrGliderComponent.h.
|
private |
Definition at line 533 of file VrGliderComponent.h.
|
private |
Definition at line 510 of file VrGliderComponent.h.
|
private |
Definition at line 511 of file VrGliderComponent.h.
|
staticconstexpr |
This component type is unique per actor.
Definition at line 117 of file VrGliderComponent.h.
|
private |
Definition at line 534 of file VrGliderComponent.h.
|
private |
Definition at line 532 of file VrGliderComponent.h.
|
private |
Definition at line 530 of file VrGliderComponent.h.
|
staticconstexprprivate |
Definition at line 546 of file VrGliderComponent.h.
|
private |
Definition at line 512 of file VrGliderComponent.h.
Referenced by getPhysicsBody().
|
private |
Definition at line 537 of file VrGliderComponent.h.
|
private |
Definition at line 538 of file VrGliderComponent.h.
|
staticconstexprprivate |
Definition at line 545 of file VrGliderComponent.h.
|
private |
Definition at line 541 of file VrGliderComponent.h.
|
private |
Definition at line 516 of file VrGliderComponent.h.
|
private |
Definition at line 518 of file VrGliderComponent.h.
Referenced by getSpeed(), and getVelocity().