add a testing camera fps (switching cameras by pressing t)
All checks were successful
Linux arm64 / Build (push) Successful in 57s

This commit is contained in:
Morph01
2024-08-13 10:10:31 +02:00
parent d59047d0ae
commit 4707d85150
4 changed files with 82 additions and 56 deletions

View File

@@ -28,6 +28,8 @@ SpringArmPivot::~SpringArmPivot() {}
void SpringArmPivot::_ready() {
m_SpringArm = Object::cast_to<godot::SpringArm3D>(get_child(0));
m_Camera = Object::cast_to<godot::Camera3D>(m_SpringArm->get_child(0));
m_CameraFPS = get_parent()->get_node<godot::Camera3D>("Mesh/Armature/Skeleton3D/BoneAttachment3D/CameraFPS");
DEV_ASSERT(m_SpringArm);
DEV_ASSERT(m_Camera);
if (!godot::Engine::get_singleton()->is_editor_hint()) {
@@ -40,11 +42,22 @@ void SpringArmPivot::_unhandled_input(const godot::Ref<godot::InputEvent>& p_eve
if (event) {
rotate_y(-event->get_relative().x * 0.005);
m_SpringArm->rotate_x(-event->get_relative().y * 0.005);
m_CameraFPS->rotate_x(event->get_relative().y * 0.005);
godot::Vector3 rotationClamped = m_SpringArm->get_rotation();
rotationClamped.x = godot::UtilityFunctions::clamp(rotationClamped.x, -Math_PI / 4, Math_PI / 4);
m_SpringArm->set_rotation(rotationClamped);
}
auto* keyboardevent = Object::cast_to<godot::InputEvent>(p_event.ptr());
if (keyboardevent->is_action_pressed("switch_camera")) {
if (m_Camera->is_current()) {
m_Camera->clear_current();
} else {
m_Camera->make_current();
}
}
}
void SpringArmPivot::_physics_process(float delta) {