diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-10-31 15:19:48 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-10-31 15:19:48 +0800 |
commit | 3ded27c62dcb9624fd037b0825a436b302c64fb5 (patch) | |
tree | 64de4c3b18ec6973de6200215dbd390b3300d38e /editor | |
parent | 256c0079b0b209669e90a40ebc4cb89453875c5c (diff) |
Make Marker3D gizmo resizable
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/node_3d_editor_gizmos.cpp | 21 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_gizmos.h | 1 |
2 files changed, 17 insertions, 5 deletions
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 26af5e3f2d..0d3b303d3a 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -2296,10 +2296,10 @@ void Label3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Marker3DGizmoPlugin::Marker3DGizmoPlugin() { pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); - cursor_points = Vector<Vector3>(); + Vector<Vector3> cursor_points; Vector<Color> cursor_colors; - const float cs = 0.25; + const float cs = 1.0; // Add more points to create a "hard stop" in the color gradient. cursor_points.push_back(Vector3(+cs, 0, 0)); cursor_points.push_back(Vector3()); @@ -2367,9 +2367,22 @@ int Marker3DGizmoPlugin::get_priority() const { } void Marker3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + const Marker3D *marker = Object::cast_to<Marker3D>(p_gizmo->get_node_3d()); + const real_t extents = marker->get_gizmo_extents(); + const Transform3D xform(Basis::from_scale(Vector3(extents, extents, extents))); + p_gizmo->clear(); - p_gizmo->add_mesh(pos3d_mesh); - p_gizmo->add_collision_segments(cursor_points); + p_gizmo->add_mesh(pos3d_mesh, Ref<Material>(), xform); + + const Vector<Vector3> points = { + Vector3(-extents, 0, 0), + Vector3(+extents, 0, 0), + Vector3(0, -extents, 0), + Vector3(0, +extents, 0), + Vector3(0, 0, -extents), + Vector3(0, 0, +extents), + }; + p_gizmo->add_collision_segments(points); } //// diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index b642e1024a..d7e3e03f61 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -338,7 +338,6 @@ class Marker3DGizmoPlugin : public EditorNode3DGizmoPlugin { GDCLASS(Marker3DGizmoPlugin, EditorNode3DGizmoPlugin); Ref<ArrayMesh> pos3d_mesh; - Vector<Vector3> cursor_points; public: bool has_gizmo(Node3D *p_spatial) override; |