Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Components::VrGlider Class Reference

VR gliding component using hand positions for flight control. More...

#include <VrGliderComponent.h>

Inheritance diagram for Engine::Components::VrGlider:
Collaboration diagram for Engine::Components::VrGlider:

Classes

struct  DebugSnapshot
struct  HandData
 Hand position and orientation data relative to head. More...

Public Member Functions

 VrGlider (Entities::Scene *owningScene, Rendering::Headset *headset, Input::XrInputHandler *inputHandler, PhysicsBody *physicsBody)
 Constructs the VR glider component.
 ~VrGlider () override=default
std::string getComponentName () const override
 Gets the component type name for debugging/UI.
void beginPlay () override
 Called when the component is added to the scene or the game starts.
void tick (double deltaTime) override
 Called every frame if ticking is enabled.
void endPlay () override
 Called when the component is removed or the game ends.
GliderState getState () const
 Getter.
glm::vec3 getVelocity () const
 Getter.
float getSpeed () const
 Getter.
const GliderConfiggetConfig () const
 Getter.
GliderConfiggetConfig ()
 Getter.
void setConfig (const GliderConfig &config)
 Setter.
void setEnabled (bool enabled)
 Setter.
bool isEnabled () const
 Getter.
void setFrozen (bool frozen)
 Pauses/unpauses physics integration.
void resetGliderStateTo (GliderState state)
PhysicsBodygetPhysicsBody () const
const DebugSnapshotgetDebugSnapshot () const
bool isFrozen () const
 Getter.
void setDebugLogging (bool enabled)
 Setter.
bool isDebugLogging () const
 Getter.
Public Member Functions inherited from Engine::Components::Logic
 Logic (Entities::Scene *owningScene)
virtual ~Logic ()=default
bool hasBegunPlay () const
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
Entities::EntitygetOwningEntity () const
 Gets the entity this component belongs to.

Static Public Member Functions

static const char * stateToString (GliderState state)
 Returns string representation of a glider state.

Static Public Attributes

static constexpr bool IsUnique = true
static constexpr const char * ComponentName = "VrGlider"
static constexpr float CAPSULE_RADIUS = 0.3f
static constexpr float CAPSULE_HALF_HEIGHT = 0.7f
static constexpr float CAPSULE_TOTAL_HALF = 1.0f
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
 Getter.
glm::quat getHeadOrientation () const
 Getter.
glm::vec3 getHeadForward () const
 Getter.
bool canStartGlidingFromWalking (const glm::vec3 &currentPos, glm::vec3 &outTakeoffPos) const
bool handleFlightCollision (const glm::vec3 &currentPos, 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::Headsetheadset_ = nullptr
Input::XrInputHandlerinputHandler_ = nullptr
PhysicsBodyphysicsBody_ = 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::ScenegetScene () const
 Gets the scene this component belongs to.
Core::SceneManagergetSceneManager () const
 Helper to get the SceneManager from the owning scene.

Detailed Description

VR gliding component using hand positions for flight control.

Definition at line 100 of file VrGliderComponent.h.

Constructor & Destructor Documentation

◆ VrGlider()

Engine::Components::VrGlider::VrGlider ( Entities::Scene * owningScene,
Rendering::Headset * headset,
Input::XrInputHandler * inputHandler,
PhysicsBody * physicsBody )

Constructs the VR glider component.

Parameters
owningSceneThe scene this component belongs to.
headsetPointer to the headset for reading head position/orientation.
inputHandlerPointer to the XR input handler for hand poses.
physicsBodyPointer to the physics body for applying velocities.

◆ ~VrGlider()

Engine::Components::VrGlider::~VrGlider ( )
overridedefault

Member Function Documentation

◆ areArmsSpread()

bool Engine::Components::VrGlider::areArmsSpread ( const HandData & leftHand,
const HandData & rightHand,
float hysteresis = 0.0f ) const
nodiscardprivate

◆ areHandsTucked()

bool Engine::Components::VrGlider::areHandsTucked ( const HandData & leftHand,
const HandData & rightHand ) const
nodiscardprivate

◆ beginPlay()

void Engine::Components::VrGlider::beginPlay ( )
overridevirtual

Called when the component is added to the scene or the game starts.

Reimplemented from Engine::Components::Logic.

◆ buildGlideDirection()

glm::vec3 Engine::Components::VrGlider::buildGlideDirection ( const HandData & leftHand,
const HandData & rightHand,
glm::vec3 & outBodyForward,
float & outForwardAmount,
float & outRightAmount ) const
nodiscardprivate

◆ canStartGlidingFromWalking()

bool Engine::Components::VrGlider::canStartGlidingFromWalking ( const glm::vec3 & currentPos,
glm::vec3 & outTakeoffPos ) const
private

◆ collideAndSlide()

glm::vec3 Engine::Components::VrGlider::collideAndSlide ( const glm::vec3 & startPos,
const glm::vec3 & displacement )
private

◆ endPlay()

void Engine::Components::VrGlider::endPlay ( )
overridevirtual

Called when the component is removed or the game ends.

Reimplemented from Engine::Components::Logic.

◆ getComponentName()

std::string Engine::Components::VrGlider::getComponentName ( ) const
inlinenodiscardoverridevirtual

Gets the component type name for debugging/UI.

Returns
The component display name.

Reimplemented from Engine::Components::Logic.

Definition at line 229 of file VrGliderComponent.h.

References ComponentName.

◆ getConfig() [1/2]

GliderConfig & Engine::Components::VrGlider::getConfig ( )
inline

Getter.

Definition at line 270 of file VrGliderComponent.h.

References config_.

◆ getConfig() [2/2]

const GliderConfig & Engine::Components::VrGlider::getConfig ( ) const
inlinenodiscard

Getter.

Definition at line 262 of file VrGliderComponent.h.

References config_.

◆ getDebugSnapshot()

const DebugSnapshot & Engine::Components::VrGlider::getDebugSnapshot ( ) const
inlinenodiscard

Definition at line 308 of file VrGliderComponent.h.

References debugSnapshot_.

◆ getHandData()

HandData Engine::Components::VrGlider::getHandData ( Input::Hand hand) const
nodiscardprivate

◆ getHeadForward()

glm::vec3 Engine::Components::VrGlider::getHeadForward ( ) const
nodiscardprivate

Getter.

◆ getHeadOrientation()

glm::quat Engine::Components::VrGlider::getHeadOrientation ( ) const
nodiscardprivate

Getter.

◆ getHeadWorldPosition()

glm::vec3 Engine::Components::VrGlider::getHeadWorldPosition ( ) const
nodiscardprivate

Getter.

◆ getPhysicsBody()

PhysicsBody * Engine::Components::VrGlider::getPhysicsBody ( ) const
inlinenodiscard

Definition at line 306 of file VrGliderComponent.h.

References physicsBody_.

◆ getSpeed()

float Engine::Components::VrGlider::getSpeed ( ) const
inlinenodiscard

Getter.

Definition at line 254 of file VrGliderComponent.h.

References velocity_.

◆ getState()

GliderState Engine::Components::VrGlider::getState ( ) const
inlinenodiscard

Getter.

Definition at line 238 of file VrGliderComponent.h.

References currentState_.

◆ getVelocity()

glm::vec3 Engine::Components::VrGlider::getVelocity ( ) const
inlinenodiscard

Getter.

Definition at line 246 of file VrGliderComponent.h.

References velocity_.

◆ handleFlightCollision()

bool Engine::Components::VrGlider::handleFlightCollision ( const glm::vec3 & currentPos,
glm::vec3 & desiredPos )
private

◆ isDebugLogging()

bool Engine::Components::VrGlider::isDebugLogging ( ) const
inlinenodiscard

Getter.

Definition at line 329 of file VrGliderComponent.h.

References debugLogging_.

◆ isEnabled()

bool Engine::Components::VrGlider::isEnabled ( ) const
inlinenodiscard

Getter.

Definition at line 294 of file VrGliderComponent.h.

References enabled_.

◆ isFrozen()

bool Engine::Components::VrGlider::isFrozen ( ) const
inlinenodiscard

Getter.

Definition at line 313 of file VrGliderComponent.h.

References frozen_.

◆ makeFlightTuning()

ArcadeGliderTuning Engine::Components::VrGlider::makeFlightTuning ( ) const
nodiscardprivate

◆ resetGliderStateTo()

void Engine::Components::VrGlider::resetGliderStateTo ( GliderState state)

◆ resetToLastSafeLanding()

void Engine::Components::VrGlider::resetToLastSafeLanding ( )
private

◆ resetToSpawn()

void Engine::Components::VrGlider::resetToSpawn ( )
private

◆ setConfig()

void Engine::Components::VrGlider::setConfig ( const GliderConfig & config)
inline

Setter.

Definition at line 278 of file VrGliderComponent.h.

References config_.

◆ setDebugLogging()

void Engine::Components::VrGlider::setDebugLogging ( bool enabled)
inline

Setter.

Definition at line 321 of file VrGliderComponent.h.

References debugLogging_.

◆ setEnabled()

void Engine::Components::VrGlider::setEnabled ( bool enabled)
inline

Setter.

Definition at line 286 of file VrGliderComponent.h.

References enabled_.

◆ setFrozen()

void Engine::Components::VrGlider::setFrozen ( bool frozen)

Pauses/unpauses physics integration.

◆ stateToString()

const char * Engine::Components::VrGlider::stateToString ( GliderState state)
staticnodiscard

Returns string representation of a glider state.

◆ sweepGround()

bool Engine::Components::VrGlider::sweepGround ( const glm::vec3 & origin,
glm::vec3 & outHitPoint,
glm::vec3 & outHitNormal,
float & outHitFraction ) const
private

◆ teleportPlayer()

void Engine::Components::VrGlider::teleportPlayer ( const glm::vec3 & position)
private

◆ tick()

void Engine::Components::VrGlider::tick ( double deltaTime)
overridevirtual

Called every frame if ticking is enabled.

Parameters
deltaTimeTime elapsed since last frame.

Reimplemented from Engine::Components::Logic.

◆ updateGlidingVelocity()

void Engine::Components::VrGlider::updateGlidingVelocity ( const HandData & leftHand,
const HandData & rightHand,
float dt )
private

◆ updateLastSafeLanding()

void Engine::Components::VrGlider::updateLastSafeLanding ( const glm::vec3 & position,
bool stableWalkableGround,
float dt )
private

◆ updateWalkingInput()

void Engine::Components::VrGlider::updateWalkingInput ( float dt)
private

Member Data Documentation

◆ bothGripsWerePressed_

bool Engine::Components::VrGlider::bothGripsWerePressed_ = false
private

Definition at line 431 of file VrGliderComponent.h.

◆ CAPSULE_HALF_HEIGHT

float Engine::Components::VrGlider::CAPSULE_HALF_HEIGHT = 0.7f
staticconstexpr

Definition at line 106 of file VrGliderComponent.h.

◆ CAPSULE_RADIUS

float Engine::Components::VrGlider::CAPSULE_RADIUS = 0.3f
staticconstexpr

Definition at line 105 of file VrGliderComponent.h.

◆ CAPSULE_TOTAL_HALF

float Engine::Components::VrGlider::CAPSULE_TOTAL_HALF = 1.0f
staticconstexpr

Definition at line 107 of file VrGliderComponent.h.

◆ ComponentName

const char* Engine::Components::VrGlider::ComponentName = "VrGlider"
staticconstexpr

Definition at line 104 of file VrGliderComponent.h.

Referenced by getComponentName().

◆ config_

GliderConfig Engine::Components::VrGlider::config_
private

Definition at line 419 of file VrGliderComponent.h.

Referenced by getConfig(), getConfig(), and setConfig().

◆ currentState_

GliderState Engine::Components::VrGlider::currentState_ = GliderState::FALLING
private

Definition at line 420 of file VrGliderComponent.h.

Referenced by getState().

◆ DEBUG_LOG_INTERVAL

float Engine::Components::VrGlider::DEBUG_LOG_INTERVAL = 0.5f
staticconstexprprivate

Definition at line 428 of file VrGliderComponent.h.

◆ debugLogging_

bool Engine::Components::VrGlider::debugLogging_ = true
private

Definition at line 426 of file VrGliderComponent.h.

Referenced by isDebugLogging(), and setDebugLogging().

◆ debugLogTimer_

float Engine::Components::VrGlider::debugLogTimer_ = 0.0f
private

Definition at line 427 of file VrGliderComponent.h.

◆ debugSnapshot_

DebugSnapshot Engine::Components::VrGlider::debugSnapshot_ {}
private

Definition at line 436 of file VrGliderComponent.h.

Referenced by getDebugSnapshot().

◆ enabled_

bool Engine::Components::VrGlider::enabled_ = true
private

Definition at line 424 of file VrGliderComponent.h.

Referenced by isEnabled(), and setEnabled().

◆ flightState_

ArcadeGliderState Engine::Components::VrGlider::flightState_ {}
private

Definition at line 434 of file VrGliderComponent.h.

◆ frozen_

bool Engine::Components::VrGlider::frozen_ = true
private

Definition at line 425 of file VrGliderComponent.h.

Referenced by isFrozen().

◆ GRIP_THRESHOLD

float Engine::Components::VrGlider::GRIP_THRESHOLD = 0.8f
staticconstexprprivate

Definition at line 432 of file VrGliderComponent.h.

◆ groundYInitialized_

bool Engine::Components::VrGlider::groundYInitialized_ = false
private

Definition at line 447 of file VrGliderComponent.h.

◆ hasLastSafeLandingPosition_

bool Engine::Components::VrGlider::hasLastSafeLandingPosition_ = false
private

Definition at line 438 of file VrGliderComponent.h.

◆ headset_

Rendering::Headset* Engine::Components::VrGlider::headset_ = nullptr
private

Definition at line 415 of file VrGliderComponent.h.

◆ inputHandler_

Input::XrInputHandler* Engine::Components::VrGlider::inputHandler_ = nullptr
private

Definition at line 416 of file VrGliderComponent.h.

◆ IsUnique

bool Engine::Components::VrGlider::IsUnique = true
staticconstexpr

Definition at line 103 of file VrGliderComponent.h.

◆ landingCheckpointTimer_

float Engine::Components::VrGlider::landingCheckpointTimer_ = 0.0f
private

Definition at line 439 of file VrGliderComponent.h.

◆ lastSafeLandingPosition_

glm::vec3 Engine::Components::VrGlider::lastSafeLandingPosition_ { 0.0f, 10.0f, 0.0f }
private

Definition at line 437 of file VrGliderComponent.h.

◆ lastWindSample_

World::WindSample Engine::Components::VrGlider::lastWindSample_ {}
private

Definition at line 435 of file VrGliderComponent.h.

◆ MAX_SLIDE_ITERATIONS

int Engine::Components::VrGlider::MAX_SLIDE_ITERATIONS = 3
staticconstexprprivate

Definition at line 451 of file VrGliderComponent.h.

◆ physicsBody_

PhysicsBody* Engine::Components::VrGlider::physicsBody_ = nullptr
private

Definition at line 417 of file VrGliderComponent.h.

Referenced by getPhysicsBody().

◆ playerYaw_

float Engine::Components::VrGlider::playerYaw_ = 0.0f
private

Definition at line 442 of file VrGliderComponent.h.

◆ rightStickSnapTurnArmed_

bool Engine::Components::VrGlider::rightStickSnapTurnArmed_ = true
private

Definition at line 443 of file VrGliderComponent.h.

◆ SKIN_WIDTH

float Engine::Components::VrGlider::SKIN_WIDTH = 0.02f
staticconstexprprivate

Definition at line 450 of file VrGliderComponent.h.

◆ smoothedGroundY_

float Engine::Components::VrGlider::smoothedGroundY_ = 0.0f
private

Definition at line 446 of file VrGliderComponent.h.

◆ takeoffArmed_

bool Engine::Components::VrGlider::takeoffArmed_ = true
private

Definition at line 421 of file VrGliderComponent.h.

◆ velocity_

glm::vec3 Engine::Components::VrGlider::velocity_ { 0.0f }
private

Definition at line 423 of file VrGliderComponent.h.

Referenced by getSpeed(), and getVelocity().


The documentation for this class was generated from the following file: