class HandleSlider

Inherits: IScriptExportable

Base class for all handle sliders.

A handle slider is geometry that the user can interact with by selecting or dragging (sliding) it. Sliders generally output a one- or multi-dimensional delta value that signals the drag amount (and/or direction).

Public

Constructors

HandleSlider

HandleSlider(const SPtr<SceneHandles> &owner, bool fixedScale, u64 layer)

Constructs a new handle slider.

owner
Object that that owns the slider.
fixedScale
If true the handle slider will always try to maintain the same visible area in the viewport regardless of distance from camera.
layer
Layer that allows filtering of which sliders are interacted with from a specific camera.

Methods

~HandleSlider

virtual ~HandleSlider() noexcept

Intersects

virtual bool Intersects(const Vector2I &screenPos, const Ray &ray, float &t) const = 0

Attempts to find an intersection between the provided ray and the slider geometry.

screenPos
Position in screen space at which to look for intersection. Some sliders might ignore this and use the instead.
ray
Ray in world space to try to interect with geometry.
t
Position of the intersection along the ray. Only if intersection happened.

Returns: Whether an intersection was detected.

HandleInput

virtual void HandleInput(const HCamera &camera, const Vector2I &inputDelta) = 0

Updates a slider that is currently active (being dragged).

camera
Camera through which we're interacting with the slider.
inputDelta
Pointer movement since the last time this method was called.

Update

void Update(const HCamera &camera)

Updates the state of the slider.

Must be called every frame.

camera
Camera through which we're interacting with the slider.

GetState

HandleSliderState GetState() const

Returns the state the slider is currently in.

GetFixedScale

bool GetFixedScale() const

Returns if fixed scale is enabled.

If enabled the handle slider will always try to maintain the same visible area in the viewport regardless of distance from camera.

GetLayer

u64 GetLayer() const

Returns a layer that determines which sliders are interacted with from a specific camera.

SetPosition

void SetPosition(const Vector3 &position)

Sets the world position of the slider.

SetRotation

void SetRotation(const Quaternion &rotation)

Sets the world rotation of the slider.

SetScale

void SetScale(const Vector3 &scale)

Sets the scale of the slider.

SetEnabled

void SetEnabled(bool enabled)

Enables or disables the slider, making it interactable or not.

GetPosition

const Vector3 &GetPosition() const

Gets the world position of the slider.

GetRotation

const Quaternion &GetRotation() const

Gets the world rotation of the slider.

GetScale

const Vector3 &GetScale() const

Gets the scale of the slider.

GetEnabled

bool GetEnabled() const

Checks whether the slider can be interacted with or not.

Destroy

void Destroy()

Makes the slider inactive.

Does not need to be called explicitly if the slider is deleted.

Protected

Methods

SetInactive

void SetInactive()

Toggles the slider state to inactive.

SetActive

void SetActive(const HCamera &camera, const Vector2I &pointerPos)

Toggles the slider state to active.

camera
Camera through which the slider was activated.
pointerPos
Position of the pointer when the slider was activated.

SetHover

void SetHover()

Toggles the slider state to hovered.

GetTransform

const Matrix4 &GetTransform() const

Gets the slider transform depending on set position, rotation and scale values.

GetTransformInv

const Matrix4 &GetTransformInv() const

Gets the inverse of the slider transform depending on set position, rotation and scale values.

Activate

virtual void Activate(const HCamera &camera, const Vector2I &pointerPos)

Triggered when the slider state is changed to active.

Reset

virtual void Reset()

Triggered when the slider state is changed from active to some other state.

UpdateCachedTransform

void UpdateCachedTransform() const

Updates the internal transform from the stored position, rotation and scale values.

CalcDelta

float CalcDelta(const HCamera &camera, const Vector3 &position, const Vector3 &direction, const Vector2I &pointerStart, const Vector2I &pointerEnd)

Calculates amount of movement along the provided ray depending on pointer movement.

camera
Camera on which the pointer movement is occurring.
position
Position of the ray to calculate movement on.
direction
Direction of the ray to calculate movement on. Must be normalized.
pointerStart
Starting position of the pointer when movement started, in pixels relative to provided camera.
pointerEnd
Current position of the pointer, in pixels relative to provided camera.

Fields

mOwner

WeakSPtr<SceneHandles> mOwner

mFixedScale

bool mFixedScale

mLayer

u64 mLayer

mPosition

Vector3 mPosition

mRotation

Quaternion mRotation

mScale

Vector3 mScale

mDistanceScale

float mDistanceScale

mStartPointerPos

Vector2I mStartPointerPos

mCurrentPointerPos

Vector2I mCurrentPointerPos

mState

mEnabled

bool mEnabled

mTransformDirty

bool mTransformDirty

mTransform

Matrix4 mTransform

mTransformInv

Matrix4 mTransformInv