diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-08-21 17:19:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-21 17:19:34 +0200 |
commit | 2ffc1c4105dd2788d0f35917b9db3d6066837bf9 (patch) | |
tree | 140d63a1a0c0473c6719cac8a00cb7a79711cacf /editor/spatial_editor_gizmos.cpp | |
parent | 6c1263f8ec365c9e7061ea2a7406fc79f6f793e0 (diff) | |
parent | a350fd4a5755fdaaecef820e181ddda4ce866830 (diff) |
Merge pull request #31534 from Calinou/3d-editor-distinguish-disabled-shapes
Draw 3D collision shape/raycast gizmos in grayscale when disabled
Diffstat (limited to 'editor/spatial_editor_gizmos.cpp')
-rw-r--r-- | editor/spatial_editor_gizmos.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index f7ba5e5e3c..4c5371769f 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -2037,8 +2037,11 @@ PortalSpatialGizmo::PortalSpatialGizmo(Portal *p_portal) { RayCastSpatialGizmoPlugin::RayCastSpatialGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); + const float gizmo_value = gizmo_color.get_v(); + const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); + create_material("shape_material_disabled", gizmo_color_disabled); } bool RayCastSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { @@ -2064,7 +2067,8 @@ void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { lines.push_back(Vector3()); lines.push_back(raycast->get_cast_to()); - Ref<SpatialMaterial> material = get_material("shape_material", p_gizmo); + const Ref<SpatialMaterial> material = + get_material(raycast->is_enabled() ? "shape_material" : "shape_material_disabled", p_gizmo); p_gizmo->add_lines(lines, material); p_gizmo->add_collision_segments(lines); @@ -3108,8 +3112,11 @@ void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { //// CollisionShapeSpatialGizmoPlugin::CollisionShapeSpatialGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); + const float gizmo_value = gizmo_color.get_v(); + const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); + create_material("shape_material_disabled", gizmo_color_disabled); create_handle_material("handles"); } @@ -3432,7 +3439,8 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { if (s.is_null()) return; - Ref<Material> material = get_material("shape_material", p_gizmo); + const Ref<Material> material = + get_material(!cs->is_disabled() ? "shape_material" : "shape_material_disabled", p_gizmo); Ref<Material> handles_material = get_material("handles"); if (Object::cast_to<SphereShape>(*s)) { @@ -3733,8 +3741,11 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ///// CollisionPolygonSpatialGizmoPlugin::CollisionPolygonSpatialGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); + const float gizmo_value = gizmo_color.get_v(); + const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); + create_material("shape_material_disabled", gizmo_color_disabled); } bool CollisionPolygonSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { @@ -3770,7 +3781,8 @@ void CollisionPolygonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { lines.push_back(Vector3(points[i].x, points[i].y, -depth)); } - Ref<Material> material = get_material("shape_material", p_gizmo); + const Ref<Material> material = + get_material(!polygon->is_disabled() ? "shape_material" : "shape_material_disabled", p_gizmo); p_gizmo->add_lines(lines, material); p_gizmo->add_collision_segments(lines); |