diff --git a/doc/classes/EditorSpatialGizmo.xml b/doc/classes/EditorSpatialGizmo.xml
index 338ef1ae4..6cf75beed 100644
--- a/doc/classes/EditorSpatialGizmo.xml
+++ b/doc/classes/EditorSpatialGizmo.xml
@@ -32,6 +32,7 @@
Adds a list of handles (points) which can be used to edit the properties of the gizmo's Spatial. The [code]ids[/code] argument can be used to specify a custom identifier for each handle, if an empty [code]Array[/code] is passed, the ids will be assigned automatically from the [code]handles[/code] argument order.
+ The [code]secondary[/code] argument marks the added handles as secondary, meaning they will normally have less selection priority than regular handles. When the user is holding the shift key secondary handles will switch to have higher priority than regular handles. This change in priority can be used to place multiple handles at the same point while still giving the user control on their selection.
There are virtual methods which will be called upon editing of these handles. Call this method during [method _redraw].
@@ -73,11 +74,13 @@
-
-
+
+
+
Override this method to commit a handle being edited (handles must have been previously added by [method add_handles]). This usually means creating an [UndoRedo] action for the change, using the current handle value as "do" and the [code]restore[/code] argument as "undo".
If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] value should be directly set, without any [UndoRedo] action.
+ The [code]secondary[/code] argument is [code]true[/code] when the committed handle is secondary (see [method add_handles] for more information).
@@ -97,16 +100,19 @@
+
- Override this method to return the name of an edited handle (handles must have been previously added by [method add_handles]).
- Handles can be named for reference to the user when editing.
+ Override this method to return the name of an edited handle (handles must have been previously added by [method add_handles]). Handles can be named for reference to the user when editing.
+ The [code]secondary[/code] argument is [code]true[/code] when the requested handle is secondary (see [method add_handles] for more information).
+
Override this method to return the current value of a handle. This value will be requested at the start of an edit and used as the [code]restore[/code] argument in [method _commit_handle].
+ The [code]secondary[/code] argument is [code]true[/code] when the requested handle is secondary (see [method add_handles] for more information).
@@ -133,8 +139,10 @@
+
Override this method to return [code]true[/code] whenever the given handle should be highlighted in the editor.
+ The [code]secondary[/code] argument is [code]true[/code] when the requested handle is secondary (see [method add_handles] for more information).
@@ -146,10 +154,12 @@
-
-
+
+
+
Override this method to update the node properties when the user drags a gizmo handle (previously added with [method add_handles]). The provided [code]point[/code] is the mouse position in screen coordinates and the [code]camera[/code] can be used to convert it to raycasts.
+ The [code]secondary[/code] argument is [code]true[/code] when the edited handle is secondary (see [method add_handles] for more information).
diff --git a/doc/classes/EditorSpatialGizmoPlugin.xml b/doc/classes/EditorSpatialGizmoPlugin.xml
index 4a46ffd3b..641c9a761 100644
--- a/doc/classes/EditorSpatialGizmoPlugin.xml
+++ b/doc/classes/EditorSpatialGizmoPlugin.xml
@@ -29,11 +29,14 @@
-
-
+
+
+
Override this method to commit a handle being edited (handles must have been previously added by [method EditorSpatialGizmo.add_handles] during [method _redraw]). This usually means creating an [UndoRedo] action for the change, using the current handle value as "do" and the [code]restore[/code] argument as "undo".
- If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] value should be directly set, without any [UndoRedo] action. Called for this plugin's active gizmos.
+ If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] value should be directly set, without any [UndoRedo] action.
+ The [code]secondary[/code] argument is [code]true[/code] when the committed handle is secondary (see [method EditorNode3DGizmo.add_handles] for more information).
+ Called for this plugin's active gizmos.
@@ -94,16 +97,20 @@
+
- Override this method to provide gizmo's handle names. Called for this plugin's active gizmos.
+ Override this method to provide gizmo's handle names. The [code]secondary[/code] argument is [code]true[/code] when the requested handle is secondary (see [method EditorNode3DGizmo.add_handles] for more information). Called for this plugin's active gizmos.
+
- Override this method to return the current value of a handle. This value will be requested at the start of an edit and used as the [code]restore[/code] argument in [method _commit_handle]. Called for this plugin's active gizmos.
+ Override this method to return the current value of a handle. This value will be requested at the start of an edit and used as the [code]restore[/code] argument in [method _commit_handle].
+ The [code]secondary[/code] argument is [code]true[/code] when the requested handle is secondary (see [method EditorNode3DGizmo.add_handles] for more information).
+ Called for this plugin's active gizmos.
@@ -149,8 +156,9 @@
+
- Override this method to return [code]true[/code] whenever to given handle should be highlighted in the editor. Called for this plugin's active gizmos.
+ Override this method to return [code]true[/code] whenever to given handle should be highlighted in the editor. The [code]secondary[/code] argument is [code]true[/code] when the requested handle is secondary (see [method EditorNode3DGizmo.add_handles] for more information). Called for this plugin's active gizmos.
@@ -170,10 +178,13 @@
-
-
+
+
+
- Override this method to update the node's properties when the user drags a gizmo handle (previously added with [method EditorSpatialGizmo.add_handles]). The provided [code]point[/code] is the mouse position in screen coordinates and the [code]camera[/code] can be used to convert it to raycasts. Called for this plugin's active gizmos.
+ Override this method to update the node's properties when the user drags a gizmo handle (previously added with [method EditorNode3DGizmo.add_handles]). The provided [code]point[/code] is the mouse position in screen coordinates and the [code]camera[/code] can be used to convert it to raycasts.
+ The [code]secondary[/code] argument is [code]true[/code] when the edited handle is secondary (see [method EditorNode3DGizmo.add_handles] for more information).
+ Called for this plugin's active gizmos.
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index 75e65b92d..3b4913c3a 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -30,9 +30,6 @@
#include "path_editor_plugin.h"
-#include "core/os/keyboard.h"
-#include "scene/resources/curve.h"
-#include "spatial_editor_plugin.h"
#include "core/class_db.h"
#include "core/color.h"
#include "core/math/basis.h"
@@ -41,6 +38,7 @@
#include "core/math/plane.h"
#include "core/math/transform.h"
#include "core/os/input_event.h"
+#include "core/os/keyboard.h"
#include "core/os/memory.h"
#include "core/pool_vector.h"
#include "core/undo_redo.h"
@@ -56,22 +54,24 @@
#include "scene/gui/separator.h"
#include "scene/gui/tool_button.h"
#include "scene/main/node.h"
+#include "scene/resources/curve.h"
#include "scene/resources/material.h"
+#include "spatial_editor_plugin.h"
-String PathSpatialGizmo::get_handle_name(int p_idx) const {
+String PathSpatialGizmo::get_handle_name(int p_id, bool p_secondary) const {
Ref c = path->get_curve();
if (c.is_null()) {
return "";
}
- if (p_idx < c->get_point_count()) {
- return TTR("Curve Point #") + itos(p_idx);
+ if (!p_secondary) {
+ return TTR("Curve Point #") + itos(p_id);
}
- p_idx = p_idx - c->get_point_count() + 1;
+ p_id += 1; // Account for the first point only having an "out" handle
- int idx = p_idx / 2;
- int t = p_idx % 2;
+ int idx = p_id / 2;
+ int t = p_id % 2;
String n = TTR("Curve Point #") + itos(idx);
if (t == 0) {
n += " In";
@@ -81,21 +81,21 @@ String PathSpatialGizmo::get_handle_name(int p_idx) const {
return n;
}
-Variant PathSpatialGizmo::get_handle_value(int p_idx) {
+Variant PathSpatialGizmo::get_handle_value(int p_id, bool p_secondary) {
Ref c = path->get_curve();
if (c.is_null()) {
return Variant();
}
- if (p_idx < c->get_point_count()) {
- original = c->get_point_position(p_idx);
+ if (!p_secondary) {
+ original = c->get_point_position(p_id);
return original;
}
- p_idx = p_idx - c->get_point_count() + 1;
+ p_id += 1; // Account for the first point only having an "out" handle
- int idx = p_idx / 2;
- int t = p_idx % 2;
+ int idx = p_id / 2;
+ int t = p_id % 2;
Vector3 ofs;
if (t == 0) {
@@ -108,7 +108,7 @@ Variant PathSpatialGizmo::get_handle_value(int p_idx) {
return ofs;
}
-void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
+void PathSpatialGizmo::set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
Ref c = path->get_curve();
if (c.is_null()) {
return;
@@ -120,7 +120,7 @@ void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_p
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
// Setting curve point positions
- if (p_idx < c->get_point_count()) {
+ if (!p_secondary) {
Plane p(gt.xform(original), p_camera->get_transform().basis.get_axis(2));
Vector3 inters;
@@ -132,16 +132,16 @@ void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_p
}
Vector3 local = gi.xform(inters);
- c->set_point_position(p_idx, local);
+ c->set_point_position(p_id, local);
}
return;
}
- p_idx = p_idx - c->get_point_count() + 1;
+ p_id += 1; // Account for the first point only having an "out" handle
- int idx = p_idx / 2;
- int t = p_idx % 2;
+ int idx = p_id / 2;
+ int t = p_id % 2;
Vector3 base = c->get_point_position(idx);
@@ -177,7 +177,7 @@ void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_p
}
}
-void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
+void PathSpatialGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
Ref c = path->get_curve();
if (c.is_null()) {
return;
@@ -185,27 +185,27 @@ void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
- if (p_idx < c->get_point_count()) {
+ if (!p_secondary) {
if (p_cancel) {
- c->set_point_position(p_idx, p_restore);
+ c->set_point_position(p_id, p_restore);
return;
}
ur->create_action(TTR("Set Curve Point Position"));
- ur->add_do_method(c.ptr(), "set_point_position", p_idx, c->get_point_position(p_idx));
- ur->add_undo_method(c.ptr(), "set_point_position", p_idx, p_restore);
+ ur->add_do_method(c.ptr(), "set_point_position", p_id, c->get_point_position(p_id));
+ ur->add_undo_method(c.ptr(), "set_point_position", p_id, p_restore);
ur->commit_action();
return;
}
- p_idx = p_idx - c->get_point_count() + 1;
+ p_id += 1; // Account for the first point only having an "out" handle
- int idx = p_idx / 2;
- int t = p_idx % 2;
+ int idx = p_id / 2;
+ int t = p_id % 2;
if (t == 0) {
if (p_cancel) {
- c->set_point_in(p_idx, p_restore);
+ c->set_point_in(p_id, p_restore);
return;
}
@@ -513,10 +513,10 @@ void PathEditorPlugin::make_visible(bool p_visible) {
}
}
-void PathEditorPlugin::_mode_changed(int p_idx) {
- curve_create->set_pressed(p_idx == 0);
- curve_edit->set_pressed(p_idx == 1);
- curve_del->set_pressed(p_idx == 2);
+void PathEditorPlugin::_mode_changed(int p_id) {
+ curve_create->set_pressed(p_id == 0);
+ curve_edit->set_pressed(p_id == 1);
+ curve_del->set_pressed(p_id == 2);
}
void PathEditorPlugin::_close_curve() {
diff --git a/editor/plugins/path_editor_plugin.h b/editor/plugins/path_editor_plugin.h
index 350d62217..4a6dd5c3a 100644
--- a/editor/plugins/path_editor_plugin.h
+++ b/editor/plugins/path_editor_plugin.h
@@ -59,10 +59,10 @@ class PathSpatialGizmo : public EditorSpatialGizmo {
mutable float orig_out_length;
public:
- virtual String get_handle_name(int p_idx) const;
- virtual Variant get_handle_value(int p_idx);
- virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
- virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
+ virtual String get_handle_name(int p_id, bool p_secondary) const;
+ virtual Variant get_handle_value(int p_id, bool p_secondary);
+ virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual void redraw();
PathSpatialGizmo(Path *p_path = nullptr);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index c4272195e..d7615707f 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -474,6 +474,7 @@ Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) const {
void SpatialEditorViewport::_clear_selected() {
_edit.gizmo = Ref();
_edit.gizmo_handle = -1;
+ _edit.gizmo_handle_secondary = false;
_edit.gizmo_initial_value = Variant();
Spatial *selected = spatial_editor->get_single_selected_node();
@@ -1431,7 +1432,7 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) {
if (b->is_pressed() && _edit.gizmo.is_valid()) {
//restore
- _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, true);
+ _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, true);
_edit.gizmo = Ref();
}
@@ -1570,11 +1571,13 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) {
}
int gizmo_handle = -1;
- seg->handles_intersect_ray(camera, _edit.mouse_pos, b->get_shift(), gizmo_handle);
+ bool gizmo_secondary = false;
+ seg->handles_intersect_ray(camera, _edit.mouse_pos, b->get_shift(), gizmo_handle, gizmo_secondary);
if (gizmo_handle != -1) {
_edit.gizmo = seg;
_edit.gizmo_handle = gizmo_handle;
- _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle);
+ _edit.gizmo_handle_secondary = gizmo_secondary;
+ _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle, gizmo_secondary);
intersected_handle = true;
break;
}
@@ -1690,7 +1693,7 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) {
surface->update();
} else {
if (_edit.gizmo.is_valid()) {
- _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, false);
+ _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false);
_edit.gizmo = Ref();
break;
}
@@ -1767,6 +1770,7 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) {
Ref found_gizmo;
int found_handle = -1;
+ bool found_handle_secondary = false;
for (int i = 0; i < gizmos.size(); i++) {
Ref seg = gizmos[i];
@@ -1774,7 +1778,7 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) {
continue;
}
- seg->handles_intersect_ray(camera, _edit.mouse_pos, false, found_handle);
+ seg->handles_intersect_ray(camera, _edit.mouse_pos, false, found_handle, found_handle_secondary);
if (found_handle != -1) {
found_gizmo = seg;
@@ -1786,9 +1790,11 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) {
spatial_editor->select_gizmo_highlight_axis(-1);
}
- if (found_gizmo != spatial_editor->get_current_hover_gizmo() || found_handle != spatial_editor->get_current_hover_gizmo_handle()) {
+ bool current_hover_handle_secondary = false;
+ int curreny_hover_handle = spatial_editor->get_current_hover_gizmo_handle(current_hover_handle_secondary);
+ if (found_gizmo != spatial_editor->get_current_hover_gizmo() || found_handle != curreny_hover_handle || found_handle_secondary != current_hover_handle_secondary) {
spatial_editor->set_current_hover_gizmo(found_gizmo);
- spatial_editor->set_current_hover_gizmo_handle(found_handle);
+ spatial_editor->set_current_hover_gizmo_handle(found_handle, found_handle_secondary);
spatial_editor->get_single_selected_node()->update_gizmos();
}
}
@@ -1801,9 +1807,9 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) {
NavigationMode nav_mode = NAVIGATION_NONE;
if (_edit.gizmo.is_valid()) {
- _edit.gizmo->set_handle(_edit.gizmo_handle, camera, m->get_position());
- Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle);
- String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle);
+ _edit.gizmo->set_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, camera, m->get_position());
+ Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle, _edit.gizmo_handle_secondary);
+ String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle, _edit.gizmo_handle_secondary);
set_message(n + ": " + String(v));
} else if (m->get_button_mask() & BUTTON_MASK_LEFT) {
@@ -4367,6 +4373,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
_edit.plane = TRANSFORM_VIEW;
_edit.snap = true;
_edit.gizmo_handle = -1;
+ _edit.gizmo_handle_secondary = false;
index = p_index;
editor = p_editor;
@@ -5390,6 +5397,7 @@ void SpatialEditor::edit(Spatial *p_spatial) {
selected = p_spatial;
current_hover_gizmo = Ref();
current_hover_gizmo_handle = -1;
+ current_hover_gizmo_handle_secondary = false;
if (selected) {
Vector[> gizmos = selected->get_gizmos();
@@ -7505,6 +7513,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true);
current_hover_gizmo_handle = -1;
+ current_hover_gizmo_handle_secondary = false;
// make sure the portal tools are off by default
// (when no RoomManager is present)
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 817affde9..3f0911834 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -334,6 +334,7 @@ public:
bool snap;
Ref gizmo;
int gizmo_handle;
+ bool gizmo_handle_secondary;
Variant gizmo_initial_value;
} _edit;
@@ -601,6 +602,7 @@ private:
Ref current_hover_gizmo;
int current_hover_gizmo_handle;
+ bool current_hover_gizmo_handle_secondary;
float snap_translate_value;
float snap_rotate_value;
@@ -813,8 +815,15 @@ public:
Ref get_current_hover_gizmo() const { return current_hover_gizmo; }
void set_current_hover_gizmo(Ref p_gizmo) { current_hover_gizmo = p_gizmo; }
- void set_current_hover_gizmo_handle(int p_id) { current_hover_gizmo_handle = p_id; }
- int get_current_hover_gizmo_handle() const { return current_hover_gizmo_handle; }
+ void set_current_hover_gizmo_handle(int p_id, bool p_secondary) {
+ current_hover_gizmo_handle = p_id;
+ current_hover_gizmo_handle_secondary = p_secondary;
+ }
+
+ int get_current_hover_gizmo_handle(bool &r_secondary) const {
+ r_secondary = current_hover_gizmo_handle_secondary;
+ return current_hover_gizmo_handle;
+ }
void set_can_preview(Camera *p_preview);
void set_message(String p_message, float p_time = 5);
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index dbacbbad4..a665775f7 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -153,51 +153,51 @@ void EditorSpatialGizmo::redraw() {
}
}
-String EditorSpatialGizmo::get_handle_name(int p_id) const {
+String EditorSpatialGizmo::get_handle_name(int p_id, bool p_secondary) const {
if (get_script_instance() && get_script_instance()->has_method("get_handle_name")) {
- return get_script_instance()->call("get_handle_name", p_id);
+ return get_script_instance()->call("get_handle_name", p_id, p_secondary);
}
ERR_FAIL_COND_V(!gizmo_plugin, "");
- return gizmo_plugin->get_handle_name(this, p_id);
+ return gizmo_plugin->get_handle_name(this, p_id, p_secondary);
}
-bool EditorSpatialGizmo::is_handle_highlighted(int p_id) const {
+bool EditorSpatialGizmo::is_handle_highlighted(int p_id, bool p_secondary) const {
if (get_script_instance() && get_script_instance()->has_method("is_handle_highlighted")) {
- return get_script_instance()->call("is_handle_highlighted", p_id);
+ return get_script_instance()->call("is_handle_highlighted", p_id, p_secondary);
}
ERR_FAIL_COND_V(!gizmo_plugin, false);
- return gizmo_plugin->is_handle_highlighted(this, p_id);
+ return gizmo_plugin->is_handle_highlighted(this, p_id, p_secondary);
}
-Variant EditorSpatialGizmo::get_handle_value(int p_id) {
+Variant EditorSpatialGizmo::get_handle_value(int p_id, bool p_secondary) {
if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) {
- return get_script_instance()->call("get_handle_value", p_id);
+ return get_script_instance()->call("get_handle_value", p_id, p_secondary);
}
ERR_FAIL_COND_V(!gizmo_plugin, Variant());
- return gizmo_plugin->get_handle_value(this, p_id);
+ return gizmo_plugin->get_handle_value(this, p_id, p_secondary);
}
-void EditorSpatialGizmo::set_handle(int p_id, Camera *p_camera, const Point2 &p_point) {
+void EditorSpatialGizmo::set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
if (get_script_instance() && get_script_instance()->has_method("set_handle")) {
- get_script_instance()->call("set_handle", p_id, p_camera, p_point);
+ get_script_instance()->call("set_handle", p_id, p_secondary, p_camera, p_point);
return;
}
ERR_FAIL_COND(!gizmo_plugin);
- gizmo_plugin->set_handle(this, p_id, p_camera, p_point);
+ gizmo_plugin->set_handle(this, p_id, p_secondary, p_camera, p_point);
}
-void EditorSpatialGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) {
+void EditorSpatialGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
if (get_script_instance() && get_script_instance()->has_method("commit_handle")) {
- get_script_instance()->call("commit_handle", p_id, p_restore, p_cancel);
+ get_script_instance()->call("commit_handle", p_id, p_secondary, p_restore, p_cancel);
return;
}
ERR_FAIL_COND(!gizmo_plugin);
- gizmo_plugin->commit_handle(this, p_id, p_restore, p_cancel);
+ gizmo_plugin->commit_handle(this, p_id, p_secondary, p_restore, p_cancel);
}
int EditorSpatialGizmo::subgizmos_intersect_ray(Camera *p_camera, const Vector2 &p_point) const {
@@ -494,7 +494,8 @@ void EditorSpatialGizmo::add_handles(const Vector &p_handles, const Ref
}
bool is_current_hover_gizmo = SpatialEditor::get_singleton()->get_current_hover_gizmo() == this;
- int current_hover_handle = SpatialEditor::get_singleton()->get_current_hover_gizmo_handle();
+ bool current_hover_handle_secondary;
+ int current_hover_handle = SpatialEditor::get_singleton()->get_current_hover_gizmo_handle(current_hover_handle_secondary);
Instance ins;
@@ -509,12 +510,12 @@ void EditorSpatialGizmo::add_handles(const Vector &p_handles, const Ref
PoolVector::Write w = colors.write();
for (int i = 0; i < p_handles.size(); i++) {
Color col(1, 1, 1, 1);
- if (is_handle_highlighted(i)) {
+ if (is_handle_highlighted(i, p_secondary)) {
col = Color(0, 0, 1, 0.9);
}
int id = p_ids.empty() ? i : p_ids[i];
- if (!is_current_hover_gizmo || current_hover_handle != id) {
+ if (!is_current_hover_gizmo || current_hover_handle != id || p_secondary != current_hover_handle_secondary) {
col.a = 0.8;
}
@@ -658,8 +659,9 @@ bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector<
return false;
}
-void EditorSpatialGizmo::handles_intersect_ray(Camera *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id) {
+void EditorSpatialGizmo::handles_intersect_ray(Camera *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id, bool &r_secondary) {
r_id = -1;
+ r_secondary = false;
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
@@ -689,6 +691,7 @@ void EditorSpatialGizmo::handles_intersect_ray(Camera *p_camera, const Vector2 &
} else {
r_id = secondary_handle_ids[i];
}
+ r_secondary = true;
}
}
}
@@ -711,7 +714,7 @@ void EditorSpatialGizmo::handles_intersect_ray(Camera *p_camera, const Vector2 &
r_id = i;
} else {
r_id = handle_ids[i];
- }
+ r_secondary = false; }
}
}
}
@@ -923,15 +926,15 @@ void EditorSpatialGizmo::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_subgizmo_selection"), &EditorSpatialGizmo::get_subgizmo_selection);
BIND_VMETHOD(MethodInfo("redraw"));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", PropertyInfo(Variant::INT, "id")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_handle_highlighted", PropertyInfo(Variant::INT, "id")));
+ BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "secondary")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_handle_highlighted", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "secondary")));
- MethodInfo hvget(Variant::NIL, "get_handle_value", PropertyInfo(Variant::INT, "id"));
+ MethodInfo hvget(Variant::NIL, "get_handle_value", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "secondary"));
hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
BIND_VMETHOD(hvget);
- BIND_VMETHOD(MethodInfo("set_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::VECTOR2, "point")));
- MethodInfo cm = MethodInfo("commit_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
+ BIND_VMETHOD(MethodInfo("set_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "secondary"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::VECTOR2, "point")));
+ MethodInfo cm = MethodInfo("commit_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "secondary"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
cm.default_arguments.push_back(false);
BIND_VMETHOD(cm);
@@ -1147,15 +1150,15 @@ void EditorSpatialGizmoPlugin::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_selectable_when_hidden"));
BIND_VMETHOD(MethodInfo("redraw", GIZMO_REF));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", GIZMO_REF, PropertyInfo(Variant::INT, "id")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "id")));
+ BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "secondary")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "secondary")));
- MethodInfo hvget(Variant::NIL, "get_handle_value", GIZMO_REF, PropertyInfo(Variant::INT, "index"));
+ MethodInfo hvget(Variant::NIL, "get_handle_value", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "secondary"));
hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
BIND_VMETHOD(hvget);
- BIND_VMETHOD(MethodInfo("set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::VECTOR2, "point")));
- MethodInfo cm = MethodInfo("commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
+ BIND_VMETHOD(MethodInfo("set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id") , PropertyInfo(Variant::BOOL, "secondary"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::VECTOR2, "point")));
+ MethodInfo cm = MethodInfo("commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "secondary"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
cm.default_arguments.push_back(false);
BIND_VMETHOD(cm);
@@ -1210,36 +1213,36 @@ void EditorSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
}
}
-bool EditorSpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+bool EditorSpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
if (get_script_instance() && get_script_instance()->has_method("is_handle_highlighted")) {
- return get_script_instance()->call("is_handle_highlighted", p_gizmo, p_id);
+ return get_script_instance()->call("is_handle_highlighted", p_gizmo, p_id, p_secondary);
}
return false;
}
-String EditorSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+String EditorSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
if (get_script_instance() && get_script_instance()->has_method("get_handle_name")) {
- return get_script_instance()->call("get_handle_name", p_gizmo, p_id);
+ return get_script_instance()->call("get_handle_name", p_gizmo, p_id, p_secondary);
}
return "";
}
-Variant EditorSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const {
+Variant EditorSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) {
- return get_script_instance()->call("get_handle_value", p_gizmo, p_id);
+ return get_script_instance()->call("get_handle_value", p_gizmo, p_id, p_secondary);
}
return Variant();
}
-void EditorSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point) {
+void EditorSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
if (get_script_instance() && get_script_instance()->has_method("set_handle")) {
- get_script_instance()->call("set_handle", p_gizmo, p_id, p_camera, p_point);
+ get_script_instance()->call("set_handle", p_gizmo, p_id, p_secondary, p_camera, p_point);
}
}
-void EditorSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
+void EditorSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
if (get_script_instance() && get_script_instance()->has_method("commit_handle")) {
- get_script_instance()->call("commit_handle", p_gizmo, p_id, p_restore, p_cancel);
+ get_script_instance()->call("commit_handle", p_gizmo, p_id, p_secondary, p_restore, p_cancel);
}
}
@@ -1349,7 +1352,7 @@ int LightSpatialGizmoPlugin::get_priority() const {
return -1;
}
-String LightSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+String LightSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
if (p_id == 0) {
return "Radius";
} else {
@@ -1357,7 +1360,7 @@ String LightSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizm
}
}
-Variant LightSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const {
+Variant LightSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
Light *light = Object::cast_to(p_gizmo->get_spatial_node());
if (p_id == 0) {
return light->get_param(Light::PARAM_RANGE);
@@ -1396,7 +1399,7 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec
return a * 180.0 / Math_PI;
}
-void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point) {
+void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
Light *light = Object::cast_to(p_gizmo->get_spatial_node());
Transform gt = light->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -1440,7 +1443,7 @@ void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id,
}
}
-void LightSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
+void LightSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
Light *light = Object::cast_to(p_gizmo->get_spatial_node());
if (p_cancel) {
light->set_param(p_id == 0 ? Light::PARAM_RANGE : Light::PARAM_SPOT_ANGLE, p_restore);
@@ -1618,16 +1621,16 @@ int AudioStreamPlayer3DSpatialGizmoPlugin::get_priority() const {
return -1;
}
-String AudioStreamPlayer3DSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+String AudioStreamPlayer3DSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
return "Emission Radius";
}
-Variant AudioStreamPlayer3DSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const {
+Variant AudioStreamPlayer3DSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
AudioStreamPlayer3D *player = Object::cast_to(p_gizmo->get_spatial_node());
return player->get_emission_angle();
}
-void AudioStreamPlayer3DSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point) {
+void AudioStreamPlayer3DSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
AudioStreamPlayer3D *player = Object::cast_to(p_gizmo->get_spatial_node());
Transform gt = player->get_global_transform();
@@ -1664,7 +1667,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_giz
}
}
-void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
+void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
AudioStreamPlayer3D *player = Object::cast_to(p_gizmo->get_spatial_node());
if (p_cancel) {
@@ -1775,7 +1778,7 @@ int CameraSpatialGizmoPlugin::get_priority() const {
return -1;
}
-String CameraSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+String CameraSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
Camera *camera = Object::cast_to(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
@@ -1785,7 +1788,7 @@ String CameraSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_giz
}
}
-Variant CameraSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const {
+Variant CameraSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
Camera *camera = Object::cast_to(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
@@ -1795,7 +1798,7 @@ Variant CameraSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo,
}
}
-void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point) {
+void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
Camera *camera = Object::cast_to(p_gizmo->get_spatial_node());
Transform gt = camera->get_global_transform();
@@ -1824,7 +1827,7 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id,
}
}
-void CameraSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
+void CameraSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
Camera *camera = Object::cast_to(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
@@ -2518,21 +2521,21 @@ void SoftBodySpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_collision_triangles(tm);
}
-String SoftBodySpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+String SoftBodySpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
return "SoftBody pin point";
}
-Variant SoftBodySpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const {
+Variant SoftBodySpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
SoftBody *soft_body = Object::cast_to(p_gizmo->get_spatial_node());
return Variant(soft_body->is_point_pinned(p_id));
}
-void SoftBodySpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
+void SoftBodySpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
SoftBody *soft_body = Object::cast_to(p_gizmo->get_spatial_node());
soft_body->pin_point_toggle(p_id);
}
-bool SoftBodySpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const {
+bool SoftBodySpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx, bool p_secondary) const {
SoftBody *soft_body = Object::cast_to(p_gizmo->get_spatial_node());
return soft_body->is_point_pinned(idx);
}
@@ -2559,7 +2562,7 @@ int VisibilityNotifierGizmoPlugin::get_priority() const {
return -1;
}
-String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
switch (p_id) {
case 0:
return "Size X";
@@ -2578,11 +2581,11 @@ String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorSpatialGizmo *
return "";
}
-Variant VisibilityNotifierGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const {
+Variant VisibilityNotifierGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
VisibilityNotifier *notifier = Object::cast_to(p_gizmo->get_spatial_node());
return notifier->get_aabb();
}
-void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point) {
+void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
VisibilityNotifier *notifier = Object::cast_to(p_gizmo->get_spatial_node());
Transform gt = notifier->get_global_transform();
@@ -2634,7 +2637,7 @@ void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int
}
}
-void VisibilityNotifierGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
+void VisibilityNotifierGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
VisibilityNotifier *notifier = Object::cast_to(p_gizmo->get_spatial_node());
if (p_cancel) {
@@ -2752,7 +2755,7 @@ int ReflectionProbeGizmoPlugin::get_priority() const {
return -1;
}
-String ReflectionProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+String ReflectionProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
switch (p_id) {
case 0:
return "Extents X";
@@ -2770,11 +2773,11 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_g
return "";
}
-Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const {
+Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
ReflectionProbe *probe = Object::cast_to(p_gizmo->get_spatial_node());
return AABB(probe->get_extents(), probe->get_origin_offset());
}
-void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point) {
+void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
ReflectionProbe *probe = Object::cast_to(p_gizmo->get_spatial_node());
Transform gt = probe->get_global_transform();
@@ -2831,7 +2834,7 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
}
}
-void ReflectionProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
+void ReflectionProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
ReflectionProbe *probe = Object::cast_to(p_gizmo->get_spatial_node());
AABB restore = p_restore;
@@ -2985,7 +2988,7 @@ int CollisionShapeSpatialGizmoPlugin::get_priority() const {
return -1;
}
-String CollisionShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const {
+String CollisionShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
const CollisionShape *cs = Object::cast_to(p_gizmo->get_spatial_node());
Ref s = cs->get_shape();
@@ -3016,7 +3019,7 @@ String CollisionShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizm
return "";
}
-Variant CollisionShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const {
+Variant CollisionShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const {
CollisionShape *cs = Object::cast_to(p_gizmo->get_spatial_node());
Ref s = cs->get_shape();
@@ -3051,7 +3054,7 @@ Variant CollisionShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p
return Variant();
}
-void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point) {
+void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
CollisionShape *cs = Object::cast_to(p_gizmo->get_spatial_node());
Ref s = cs->get_shape();
@@ -3167,7 +3170,7 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i
}
}
}
-void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
+void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
CollisionShape *cs = Object::cast_to(p_gizmo->get_spatial_node());
Ref s = cs->get_shape();
@@ -4445,11 +4448,11 @@ int RoomGizmoPlugin::get_priority() const {
//////////////////////
-String RoomSpatialGizmo::get_handle_name(int p_id) const {
+String RoomSpatialGizmo::get_handle_name(int p_id, bool p_secondary) const {
return "Point " + itos(p_id);
}
-Variant RoomSpatialGizmo::get_handle_value(int p_id) {
+Variant RoomSpatialGizmo::get_handle_value(int p_id, bool p_secondary) {
if (!_room) {
return Vector3(0, 0, 0);
}
@@ -4462,7 +4465,7 @@ Variant RoomSpatialGizmo::get_handle_value(int p_id) {
return _room->_bound_pts[p_id];
}
-void RoomSpatialGizmo::set_handle(int p_id, Camera *p_camera, const Point2 &p_point) {
+void RoomSpatialGizmo::set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
if (!_room || (p_id >= _room->_bound_pts.size())) {
return;
}
@@ -4515,7 +4518,7 @@ void RoomSpatialGizmo::set_handle(int p_id, Camera *p_camera, const Point2 &p_po
}
}
-void RoomSpatialGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) {
+void RoomSpatialGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
if (!_room || (p_id >= _room->_bound_pts.size())) {
return;
}
@@ -4652,11 +4655,11 @@ int PortalGizmoPlugin::get_priority() const {
//////////////////////
-String PortalSpatialGizmo::get_handle_name(int p_id) const {
+String PortalSpatialGizmo::get_handle_name(int p_id, bool p_secondary) const {
return "Point " + itos(p_id);
}
-Variant PortalSpatialGizmo::get_handle_value(int p_id) {
+Variant PortalSpatialGizmo::get_handle_value(int p_id, bool p_secondary) {
if (!_portal) {
return Vector2(0, 0);
}
@@ -4669,7 +4672,7 @@ Variant PortalSpatialGizmo::get_handle_value(int p_id) {
return _portal->_pts_local_raw[p_id];
}
-void PortalSpatialGizmo::set_handle(int p_id, Camera *p_camera, const Point2 &p_point) {
+void PortalSpatialGizmo::set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
if (!_portal || (p_id >= _portal->_pts_local_raw.size())) {
return;
}
@@ -4709,7 +4712,7 @@ void PortalSpatialGizmo::set_handle(int p_id, Camera *p_camera, const Point2 &p_
}
}
-void PortalSpatialGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) {
+void PortalSpatialGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
if (!_portal || (p_id >= _portal->_pts_local_raw.size())) {
return;
}
@@ -4951,7 +4954,7 @@ int OccluderGizmoPlugin::get_priority() const {
//////////////////////
-String OccluderSpatialGizmo::get_handle_name(int p_id) const {
+String OccluderSpatialGizmo::get_handle_name(int p_id, bool p_secondary) const {
const OccluderShapeSphere *occ_sphere = get_occluder_shape_sphere();
if (occ_sphere) {
int num_spheres = occ_sphere->get_spheres().size();
@@ -4976,7 +4979,7 @@ String OccluderSpatialGizmo::get_handle_name(int p_id) const {
return "Unknown";
}
-Variant OccluderSpatialGizmo::get_handle_value(int p_id) {
+Variant OccluderSpatialGizmo::get_handle_value(int p_id, bool p_secondary) {
const OccluderShapeSphere *occ_sphere = get_occluder_shape_sphere();
if (occ_sphere) {
Vector spheres = occ_sphere->get_spheres();
@@ -5006,7 +5009,7 @@ Variant OccluderSpatialGizmo::get_handle_value(int p_id) {
return 0;
}
-void OccluderSpatialGizmo::set_handle(int p_id, Camera *p_camera, const Point2 &p_point) {
+void OccluderSpatialGizmo::set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point) {
if (!_occluder) {
return;
}
@@ -5134,7 +5137,7 @@ void OccluderSpatialGizmo::set_handle(int p_id, Camera *p_camera, const Point2 &
}
}
-void OccluderSpatialGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) {
+void OccluderSpatialGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
OccluderShapeSphere *occ_sphere = get_occluder_shape_sphere();
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
index 43e943bf2..0db3b89ad 100644
--- a/editor/spatial_editor_gizmos.h
+++ b/editor/spatial_editor_gizmos.h
@@ -107,11 +107,11 @@ public:
void add_handles(const Vector &p_handles, const Ref &p_material, const Vector &p_ids = Vector(), bool p_billboard = false, bool p_secondary = false);
void add_solid_box(Ref &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform &p_xform = Transform());
- virtual bool is_handle_highlighted(int p_id) const;
- virtual String get_handle_name(int p_id) const;
- virtual Variant get_handle_value(int p_id);
- virtual void set_handle(int p_id, Camera *p_camera, const Point2 &p_point);
- virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false);
+ virtual bool is_handle_highlighted(int p_id, bool p_secondary) const;
+ virtual String get_handle_name(int p_id, bool p_secondary) const;
+ virtual Variant get_handle_value(int p_id, bool p_secondary);
+ virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual int subgizmos_intersect_ray(Camera *p_camera, const Vector2 &p_point) const;
virtual Vector subgizmos_intersect_frustum(const Camera *p_camera, const Vector &p_frustum) const;
@@ -126,7 +126,7 @@ public:
Spatial *get_spatial_node() const { return spatial_node; }
Ref get_plugin() const { return gizmo_plugin; }
bool intersect_frustum(const Camera *p_camera, const Vector &p_frustum);
- void handles_intersect_ray(Camera *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id);
+ void handles_intersect_ray(Camera *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id, bool &r_secondary);
bool intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal);
bool is_subgizmo_selected(int p_id) const;
Vector get_subgizmo_selection() const;
@@ -177,11 +177,11 @@ public:
virtual bool is_selectable_when_hidden() const;
virtual void redraw(EditorSpatialGizmo *p_gizmo);
- virtual bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- virtual String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- virtual Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const;
- virtual void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point);
- virtual void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false);
+ virtual bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ virtual String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ virtual Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ virtual void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual int subgizmos_intersect_ray(const EditorSpatialGizmo *p_gizmo, Camera *p_camera, const Vector2 &p_point) const;
virtual Vector subgizmos_intersect_frustum(const EditorSpatialGizmo *p_gizmo, const Camera *p_camera, const Vector &p_frustum) const;
@@ -207,10 +207,10 @@ public:
String get_gizmo_name() const;
int get_priority() const;
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false);
+ String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
void redraw(EditorSpatialGizmo *p_gizmo);
LightSpatialGizmoPlugin();
@@ -224,10 +224,10 @@ public:
String get_gizmo_name() const;
int get_priority() const;
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false);
+ String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
void redraw(EditorSpatialGizmo *p_gizmo);
AudioStreamPlayer3DSpatialGizmoPlugin();
@@ -254,10 +254,10 @@ public:
String get_gizmo_name() const;
int get_priority() const;
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false);
+ String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
void redraw(EditorSpatialGizmo *p_gizmo);
CameraSpatialGizmoPlugin();
@@ -375,10 +375,10 @@ public:
bool is_selectable_when_hidden() const;
void redraw(EditorSpatialGizmo *p_gizmo);
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const;
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel);
- bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const;
+ String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel);
+ bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx, bool p_secondary) const;
SoftBodySpatialGizmoPlugin();
};
@@ -392,10 +392,10 @@ public:
int get_priority() const;
void redraw(EditorSpatialGizmo *p_gizmo);
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false);
+ String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
VisibilityNotifierGizmoPlugin();
};
@@ -421,10 +421,10 @@ public:
int get_priority() const;
void redraw(EditorSpatialGizmo *p_gizmo);
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false);
+ String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
ReflectionProbeGizmoPlugin();
};
@@ -450,10 +450,10 @@ public:
int get_priority() const;
void redraw(EditorSpatialGizmo *p_gizmo);
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false);
+ String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
+ void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
CollisionShapeSpatialGizmoPlugin();
};
@@ -562,10 +562,10 @@ class RoomSpatialGizmo : public EditorSpatialGizmo {
Room *_room = nullptr;
public:
- virtual String get_handle_name(int p_id) const;
- virtual Variant get_handle_value(int p_id);
- virtual void set_handle(int p_id, Camera *p_camera, const Point2 &p_point);
- virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false);
+ virtual String get_handle_name(int p_id, bool p_secondary) const;
+ virtual Variant get_handle_value(int p_id, bool p_secondary);
+ virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual void redraw();
RoomSpatialGizmo(Room *p_room = nullptr);
@@ -594,10 +594,10 @@ class PortalSpatialGizmo : public EditorSpatialGizmo {
Color _color_portal_back;
public:
- virtual String get_handle_name(int p_id) const;
- virtual Variant get_handle_value(int p_id);
- virtual void set_handle(int p_id, Camera *p_camera, const Point2 &p_point);
- virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false);
+ virtual String get_handle_name(int p_id, bool p_secondary) const;
+ virtual Variant get_handle_value(int p_id, bool p_secondary);
+ virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual void redraw();
PortalSpatialGizmo(Portal *p_portal = nullptr);
@@ -640,10 +640,10 @@ class OccluderSpatialGizmo : public EditorSpatialGizmo {
void _redraw_poly(bool p_hole, const Vector &p_pts, const PoolVector &p_pts_raw);
public:
- virtual String get_handle_name(int p_id) const;
- virtual Variant get_handle_value(int p_id);
- virtual void set_handle(int p_id, Camera *p_camera, const Point2 &p_point);
- virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false);
+ virtual String get_handle_name(int p_id, bool p_secondary) const;
+ virtual Variant get_handle_value(int p_id, bool p_secondary);
+ virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual void redraw();
OccluderSpatialGizmo(Occluder *p_occluder = nullptr);
diff --git a/modules/mesh_data_resource/editor/mdi_gizmo.cpp b/modules/mesh_data_resource/editor/mdi_gizmo.cpp
index 0d9a242db..2964783a4 100644
--- a/modules/mesh_data_resource/editor/mdi_gizmo.cpp
+++ b/modules/mesh_data_resource/editor/mdi_gizmo.cpp
@@ -47,7 +47,7 @@ void MDIGizmo::set_editor_plugin(EditorPlugin *editor_plugin) {
_undo_redo = EditorNode::get_undo_redo();
}
-void MDIGizmo::set_handle(int index, Camera *camera, const Point2 &point) {
+void MDIGizmo::set_handle(int index, bool secondary, Camera *camera, const Point2 &point) {
Vector2 relative = point - previous_point;
if (!_handle_drag_op) {
diff --git a/modules/mesh_data_resource/editor/mdi_gizmo.h b/modules/mesh_data_resource/editor/mdi_gizmo.h
index c4b8f85fb..6a276aa93 100644
--- a/modules/mesh_data_resource/editor/mdi_gizmo.h
+++ b/modules/mesh_data_resource/editor/mdi_gizmo.h
@@ -77,7 +77,7 @@ public:
void setup();
void set_editor_plugin(EditorPlugin *editor_plugin);
- void set_handle(int index, Camera *camera, const Point2 &point);
+ void set_handle(int index, bool secondary, Camera *camera, const Point2 &point);
void redraw();
void apply();
diff --git a/modules/mesh_data_resource/editor/mdi_gizmo_plugin.cpp b/modules/mesh_data_resource/editor/mdi_gizmo_plugin.cpp
index afc963ec7..d970af3f0 100644
--- a/modules/mesh_data_resource/editor/mdi_gizmo_plugin.cpp
+++ b/modules/mesh_data_resource/editor/mdi_gizmo_plugin.cpp
@@ -32,8 +32,8 @@ String MDIGizmoPlugin::get_gizmo_name() const {
int MDIGizmoPlugin::get_priority() const {
return 100;
}
-bool MDIGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
- return EditorSpatialGizmoPlugin::is_handle_highlighted(p_gizmo, p_idx);
+bool MDIGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx, bool p_secondary) const {
+ return EditorSpatialGizmoPlugin::is_handle_highlighted(p_gizmo, p_idx, p_secondary);
}
Ref MDIGizmoPlugin::create_gizmo(Spatial *p_spatial) {
diff --git a/modules/mesh_data_resource/editor/mdi_gizmo_plugin.h b/modules/mesh_data_resource/editor/mdi_gizmo_plugin.h
index 1e9c31f99..7c3d069a2 100644
--- a/modules/mesh_data_resource/editor/mdi_gizmo_plugin.h
+++ b/modules/mesh_data_resource/editor/mdi_gizmo_plugin.h
@@ -34,7 +34,7 @@ public:
void _init();
String get_gizmo_name() const;
int get_priority() const;
- bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
+ bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx, bool p_secondary) const;
MDIGizmoPlugin();
~MDIGizmoPlugin();
]