Skip to content

Commit 7af3c5a

Browse files
committed
Merge pull request godotengine#99569 from yahkr/hide_colliders
Add option to toggle always showing collision shapes
2 parents b812eed + 845bc49 commit 7af3c5a

5 files changed

Lines changed: 22 additions & 0 deletions

File tree

doc/classes/EditorSettings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@
599599
<member name="editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size" type="float" setter="" getter="">
600600
Size of the disk gizmo displayed when editing [Path3D]'s tilt handles.
601601
</member>
602+
<member name="editors/3d_gizmos/gizmo_settings/show_collision_shapes_only_when_selected" type="bool" setter="" getter="">
603+
If [code]true[/code], collision shapes in the 3D editor are visible only when selected. If [code]false[/code], collision shapes are always visible.
604+
</member>
602605
<member name="editors/animation/autorename_animation_tracks" type="bool" setter="" getter="">
603606
If [code]true[/code], automatically updates animation tracks' target paths when renaming or reparenting nodes in the Scene tree dock.
604607
</member>

editor/scene/3d/gizmos/physics/collision_shape_3d_gizmo_plugin.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "editor/editor_undo_redo_manager.h"
3636
#include "editor/scene/3d/gizmos/gizmo_3d_helper.h"
3737
#include "editor/scene/3d/node_3d_editor_plugin.h"
38+
#include "editor/settings/editor_settings.h"
3839
#include "scene/3d/physics/collision_shape_3d.h"
3940
#include "scene/resources/3d/box_shape_3d.h"
4041
#include "scene/resources/3d/capsule_shape_3d.h"
@@ -49,6 +50,8 @@
4950
CollisionShape3DGizmoPlugin::CollisionShape3DGizmoPlugin() {
5051
helper.instantiate();
5152

53+
show_only_when_selected = EDITOR_GET("editors/3d_gizmos/gizmo_settings/show_collision_shapes_only_when_selected");
54+
5255
create_collision_material("shape_material", 2.0);
5356
create_collision_material("shape_material_arraymesh", 0.0625);
5457

@@ -307,6 +310,10 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
307310
return;
308311
}
309312

313+
if (show_only_when_selected && !p_gizmo->is_selected()) {
314+
return;
315+
}
316+
310317
const Ref<StandardMaterial3D> material =
311318
get_material(!cs->is_disabled() ? "shape_material" : "shape_material_disabled", p_gizmo);
312319
const Ref<StandardMaterial3D> material_arraymesh =
@@ -667,3 +674,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
667674
p_gizmo->add_lines(lines, material, false, collision_color);
668675
}
669676
}
677+
678+
void CollisionShape3DGizmoPlugin::set_show_only_when_selected(bool p_enabled) {
679+
show_only_when_selected = p_enabled;
680+
}

editor/scene/3d/gizmos/physics/collision_shape_3d_gizmo_plugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ class CollisionShape3DGizmoPlugin : public EditorNode3DGizmoPlugin {
4141

4242
Ref<Gizmo3DHelper> helper;
4343

44+
inline static bool show_only_when_selected = false;
45+
4446
public:
4547
bool has_gizmo(Node3D *p_spatial) override;
4648
String get_gizmo_name() const override;
4749
int get_priority() const override;
4850
void redraw(EditorNode3DGizmo *p_gizmo) override;
51+
static void set_show_only_when_selected(bool p_enabled);
4952

5053
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override;
5154
Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override;

editor/scene/3d/node_3d_editor_plugin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9023,6 +9023,10 @@ void Node3DEditor::_notification(int p_what) {
90239023
}
90249024
update_gizmo_opacity();
90259025
}
9026+
if (EditorSettings::get_singleton()->check_changed_settings_in_group("editors/3d_gizmos/gizmo_settings")) {
9027+
CollisionShape3DGizmoPlugin::set_show_only_when_selected(EDITOR_GET("editors/3d_gizmos/gizmo_settings/show_collision_shapes_only_when_selected"));
9028+
update_all_gizmos();
9029+
}
90269030
} break;
90279031

90289032
case NOTIFICATION_PHYSICS_PROCESS: {

editor/settings/editor_settings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
907907
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d_gizmos/gizmo_settings/bone_shape", 1, "Wire,Octahedron");
908908
EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size", 0.8, "0.01,4.0,0.001,or_greater", PROPERTY_USAGE_DEFAULT)
909909
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)
910+
_initial_set("editors/3d_gizmos/gizmo_settings/show_collision_shapes_only_when_selected", false);
910911

911912
// If a line is a multiple of this, it uses the primary grid color.
912913
// Use a power of 2 value by default as it's more common to use powers of 2 in level design.

0 commit comments

Comments
 (0)