From 3ded27c62dcb9624fd037b0825a436b302c64fb5 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Mon, 31 Oct 2022 15:19:48 +0800 Subject: Make Marker3D gizmo resizable --- scene/3d/marker_3d.cpp | 19 +++++++++++++++++++ scene/3d/marker_3d.h | 8 ++++++++ 2 files changed, 27 insertions(+) (limited to 'scene/3d') diff --git a/scene/3d/marker_3d.cpp b/scene/3d/marker_3d.cpp index 3987172561..8e5998d14f 100644 --- a/scene/3d/marker_3d.cpp +++ b/scene/3d/marker_3d.cpp @@ -30,5 +30,24 @@ #include "marker_3d.h" +void Marker3D::set_gizmo_extents(real_t p_extents) { + if (Math::is_equal_approx(gizmo_extents, p_extents)) { + return; + } + gizmo_extents = p_extents; + update_gizmos(); +} + +real_t Marker3D::get_gizmo_extents() const { + return gizmo_extents; +} + +void Marker3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_gizmo_extents", "extents"), &Marker3D::set_gizmo_extents); + ClassDB::bind_method(D_METHOD("get_gizmo_extents"), &Marker3D::get_gizmo_extents); + + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gizmo_extents", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater,suffix:m"), "set_gizmo_extents", "get_gizmo_extents"); +} + Marker3D::Marker3D() { } diff --git a/scene/3d/marker_3d.h b/scene/3d/marker_3d.h index 95caa101c5..a9bd993476 100644 --- a/scene/3d/marker_3d.h +++ b/scene/3d/marker_3d.h @@ -36,7 +36,15 @@ class Marker3D : public Node3D { GDCLASS(Marker3D, Node3D); + real_t gizmo_extents = 0.25; + +protected: + static void _bind_methods(); + public: + void set_gizmo_extents(real_t p_extents); + real_t get_gizmo_extents() const; + Marker3D(); }; -- cgit v1.2.3