Do not require editor restart when changing Path 3d Tilt Disk Size setting
This commit is contained in:
committed by
Robert Yevdokimov
parent
ef34c3d534
commit
3cfcedd6d5
@ -409,6 +409,8 @@ void Path3DGizmo::redraw() {
|
||||
|
||||
_secondary_handles_info.resize(c->get_point_count() * 3);
|
||||
|
||||
const float disk_size = EDITOR_GET("editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size");
|
||||
|
||||
for (int idx = 0; idx < c->get_point_count(); idx++) {
|
||||
// Collect primary-handles.
|
||||
const Vector3 pos = c->get_point_position(idx);
|
||||
@ -539,9 +541,8 @@ void Path3DGizmo::_update_transform_gizmo() {
|
||||
Node3DEditor::get_singleton()->update_transform_gizmo();
|
||||
}
|
||||
|
||||
Path3DGizmo::Path3DGizmo(Path3D *p_path, float p_disk_size) {
|
||||
Path3DGizmo::Path3DGizmo(Path3D *p_path) {
|
||||
path = p_path;
|
||||
disk_size = p_disk_size;
|
||||
set_node_3d(p_path);
|
||||
orig_in_length = 0;
|
||||
orig_out_length = 0;
|
||||
@ -685,6 +686,7 @@ EditorPlugin::AfterGUIInput Path3DEditorPlugin::forward_3d_gui_input(Camera3D *p
|
||||
}
|
||||
|
||||
} else if (mb->is_pressed() && ((mb->get_button_index() == MouseButton::LEFT && curve_del->is_pressed()) || (mb->get_button_index() == MouseButton::RIGHT && curve_edit->is_pressed()))) {
|
||||
const float disk_size = EDITOR_GET("editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size");
|
||||
for (int i = 0; i < c->get_point_count(); i++) {
|
||||
real_t dist_to_p = viewport->point_to_screen(gt.xform(c->get_point_position(i))).distance_to(mbpos);
|
||||
real_t dist_to_p_out = viewport->point_to_screen(gt.xform(c->get_point_position(i) + c->get_point_out(i))).distance_to(mbpos);
|
||||
@ -869,6 +871,22 @@ void Path3DEditorPlugin::_update_toolbar() {
|
||||
create_curve_button->set_visible(!has_curve);
|
||||
}
|
||||
|
||||
void Path3DEditorPlugin::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
if (!path) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EditorSettings::get_singleton()->check_changed_settings_in_group("editors/3d_gizmos/gizmo_settings")) {
|
||||
return;
|
||||
}
|
||||
|
||||
path->update_gizmos();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void Path3DEditorPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_update_toolbar"), &Path3DEditorPlugin::_update_toolbar);
|
||||
ClassDB::bind_method(D_METHOD("_clear_curve_points"), &Path3DEditorPlugin::_clear_curve_points);
|
||||
@ -880,9 +898,8 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
||||
mirror_handle_angle = true;
|
||||
mirror_handle_length = true;
|
||||
|
||||
disk_size = EDITOR_GET("editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size");
|
||||
|
||||
Ref<Path3DGizmoPlugin> gizmo_plugin = memnew(Path3DGizmoPlugin(disk_size));
|
||||
Ref<Path3DGizmoPlugin> gizmo_plugin;
|
||||
gizmo_plugin.instantiate();
|
||||
Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
|
||||
path_3d_gizmo_plugin = gizmo_plugin;
|
||||
|
||||
@ -985,7 +1002,7 @@ Ref<EditorNode3DGizmo> Path3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
|
||||
|
||||
Path3D *path = Object::cast_to<Path3D>(p_spatial);
|
||||
if (path) {
|
||||
ref.instantiate(path, disk_size);
|
||||
ref.instantiate(path);
|
||||
}
|
||||
|
||||
return ref;
|
||||
@ -1163,10 +1180,9 @@ int Path3DGizmoPlugin::get_priority() const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Path3DGizmoPlugin::Path3DGizmoPlugin(float p_disk_size) {
|
||||
Path3DGizmoPlugin::Path3DGizmoPlugin() {
|
||||
Color path_color = SceneTree::get_singleton()->get_debug_paths_color();
|
||||
Color path_tilt_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/path_tilt");
|
||||
disk_size = p_disk_size;
|
||||
|
||||
create_material("path_material", path_color);
|
||||
create_material("path_thin_material", Color(0.6, 0.6, 0.6));
|
||||
|
||||
@ -59,7 +59,6 @@ class Path3DGizmo : public EditorNode3DGizmo {
|
||||
mutable Vector3 original;
|
||||
mutable float orig_in_length;
|
||||
mutable float orig_out_length;
|
||||
mutable float disk_size = 0.8;
|
||||
|
||||
// Index that should have swapped control points for achieving an outwards curve.
|
||||
int swapped_control_points_idx = -1;
|
||||
@ -77,14 +76,12 @@ public:
|
||||
virtual void commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
|
||||
|
||||
virtual void redraw() override;
|
||||
Path3DGizmo(Path3D *p_path = nullptr, float p_disk_size = 0.8);
|
||||
Path3DGizmo(Path3D *p_path = nullptr);
|
||||
};
|
||||
|
||||
class Path3DGizmoPlugin : public EditorNode3DGizmoPlugin {
|
||||
GDCLASS(Path3DGizmoPlugin, EditorNode3DGizmoPlugin);
|
||||
|
||||
float disk_size = 0.8;
|
||||
|
||||
// Locking basis is meant to ensure a predictable behavior during translation of the curve points in "local space transform mode".
|
||||
// Without the locking, the gizmo/point, in "local space transform mode", wouldn't follow a straight path and would curve and twitch in an unpredictable way.
|
||||
HashMap<int, Basis> transformation_locked_basis;
|
||||
@ -105,7 +102,7 @@ public:
|
||||
virtual void commit_subgizmos(const EditorNode3DGizmo *p_gizmo, const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel = false) override;
|
||||
|
||||
int get_priority() const override;
|
||||
Path3DGizmoPlugin(float p_disk_size);
|
||||
Path3DGizmoPlugin();
|
||||
};
|
||||
|
||||
class Path3DEditorPlugin : public EditorPlugin {
|
||||
@ -131,8 +128,6 @@ class Path3DEditorPlugin : public EditorPlugin {
|
||||
Button *create_curve_button = nullptr;
|
||||
ConfirmationDialog *clear_points_dialog = nullptr;
|
||||
|
||||
float disk_size = 0.8;
|
||||
|
||||
enum Mode {
|
||||
MODE_CREATE,
|
||||
MODE_EDIT,
|
||||
@ -166,6 +161,7 @@ class Path3DEditorPlugin : public EditorPlugin {
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
|
||||
@ -902,7 +902,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||
EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_colors/ik_chain", Color(0.6, 0.9, 0.8), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
|
||||
_initial_set("editors/3d_gizmos/gizmo_settings/bone_axis_length", (float)0.1);
|
||||
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d_gizmos/gizmo_settings/bone_shape", 1, "Wire,Octahedron");
|
||||
EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size", 0.8, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
|
||||
EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size", 0.8, "", PROPERTY_USAGE_DEFAULT)
|
||||
EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d_gizmos/gizmo_settings/lightmap_gi_probe_size", 0.4, "0.0,1.0,0.001,or_greater", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
|
||||
|
||||
// If a line is a multiple of this, it uses the primary grid color.
|
||||
|
||||
Reference in New Issue
Block a user