Backported from Godot4: Fix secondary handles in editor gizmos

Primary and secondary handles are no longer differentiated by their ids, so a bool was added to tell them apart in all the handle-related methods.
Includes a minor fix in CollisionPolygon3DEditor, unrelated to editor gizmos.
- JFonS
5ebea2d120
This commit is contained in:
Relintai 2022-08-12 22:21:00 +02:00
parent 88da0c8d4f
commit f423b30714
12 changed files with 243 additions and 201 deletions

View File

@ -32,6 +32,7 @@
<argument index="4" name="secondary" type="bool" default="false" /> <argument index="4" name="secondary" type="bool" default="false" />
<description> <description>
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. 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]. There are virtual methods which will be called upon editing of these handles. Call this method during [method _redraw].
</description> </description>
</method> </method>
@ -73,11 +74,13 @@
<method name="commit_handle" qualifiers="virtual"> <method name="commit_handle" qualifiers="virtual">
<return type="void" /> <return type="void" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<argument index="1" name="restore" type="Variant" /> <argument index="1" name="secondary" type="bool" />
<argument index="2" name="cancel" type="bool" default="false" /> <argument index="2" name="restore" type="Variant" />
<argument index="3" name="cancel" type="bool" />
<description> <description>
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". 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. 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).
</description> </description>
</method> </method>
<method name="commit_subgizmos" qualifiers="virtual"> <method name="commit_subgizmos" qualifiers="virtual">
@ -97,16 +100,19 @@
<method name="get_handle_name" qualifiers="virtual"> <method name="get_handle_name" qualifiers="virtual">
<return type="String" /> <return type="String" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<argument index="1" name="secondary" type="bool" />
<description> <description>
Override this method to return the name of an edited handle (handles must have been previously added by [method add_handles]). 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.
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).
</description> </description>
</method> </method>
<method name="get_handle_value" qualifiers="virtual"> <method name="get_handle_value" qualifiers="virtual">
<return type="Variant" /> <return type="Variant" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<argument index="1" name="secondary" type="bool" />
<description> <description>
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]. 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).
</description> </description>
</method> </method>
<method name="get_subgizmo_transform" qualifiers="virtual"> <method name="get_subgizmo_transform" qualifiers="virtual">
@ -133,8 +139,10 @@
<method name="is_handle_highlighted" qualifiers="virtual"> <method name="is_handle_highlighted" qualifiers="virtual">
<return type="bool" /> <return type="bool" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<argument index="1" name="secondary" type="bool" />
<description> <description>
Override this method to return [code]true[/code] whenever the given handle should be highlighted in the editor. 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).
</description> </description>
</method> </method>
<method name="redraw" qualifiers="virtual"> <method name="redraw" qualifiers="virtual">
@ -146,10 +154,12 @@
<method name="set_handle" qualifiers="virtual"> <method name="set_handle" qualifiers="virtual">
<return type="void" /> <return type="void" />
<argument index="0" name="id" type="int" /> <argument index="0" name="id" type="int" />
<argument index="1" name="camera" type="Camera" /> <argument index="1" name="secondary" type="bool" />
<argument index="2" name="point" type="Vector2" /> <argument index="2" name="camera" type="Camera" />
<argument index="3" name="point" type="Vector2" />
<description> <description>
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. 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).
</description> </description>
</method> </method>
<method name="set_subgizmo_transform" qualifiers="virtual"> <method name="set_subgizmo_transform" qualifiers="virtual">

View File

@ -29,11 +29,14 @@
<return type="void" /> <return type="void" />
<argument index="0" name="gizmo" type="EditorSpatialGizmo" /> <argument index="0" name="gizmo" type="EditorSpatialGizmo" />
<argument index="1" name="id" type="int" /> <argument index="1" name="id" type="int" />
<argument index="2" name="restore" type="Variant" /> <argument index="2" name="secondary" type="bool" />
<argument index="3" name="cancel" type="bool" default="false" /> <argument index="3" name="restore" type="Variant" />
<argument index="4" name="cancel" type="bool" default="false" />
<description> <description>
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". 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.
</description> </description>
</method> </method>
<method name="commit_subgizmos" qualifiers="virtual"> <method name="commit_subgizmos" qualifiers="virtual">
@ -94,16 +97,20 @@
<return type="String" /> <return type="String" />
<argument index="0" name="gizmo" type="EditorSpatialGizmo" /> <argument index="0" name="gizmo" type="EditorSpatialGizmo" />
<argument index="1" name="id" type="int" /> <argument index="1" name="id" type="int" />
<argument index="2" name="secondary" type="bool" />
<description> <description>
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.
</description> </description>
</method> </method>
<method name="get_handle_value" qualifiers="virtual"> <method name="get_handle_value" qualifiers="virtual">
<return type="Variant" /> <return type="Variant" />
<argument index="0" name="gizmo" type="EditorSpatialGizmo" /> <argument index="0" name="gizmo" type="EditorSpatialGizmo" />
<argument index="1" name="id" type="int" /> <argument index="1" name="id" type="int" />
<argument index="2" name="secondary" type="bool" />
<description> <description>
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.
</description> </description>
</method> </method>
<method name="get_material"> <method name="get_material">
@ -149,8 +156,9 @@
<return type="bool" /> <return type="bool" />
<argument index="0" name="gizmo" type="EditorSpatialGizmo" /> <argument index="0" name="gizmo" type="EditorSpatialGizmo" />
<argument index="1" name="id" type="int" /> <argument index="1" name="id" type="int" />
<argument index="2" name="secondary" type="bool" />
<description> <description>
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.
</description> </description>
</method> </method>
<method name="is_selectable_when_hidden" qualifiers="virtual"> <method name="is_selectable_when_hidden" qualifiers="virtual">
@ -170,10 +178,13 @@
<return type="void" /> <return type="void" />
<argument index="0" name="gizmo" type="EditorSpatialGizmo" /> <argument index="0" name="gizmo" type="EditorSpatialGizmo" />
<argument index="1" name="id" type="int" /> <argument index="1" name="id" type="int" />
<argument index="2" name="camera" type="Camera" /> <argument index="2" name="secondary" type="bool" />
<argument index="3" name="point" type="Vector2" /> <argument index="3" name="camera" type="Camera" />
<argument index="4" name="point" type="Vector2" />
<description> <description>
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.
</description> </description>
</method> </method>
<method name="_set_subgizmo_transform" qualifiers="virtual"> <method name="_set_subgizmo_transform" qualifiers="virtual">

View File

@ -30,9 +30,6 @@
#include "path_editor_plugin.h" #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/class_db.h"
#include "core/color.h" #include "core/color.h"
#include "core/math/basis.h" #include "core/math/basis.h"
@ -41,6 +38,7 @@
#include "core/math/plane.h" #include "core/math/plane.h"
#include "core/math/transform.h" #include "core/math/transform.h"
#include "core/os/input_event.h" #include "core/os/input_event.h"
#include "core/os/keyboard.h"
#include "core/os/memory.h" #include "core/os/memory.h"
#include "core/pool_vector.h" #include "core/pool_vector.h"
#include "core/undo_redo.h" #include "core/undo_redo.h"
@ -56,22 +54,24 @@
#include "scene/gui/separator.h" #include "scene/gui/separator.h"
#include "scene/gui/tool_button.h" #include "scene/gui/tool_button.h"
#include "scene/main/node.h" #include "scene/main/node.h"
#include "scene/resources/curve.h"
#include "scene/resources/material.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<Curve3D> c = path->get_curve(); Ref<Curve3D> c = path->get_curve();
if (c.is_null()) { if (c.is_null()) {
return ""; return "";
} }
if (p_idx < c->get_point_count()) { if (!p_secondary) {
return TTR("Curve Point #") + itos(p_idx); 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 idx = p_id / 2;
int t = p_idx % 2; int t = p_id % 2;
String n = TTR("Curve Point #") + itos(idx); String n = TTR("Curve Point #") + itos(idx);
if (t == 0) { if (t == 0) {
n += " In"; n += " In";
@ -81,21 +81,21 @@ String PathSpatialGizmo::get_handle_name(int p_idx) const {
return n; return n;
} }
Variant PathSpatialGizmo::get_handle_value(int p_idx) { Variant PathSpatialGizmo::get_handle_value(int p_id, bool p_secondary) {
Ref<Curve3D> c = path->get_curve(); Ref<Curve3D> c = path->get_curve();
if (c.is_null()) { if (c.is_null()) {
return Variant(); return Variant();
} }
if (p_idx < c->get_point_count()) { if (!p_secondary) {
original = c->get_point_position(p_idx); original = c->get_point_position(p_id);
return original; 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 idx = p_id / 2;
int t = p_idx % 2; int t = p_id % 2;
Vector3 ofs; Vector3 ofs;
if (t == 0) { if (t == 0) {
@ -108,7 +108,7 @@ Variant PathSpatialGizmo::get_handle_value(int p_idx) {
return ofs; 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<Curve3D> c = path->get_curve(); Ref<Curve3D> c = path->get_curve();
if (c.is_null()) { if (c.is_null()) {
return; 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); Vector3 ray_dir = p_camera->project_ray_normal(p_point);
// Setting curve point positions // 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)); Plane p(gt.xform(original), p_camera->get_transform().basis.get_axis(2));
Vector3 inters; 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); Vector3 local = gi.xform(inters);
c->set_point_position(p_idx, local); c->set_point_position(p_id, local);
} }
return; 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 idx = p_id / 2;
int t = p_idx % 2; int t = p_id % 2;
Vector3 base = c->get_point_position(idx); 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<Curve3D> c = path->get_curve(); Ref<Curve3D> c = path->get_curve();
if (c.is_null()) { if (c.is_null()) {
return; 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(); UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
if (p_idx < c->get_point_count()) { if (!p_secondary) {
if (p_cancel) { if (p_cancel) {
c->set_point_position(p_idx, p_restore); c->set_point_position(p_id, p_restore);
return; return;
} }
ur->create_action(TTR("Set Curve Point Position")); 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_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_idx, p_restore); ur->add_undo_method(c.ptr(), "set_point_position", p_id, p_restore);
ur->commit_action(); ur->commit_action();
return; 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 idx = p_id / 2;
int t = p_idx % 2; int t = p_id % 2;
if (t == 0) { if (t == 0) {
if (p_cancel) { if (p_cancel) {
c->set_point_in(p_idx, p_restore); c->set_point_in(p_id, p_restore);
return; return;
} }
@ -513,10 +513,10 @@ void PathEditorPlugin::make_visible(bool p_visible) {
} }
} }
void PathEditorPlugin::_mode_changed(int p_idx) { void PathEditorPlugin::_mode_changed(int p_id) {
curve_create->set_pressed(p_idx == 0); curve_create->set_pressed(p_id == 0);
curve_edit->set_pressed(p_idx == 1); curve_edit->set_pressed(p_id == 1);
curve_del->set_pressed(p_idx == 2); curve_del->set_pressed(p_id == 2);
} }
void PathEditorPlugin::_close_curve() { void PathEditorPlugin::_close_curve() {

View File

@ -59,10 +59,10 @@ class PathSpatialGizmo : public EditorSpatialGizmo {
mutable float orig_out_length; mutable float orig_out_length;
public: public:
virtual String get_handle_name(int p_idx) const; virtual String get_handle_name(int p_id, bool p_secondary) const;
virtual Variant get_handle_value(int p_idx); virtual Variant get_handle_value(int p_id, bool p_secondary);
virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point); virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false); virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual void redraw(); virtual void redraw();
PathSpatialGizmo(Path *p_path = nullptr); PathSpatialGizmo(Path *p_path = nullptr);

View File

@ -474,6 +474,7 @@ Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) const {
void SpatialEditorViewport::_clear_selected() { void SpatialEditorViewport::_clear_selected() {
_edit.gizmo = Ref<EditorSpatialGizmo>(); _edit.gizmo = Ref<EditorSpatialGizmo>();
_edit.gizmo_handle = -1; _edit.gizmo_handle = -1;
_edit.gizmo_handle_secondary = false;
_edit.gizmo_initial_value = Variant(); _edit.gizmo_initial_value = Variant();
Spatial *selected = spatial_editor->get_single_selected_node(); Spatial *selected = spatial_editor->get_single_selected_node();
@ -1431,7 +1432,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (b->is_pressed() && _edit.gizmo.is_valid()) { if (b->is_pressed() && _edit.gizmo.is_valid()) {
//restore //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<EditorSpatialGizmo>(); _edit.gizmo = Ref<EditorSpatialGizmo>();
} }
@ -1570,11 +1571,13 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} }
int gizmo_handle = -1; 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) { if (gizmo_handle != -1) {
_edit.gizmo = seg; _edit.gizmo = seg;
_edit.gizmo_handle = gizmo_handle; _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; intersected_handle = true;
break; break;
} }
@ -1690,7 +1693,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
surface->update(); surface->update();
} else { } else {
if (_edit.gizmo.is_valid()) { 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<EditorSpatialGizmo>(); _edit.gizmo = Ref<EditorSpatialGizmo>();
break; break;
} }
@ -1767,6 +1770,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Ref<EditorSpatialGizmo> found_gizmo; Ref<EditorSpatialGizmo> found_gizmo;
int found_handle = -1; int found_handle = -1;
bool found_handle_secondary = false;
for (int i = 0; i < gizmos.size(); i++) { for (int i = 0; i < gizmos.size(); i++) {
Ref<EditorSpatialGizmo> seg = gizmos[i]; Ref<EditorSpatialGizmo> seg = gizmos[i];
@ -1774,7 +1778,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
continue; 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) { if (found_handle != -1) {
found_gizmo = seg; found_gizmo = seg;
@ -1786,9 +1790,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
spatial_editor->select_gizmo_highlight_axis(-1); 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(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(); spatial_editor->get_single_selected_node()->update_gizmos();
} }
} }
@ -1801,9 +1807,9 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
NavigationMode nav_mode = NAVIGATION_NONE; NavigationMode nav_mode = NAVIGATION_NONE;
if (_edit.gizmo.is_valid()) { if (_edit.gizmo.is_valid()) {
_edit.gizmo->set_handle(_edit.gizmo_handle, camera, m->get_position()); _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); Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle, _edit.gizmo_handle_secondary);
String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle); String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle, _edit.gizmo_handle_secondary);
set_message(n + ": " + String(v)); set_message(n + ": " + String(v));
} else if (m->get_button_mask() & BUTTON_MASK_LEFT) { } 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.plane = TRANSFORM_VIEW;
_edit.snap = true; _edit.snap = true;
_edit.gizmo_handle = -1; _edit.gizmo_handle = -1;
_edit.gizmo_handle_secondary = false;
index = p_index; index = p_index;
editor = p_editor; editor = p_editor;
@ -5390,6 +5397,7 @@ void SpatialEditor::edit(Spatial *p_spatial) {
selected = p_spatial; selected = p_spatial;
current_hover_gizmo = Ref<EditorSpatialGizmo>(); current_hover_gizmo = Ref<EditorSpatialGizmo>();
current_hover_gizmo_handle = -1; current_hover_gizmo_handle = -1;
current_hover_gizmo_handle_secondary = false;
if (selected) { if (selected) {
Vector<Ref<SpatialGizmo>> gizmos = selected->get_gizmos(); Vector<Ref<SpatialGizmo>> gizmos = selected->get_gizmos();
@ -7505,6 +7513,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true); EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true);
current_hover_gizmo_handle = -1; current_hover_gizmo_handle = -1;
current_hover_gizmo_handle_secondary = false;
// make sure the portal tools are off by default // make sure the portal tools are off by default
// (when no RoomManager is present) // (when no RoomManager is present)

View File

@ -334,6 +334,7 @@ public:
bool snap; bool snap;
Ref<EditorSpatialGizmo> gizmo; Ref<EditorSpatialGizmo> gizmo;
int gizmo_handle; int gizmo_handle;
bool gizmo_handle_secondary;
Variant gizmo_initial_value; Variant gizmo_initial_value;
} _edit; } _edit;
@ -601,6 +602,7 @@ private:
Ref<SpatialGizmo> current_hover_gizmo; Ref<SpatialGizmo> current_hover_gizmo;
int current_hover_gizmo_handle; int current_hover_gizmo_handle;
bool current_hover_gizmo_handle_secondary;
float snap_translate_value; float snap_translate_value;
float snap_rotate_value; float snap_rotate_value;
@ -813,8 +815,15 @@ public:
Ref<EditorSpatialGizmo> get_current_hover_gizmo() const { return current_hover_gizmo; } Ref<EditorSpatialGizmo> get_current_hover_gizmo() const { return current_hover_gizmo; }
void set_current_hover_gizmo(Ref<EditorSpatialGizmo> p_gizmo) { current_hover_gizmo = p_gizmo; } void set_current_hover_gizmo(Ref<EditorSpatialGizmo> p_gizmo) { current_hover_gizmo = p_gizmo; }
void set_current_hover_gizmo_handle(int p_id) { current_hover_gizmo_handle = p_id; } void set_current_hover_gizmo_handle(int p_id, bool p_secondary) {
int get_current_hover_gizmo_handle() const { return current_hover_gizmo_handle; } 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_can_preview(Camera *p_preview);
void set_message(String p_message, float p_time = 5); void set_message(String p_message, float p_time = 5);

View File

@ -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")) { 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, ""); 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")) { 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); 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")) { 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()); 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")) { 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; return;
} }
ERR_FAIL_COND(!gizmo_plugin); 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")) { 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; return;
} }
ERR_FAIL_COND(!gizmo_plugin); 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 { int EditorSpatialGizmo::subgizmos_intersect_ray(Camera *p_camera, const Vector2 &p_point) const {
@ -494,7 +494,8 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref
} }
bool is_current_hover_gizmo = SpatialEditor::get_singleton()->get_current_hover_gizmo() == this; 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; Instance ins;
@ -509,12 +510,12 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref
PoolVector<Color>::Write w = colors.write(); PoolVector<Color>::Write w = colors.write();
for (int i = 0; i < p_handles.size(); i++) { for (int i = 0; i < p_handles.size(); i++) {
Color col(1, 1, 1, 1); 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); col = Color(0, 0, 1, 0.9);
} }
int id = p_ids.empty() ? i : p_ids[i]; 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; col.a = 0.8;
} }
@ -658,8 +659,9 @@ bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector<
return false; 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_id = -1;
r_secondary = false;
ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid); ERR_FAIL_COND(!valid);
@ -689,6 +691,7 @@ void EditorSpatialGizmo::handles_intersect_ray(Camera *p_camera, const Vector2 &
} else { } else {
r_id = secondary_handle_ids[i]; 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; r_id = i;
} else { } else {
r_id = handle_ids[i]; 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); ClassDB::bind_method(D_METHOD("get_subgizmo_selection"), &EditorSpatialGizmo::get_subgizmo_selection);
BIND_VMETHOD(MethodInfo("redraw")); BIND_VMETHOD(MethodInfo("redraw"));
BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", 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"))); 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; hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
BIND_VMETHOD(hvget); 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"))); 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::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); 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); cm.default_arguments.push_back(false);
BIND_VMETHOD(cm); BIND_VMETHOD(cm);
@ -1147,15 +1150,15 @@ void EditorSpatialGizmoPlugin::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_selectable_when_hidden")); BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_selectable_when_hidden"));
BIND_VMETHOD(MethodInfo("redraw", GIZMO_REF)); BIND_VMETHOD(MethodInfo("redraw", GIZMO_REF));
BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", 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"))); 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; hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
BIND_VMETHOD(hvget); 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"))); 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::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); 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); cm.default_arguments.push_back(false);
BIND_VMETHOD(cm); 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")) { 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; 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")) { 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 ""; 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")) { 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(); 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")) { 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")) { 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; 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) { if (p_id == 0) {
return "Radius"; return "Radius";
} else { } 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<Light>(p_gizmo->get_spatial_node()); Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node());
if (p_id == 0) { if (p_id == 0) {
return light->get_param(Light::PARAM_RANGE); 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; 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<Light>(p_gizmo->get_spatial_node()); Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node());
Transform gt = light->get_global_transform(); Transform gt = light->get_global_transform();
Transform gi = gt.affine_inverse(); 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<Light>(p_gizmo->get_spatial_node()); Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node());
if (p_cancel) { if (p_cancel) {
light->set_param(p_id == 0 ? Light::PARAM_RANGE : Light::PARAM_SPOT_ANGLE, p_restore); 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; 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"; 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<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
return player->get_emission_angle(); 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<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
Transform gt = player->get_global_transform(); 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<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
if (p_cancel) { if (p_cancel) {
@ -1775,7 +1778,7 @@ int CameraSpatialGizmoPlugin::get_priority() const {
return -1; 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<Camera>(p_gizmo->get_spatial_node()); Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { 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<Camera>(p_gizmo->get_spatial_node()); Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { 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<Camera>(p_gizmo->get_spatial_node()); Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
Transform gt = camera->get_global_transform(); 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<Camera>(p_gizmo->get_spatial_node()); Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
@ -2518,21 +2521,21 @@ void SoftBodySpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_collision_triangles(tm); 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"; 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<SoftBody>(p_gizmo->get_spatial_node()); SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node());
return Variant(soft_body->is_point_pinned(p_id)); 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<SoftBody>(p_gizmo->get_spatial_node()); SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node());
soft_body->pin_point_toggle(p_id); 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<SoftBody>(p_gizmo->get_spatial_node()); SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node());
return soft_body->is_point_pinned(idx); return soft_body->is_point_pinned(idx);
} }
@ -2559,7 +2562,7 @@ int VisibilityNotifierGizmoPlugin::get_priority() const {
return -1; 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) { switch (p_id) {
case 0: case 0:
return "Size X"; return "Size X";
@ -2578,11 +2581,11 @@ String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorSpatialGizmo *
return ""; 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<VisibilityNotifier>(p_gizmo->get_spatial_node()); VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node());
return notifier->get_aabb(); 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<VisibilityNotifier>(p_gizmo->get_spatial_node()); VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node());
Transform gt = notifier->get_global_transform(); 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<VisibilityNotifier>(p_gizmo->get_spatial_node()); VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node());
if (p_cancel) { if (p_cancel) {
@ -2752,7 +2755,7 @@ int ReflectionProbeGizmoPlugin::get_priority() const {
return -1; 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) { switch (p_id) {
case 0: case 0:
return "Extents X"; return "Extents X";
@ -2770,11 +2773,11 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_g
return ""; 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<ReflectionProbe>(p_gizmo->get_spatial_node()); ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
return AABB(probe->get_extents(), probe->get_origin_offset()); 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<ReflectionProbe>(p_gizmo->get_spatial_node()); ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
Transform gt = probe->get_global_transform(); 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<ReflectionProbe>(p_gizmo->get_spatial_node()); ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
AABB restore = p_restore; AABB restore = p_restore;
@ -2985,7 +2988,7 @@ int CollisionShapeSpatialGizmoPlugin::get_priority() const {
return -1; 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<CollisionShape>(p_gizmo->get_spatial_node()); const CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
Ref<Shape> s = cs->get_shape(); Ref<Shape> s = cs->get_shape();
@ -3016,7 +3019,7 @@ String CollisionShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizm
return ""; 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<CollisionShape>(p_gizmo->get_spatial_node()); CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
Ref<Shape> s = cs->get_shape(); Ref<Shape> s = cs->get_shape();
@ -3051,7 +3054,7 @@ Variant CollisionShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p
return Variant(); 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<CollisionShape>(p_gizmo->get_spatial_node()); CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
Ref<Shape> s = cs->get_shape(); Ref<Shape> 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<CollisionShape>(p_gizmo->get_spatial_node()); CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
Ref<Shape> s = cs->get_shape(); Ref<Shape> 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); 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) { if (!_room) {
return Vector3(0, 0, 0); return Vector3(0, 0, 0);
} }
@ -4462,7 +4465,7 @@ Variant RoomSpatialGizmo::get_handle_value(int p_id) {
return _room->_bound_pts[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())) { if (!_room || (p_id >= _room->_bound_pts.size())) {
return; 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())) { if (!_room || (p_id >= _room->_bound_pts.size())) {
return; 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); 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) { if (!_portal) {
return Vector2(0, 0); return Vector2(0, 0);
} }
@ -4669,7 +4672,7 @@ Variant PortalSpatialGizmo::get_handle_value(int p_id) {
return _portal->_pts_local_raw[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())) { if (!_portal || (p_id >= _portal->_pts_local_raw.size())) {
return; 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())) { if (!_portal || (p_id >= _portal->_pts_local_raw.size())) {
return; 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(); const OccluderShapeSphere *occ_sphere = get_occluder_shape_sphere();
if (occ_sphere) { if (occ_sphere) {
int num_spheres = occ_sphere->get_spheres().size(); int num_spheres = occ_sphere->get_spheres().size();
@ -4976,7 +4979,7 @@ String OccluderSpatialGizmo::get_handle_name(int p_id) const {
return "Unknown"; 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(); const OccluderShapeSphere *occ_sphere = get_occluder_shape_sphere();
if (occ_sphere) { if (occ_sphere) {
Vector<Plane> spheres = occ_sphere->get_spheres(); Vector<Plane> spheres = occ_sphere->get_spheres();
@ -5006,7 +5009,7 @@ Variant OccluderSpatialGizmo::get_handle_value(int p_id) {
return 0; 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) { if (!_occluder) {
return; 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(); UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
OccluderShapeSphere *occ_sphere = get_occluder_shape_sphere(); OccluderShapeSphere *occ_sphere = get_occluder_shape_sphere();

View File

@ -107,11 +107,11 @@ public:
void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, const Vector<int> &p_ids = Vector<int>(), bool p_billboard = false, bool p_secondary = false); void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, const Vector<int> &p_ids = Vector<int>(), bool p_billboard = false, bool p_secondary = false);
void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform &p_xform = Transform()); void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform &p_xform = Transform());
virtual bool is_handle_highlighted(int p_id) const; virtual bool is_handle_highlighted(int p_id, bool p_secondary) const;
virtual String get_handle_name(int p_id) const; virtual String get_handle_name(int p_id, bool p_secondary) const;
virtual Variant get_handle_value(int p_id); virtual Variant get_handle_value(int p_id, bool p_secondary);
virtual void set_handle(int p_id, Camera *p_camera, const Point2 &p_point); virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false); 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 int subgizmos_intersect_ray(Camera *p_camera, const Vector2 &p_point) const;
virtual Vector<int> subgizmos_intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum) const; virtual Vector<int> subgizmos_intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum) const;
@ -126,7 +126,7 @@ public:
Spatial *get_spatial_node() const { return spatial_node; } Spatial *get_spatial_node() const { return spatial_node; }
Ref<EditorSpatialGizmoPlugin> get_plugin() const { return gizmo_plugin; } Ref<EditorSpatialGizmoPlugin> get_plugin() const { return gizmo_plugin; }
bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum); bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &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 intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal);
bool is_subgizmo_selected(int p_id) const; bool is_subgizmo_selected(int p_id) const;
Vector<int> get_subgizmo_selection() const; Vector<int> get_subgizmo_selection() const;
@ -177,11 +177,11 @@ public:
virtual bool is_selectable_when_hidden() const; virtual bool is_selectable_when_hidden() const;
virtual void redraw(EditorSpatialGizmo *p_gizmo); virtual void redraw(EditorSpatialGizmo *p_gizmo);
virtual bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_id) const; 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) 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) 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, Camera *p_camera, const Point2 &p_point); 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, const Variant &p_restore, bool p_cancel = false); 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 int subgizmos_intersect_ray(const EditorSpatialGizmo *p_gizmo, Camera *p_camera, const Vector2 &p_point) const;
virtual Vector<int> subgizmos_intersect_frustum(const EditorSpatialGizmo *p_gizmo, const Camera *p_camera, const Vector<Plane> &p_frustum) const; virtual Vector<int> subgizmos_intersect_frustum(const EditorSpatialGizmo *p_gizmo, const Camera *p_camera, const Vector<Plane> &p_frustum) const;
@ -207,10 +207,10 @@ public:
String get_gizmo_name() const; String get_gizmo_name() const;
int get_priority() const; int get_priority() const;
String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) 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) const; Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point); 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, const Variant &p_restore, bool p_cancel = false); 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); void redraw(EditorSpatialGizmo *p_gizmo);
LightSpatialGizmoPlugin(); LightSpatialGizmoPlugin();
@ -224,10 +224,10 @@ public:
String get_gizmo_name() const; String get_gizmo_name() const;
int get_priority() const; int get_priority() const;
String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) 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) const; Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point); 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, const Variant &p_restore, bool p_cancel = false); 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); void redraw(EditorSpatialGizmo *p_gizmo);
AudioStreamPlayer3DSpatialGizmoPlugin(); AudioStreamPlayer3DSpatialGizmoPlugin();
@ -254,10 +254,10 @@ public:
String get_gizmo_name() const; String get_gizmo_name() const;
int get_priority() const; int get_priority() const;
String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) 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) const; Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point); 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, const Variant &p_restore, bool p_cancel = false); 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); void redraw(EditorSpatialGizmo *p_gizmo);
CameraSpatialGizmoPlugin(); CameraSpatialGizmoPlugin();
@ -375,10 +375,10 @@ public:
bool is_selectable_when_hidden() const; bool is_selectable_when_hidden() const;
void redraw(EditorSpatialGizmo *p_gizmo); void redraw(EditorSpatialGizmo *p_gizmo);
String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) 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) const; Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel); 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) const; bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx, bool p_secondary) const;
SoftBodySpatialGizmoPlugin(); SoftBodySpatialGizmoPlugin();
}; };
@ -392,10 +392,10 @@ public:
int get_priority() const; int get_priority() const;
void redraw(EditorSpatialGizmo *p_gizmo); void redraw(EditorSpatialGizmo *p_gizmo);
String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) 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) const; Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point); 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, const Variant &p_restore, bool p_cancel = false); void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
VisibilityNotifierGizmoPlugin(); VisibilityNotifierGizmoPlugin();
}; };
@ -421,10 +421,10 @@ public:
int get_priority() const; int get_priority() const;
void redraw(EditorSpatialGizmo *p_gizmo); void redraw(EditorSpatialGizmo *p_gizmo);
String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) 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) const; Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point); 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, const Variant &p_restore, bool p_cancel = false); void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
ReflectionProbeGizmoPlugin(); ReflectionProbeGizmoPlugin();
}; };
@ -450,10 +450,10 @@ public:
int get_priority() const; int get_priority() const;
void redraw(EditorSpatialGizmo *p_gizmo); void redraw(EditorSpatialGizmo *p_gizmo);
String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_id) 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) const; Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary) const;
void set_handle(EditorSpatialGizmo *p_gizmo, int p_id, Camera *p_camera, const Point2 &p_point); 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, const Variant &p_restore, bool p_cancel = false); void commit_handle(EditorSpatialGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
CollisionShapeSpatialGizmoPlugin(); CollisionShapeSpatialGizmoPlugin();
}; };
@ -562,10 +562,10 @@ class RoomSpatialGizmo : public EditorSpatialGizmo {
Room *_room = nullptr; Room *_room = nullptr;
public: public:
virtual String get_handle_name(int p_id) const; virtual String get_handle_name(int p_id, bool p_secondary) const;
virtual Variant get_handle_value(int p_id); virtual Variant get_handle_value(int p_id, bool p_secondary);
virtual void set_handle(int p_id, Camera *p_camera, const Point2 &p_point); virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false); virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual void redraw(); virtual void redraw();
RoomSpatialGizmo(Room *p_room = nullptr); RoomSpatialGizmo(Room *p_room = nullptr);
@ -594,10 +594,10 @@ class PortalSpatialGizmo : public EditorSpatialGizmo {
Color _color_portal_back; Color _color_portal_back;
public: public:
virtual String get_handle_name(int p_id) const; virtual String get_handle_name(int p_id, bool p_secondary) const;
virtual Variant get_handle_value(int p_id); virtual Variant get_handle_value(int p_id, bool p_secondary);
virtual void set_handle(int p_id, Camera *p_camera, const Point2 &p_point); virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false); virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual void redraw(); virtual void redraw();
PortalSpatialGizmo(Portal *p_portal = nullptr); PortalSpatialGizmo(Portal *p_portal = nullptr);
@ -640,10 +640,10 @@ class OccluderSpatialGizmo : public EditorSpatialGizmo {
void _redraw_poly(bool p_hole, const Vector<Vector2> &p_pts, const PoolVector<Vector2> &p_pts_raw); void _redraw_poly(bool p_hole, const Vector<Vector2> &p_pts, const PoolVector<Vector2> &p_pts_raw);
public: public:
virtual String get_handle_name(int p_id) const; virtual String get_handle_name(int p_id, bool p_secondary) const;
virtual Variant get_handle_value(int p_id); virtual Variant get_handle_value(int p_id, bool p_secondary);
virtual void set_handle(int p_id, Camera *p_camera, const Point2 &p_point); virtual void set_handle(int p_id, bool p_secondary, Camera *p_camera, const Point2 &p_point);
virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false); virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false);
virtual void redraw(); virtual void redraw();
OccluderSpatialGizmo(Occluder *p_occluder = nullptr); OccluderSpatialGizmo(Occluder *p_occluder = nullptr);

View File

@ -47,7 +47,7 @@ void MDIGizmo::set_editor_plugin(EditorPlugin *editor_plugin) {
_undo_redo = EditorNode::get_undo_redo(); _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; Vector2 relative = point - previous_point;
if (!_handle_drag_op) { if (!_handle_drag_op) {

View File

@ -77,7 +77,7 @@ public:
void setup(); void setup();
void set_editor_plugin(EditorPlugin *editor_plugin); 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 redraw();
void apply(); void apply();

View File

@ -32,8 +32,8 @@ String MDIGizmoPlugin::get_gizmo_name() const {
int MDIGizmoPlugin::get_priority() const { int MDIGizmoPlugin::get_priority() const {
return 100; return 100;
} }
bool MDIGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const { 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); return EditorSpatialGizmoPlugin::is_handle_highlighted(p_gizmo, p_idx, p_secondary);
} }
Ref<EditorSpatialGizmo> MDIGizmoPlugin::create_gizmo(Spatial *p_spatial) { Ref<EditorSpatialGizmo> MDIGizmoPlugin::create_gizmo(Spatial *p_spatial) {

View File

@ -34,7 +34,7 @@ public:
void _init(); void _init();
String get_gizmo_name() const; String get_gizmo_name() const;
int get_priority() 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();
~MDIGizmoPlugin(); ~MDIGizmoPlugin();