Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
editor_camera.hpp
Go to the documentation of this file.
1
5
6
#pragma once
7
8
#include "
camera.hpp
"
9
#include "
workspace_events.hpp
"
10
11
#include <toast/events/listener.hpp>
12
13
namespace
toast {
14
15
class
TOAST_API EditorCameraController {
16
public
:
17
EditorCameraController();
18
21
void
tick
(
float
dt,
Camera
* target);
22
31
void
setEnabled
(
bool
enabled)
noexcept
;
32
void
configure(event::EditorCameraMode mode,
float
speed);
33
34
void
copyViewFrom(
const
EditorCameraController& other)
noexcept
;
35
36
[[nodiscard]]
37
auto
mode()
const
noexcept
-> event::EditorCameraMode {
38
return
m_mode;
39
}
40
41
[[nodiscard]]
42
auto
speed()
const
noexcept
->
float
{
43
return
m_speed;
44
}
45
46
[[nodiscard]]
47
auto
position()
const
noexcept
-> glm::vec3 {
48
return
m_position;
49
}
50
51
[[nodiscard]]
52
auto
orbitRadius()
const
noexcept
->
float
{
53
return
m_orbit_radius;
54
}
55
56
[[nodiscard]]
57
auto
orbitElevation()
const
noexcept
->
float
{
58
return
m_orbit_elevation;
59
}
60
61
private
:
62
event::Listener
m_listener;
63
64
bool
m_enabled =
false
;
65
bool
m_active =
false
;
66
bool
m_move_forward =
false
;
67
bool
m_move_back =
false
;
68
bool
m_move_left =
false
;
69
bool
m_move_right =
false
;
70
bool
m_move_up =
false
;
71
bool
m_move_down =
false
;
72
bool
m_boost =
false
;
73
74
glm::vec3 m_position {0.0f, -10.0f, 10.0f};
75
float
m_yaw = 0.0f;
76
float
m_pitch = 0.0f;
77
float
m_orbit_elevation = 0.0f;
78
float
m_orbit_radius = 0.0f;
79
80
float
m_speed = 5.0f;
81
event::EditorCameraMode m_mode = event::EditorCameraMode::free;
82
83
static
constexpr
float
k_min_speed = 0.5f;
84
static
constexpr
float
k_max_speed = 50.0f;
85
static
constexpr
float
k_min_radius = 0.1f;
86
static
constexpr
float
k_max_radius = 5000.0f;
87
static
constexpr
float
k_boost_multiplier = 3.0f;
88
static
constexpr
float
k_look_sensitivity = 0.0025f;
89
static
constexpr
float
k_gesture_zoom_sensitivity = 0.01f;
90
static
constexpr
float
k_gesture_pan_sensitivity = 0.01f;
91
static
constexpr
float
k_pitch_limit = 1.5533f;
// ~89 degrees
92
93
void
setMode(event::EditorCameraMode mode);
94
void
syncOrbitFromPosition();
95
void
applyLook(
float
dx,
float
dy);
96
void
applyPan(
float
dx,
float
dy);
97
void
applyZoom(
float
delta);
98
99
[[nodiscard]]
100
auto
orientation()
const
-> glm::quat;
101
};
102
103
}
camera.hpp
TODO: Brief description of the file's purpose.
event::Listener
manages the lifetime, subscription, and unsubscription of callbacks
Definition
listener.hpp:39
toast::Camera
Definition
camera.hpp:25
toast::EditorCameraController::setEnabled
void setEnabled(bool enabled) noexcept
Enables or disables input handling for this controller.
Definition
editor_camera.cpp:11
toast::EditorCameraController::tick
void tick(float dt, Camera *target)
Advances the fly camera and writes the result onto target.
Definition
editor_camera.cpp:145
workspace_events.hpp
engine
src
toast
world
editor_camera.hpp
Generated by
1.17.0