From 7948e0ce3ac5d6ffb7f27274204f8dfe4c91e6f0 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Mon, 19 Aug 2024 14:25:29 +0200 Subject: [PATCH] remove unused springarmpivot --- src/SpringArmPivot.cpp | 65 ------------------------------------------ src/SpringArmPivot.h | 38 ------------------------ src/register_types.cpp | 2 -- 3 files changed, 105 deletions(-) delete mode 100644 src/SpringArmPivot.cpp delete mode 100644 src/SpringArmPivot.h diff --git a/src/SpringArmPivot.cpp b/src/SpringArmPivot.cpp deleted file mode 100644 index 551ee06..0000000 --- a/src/SpringArmPivot.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "SpringArmPivot.h" - -#include "Player.h" -#include -#include -#include -#include -#include -#include -#include - -static const float NormalFov = 75.0; -static const float RunFov = 90.0; -static const float CameraBlend = 0.05; - -namespace blitz { - -void SpringArmPivot::_bind_methods() { - godot::ClassDB::bind_method(godot::D_METHOD("get_dynfov"), &SpringArmPivot::IsFovDynamic); - godot::ClassDB::bind_method(godot::D_METHOD("set_dynfov", "dynamic_fov"), &SpringArmPivot::SetDynamicFov); - ADD_PROPERTY(godot::PropertyInfo(godot::Variant::BOOL, "dynamic_fov"), "set_dynfov", "get_dynfov"); -} - -SpringArmPivot::SpringArmPivot() {} - -SpringArmPivot::~SpringArmPivot() {} - -void SpringArmPivot::_ready() { - m_SpringArm = Object::cast_to(get_child(0)); - m_Camera = Object::cast_to(m_SpringArm->get_child(0)); - DEV_ASSERT(m_SpringArm); - DEV_ASSERT(m_Camera); - if (!godot::Engine::get_singleton()->is_editor_hint()) { - godot::Input::get_singleton()->set_mouse_mode(godot::Input::MOUSE_MODE_CAPTURED); - } -} - -void SpringArmPivot::_unhandled_input(const godot::Ref& p_event) { - auto* event = Object::cast_to(p_event.ptr()); - if (event) { - rotate_y(-event->get_relative().x * 0.005); - m_SpringArm->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); - } -} - -void SpringArmPivot::_physics_process(float delta) { - if (m_DynamicFOV) { - auto* parent = Object::cast_to(get_owner()); - if (parent->is_on_floor()) { - if (godot::Input::get_singleton()->is_action_pressed("run")) { - m_Camera->set_fov(godot::UtilityFunctions::lerp(m_Camera->get_fov(), RunFov, CameraBlend)); - } else { - m_Camera->set_fov(godot::UtilityFunctions::lerp(m_Camera->get_fov(), NormalFov, CameraBlend)); - } - } else { - m_Camera->set_fov(godot::UtilityFunctions::lerp(m_Camera->get_fov(), NormalFov, CameraBlend)); - } - } -} - -} // namespace blitz diff --git a/src/SpringArmPivot.h b/src/SpringArmPivot.h deleted file mode 100644 index 410b3ce..0000000 --- a/src/SpringArmPivot.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace blitz { -class SpringArmPivot : public godot::Node3D { - - GDCLASS(SpringArmPivot, godot::Node3D); - - protected: - static void _bind_methods(); - - public: - SpringArmPivot(); - ~SpringArmPivot(); - - void _ready(); - void _unhandled_input(const godot::Ref& p_event); - void _physics_process(float delta); - - void SetDynamicFov(bool fov) { - m_DynamicFOV = fov; - } - - bool IsFovDynamic() const { - return m_DynamicFOV; - } - - private: - godot::SpringArm3D* m_SpringArm; - godot::Camera3D* m_Camera; - - bool m_DynamicFOV = false; -}; -} // namespace blitz diff --git a/src/register_types.cpp b/src/register_types.cpp index b710979..343ac20 100644 --- a/src/register_types.cpp +++ b/src/register_types.cpp @@ -7,7 +7,6 @@ #include "NetworkInterface.h" #include "Player.h" #include "Server.h" -#include "SpringArmPivot.h" #include "World.h" #include @@ -18,7 +17,6 @@ using namespace godot; static void RegisterClasses() { GDREGISTER_CLASS(blitz::Player); - GDREGISTER_CLASS(blitz::SpringArmPivot); GDREGISTER_CLASS(blitz::FirstPersonPlayer); GDREGISTER_CLASS(blitz::MainMenu); GDREGISTER_CLASS(blitz::Lobby);