class HandleSliderPlane

Inherits: HandleSlider

Handle slider that returns a delta value as you drag the pointer along a plane.

For intersection purposes the line is internally by a quadrilateral.

Public

Constructors

HandleSliderPlane

HandleSliderPlane(const SPtr<SceneHandles> &owner, const Vector3 &dir1, const Vector3 &dir2, float length, bool fixedScale = true, u64 layer = 1)

Constructs a new plane slider.

The plane is constructed from two direction vectors.

owner
Object that that owns the slider.
dir1
First direction of the plane. The x component of returned delta value will be in this direction. Should be perpendicular to .
dir2
Second direction of the plane. The y component of returned delta value will be in this direction. Should be perpendicular to .
length
Determines size of the plane.
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

~HandleSliderPlane

~HandleSliderPlane() noexcept

Intersects

bool Intersects(const Vector2I &screenPos, const Ray &ray, float &t) const override

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

void HandleInput(const HCamera &camera, const Vector2I &inputDelta) override

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.

GetDelta

Vector2 GetDelta() const

Returns a delta value that is the result of dragging/sliding the pointer along the plane.

Returned movement is in terms of the two directions originally provided when constructing the slider. This changes every frame and will be zero unless the slider is active.

Protected

Methods

Activate

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

Triggered when the slider state is changed to active.

Reset

void Reset() override

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

GetPositionOnPlane

Vector3 GetPositionOnPlane(const HCamera &camera, const Vector2I &pointerPos) const

Returns the position on plane based on pointer position.

camera
Camera we're interacting through.
pointerPos
Position of the pointer in pixels relative to the provided camera's viewport.

Fields

mDirection1

Vector3 mDirection1

mDirection2

Vector3 mDirection2

mLength

float mLength

mCollider

Rect3 mCollider

mDelta

Vector2 mDelta

mStartPlanePosition

Vector3 mStartPlanePosition

mStartClickPosition

Vector3 mStartClickPosition