From 3003e19ab1bb64b75ab71e64e063998f50c7b7e4 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Mon, 28 Aug 2017 01:21:54 -0500 Subject: [PATCH 1/2] Highlight currently selected gizmo. Work with, GIProbe, ReflectionProbe and Particles. --- editor/spatial_editor_gizmos.cpp | 33 ++++++++++++++++++++++++++++++++ editor/spatial_editor_gizmos.h | 1 + 2 files changed, 34 insertions(+) diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index fb5143b4860..6a49e240126 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -36,6 +36,7 @@ #include "scene/resources/capsule_shape.h" #include "scene/resources/convex_polygon_shape.h" #include "scene/resources/plane_shape.h" +#include "scene/resources/primitive_meshes.h" #include "scene/resources/ray_shape.h" #include "scene/resources/sphere_shape.h" #include "scene/resources/surface_tool.h" @@ -296,6 +297,15 @@ void EditorSpatialGizmo::add_handles(const Vector &p_handles, bool p_bi } } +void EditorSpatialGizmo::add_solid_box(Ref &p_material, Vector3 size) { + CubeMesh cubem; + cubem.set_size(size); + Ref m = memnew(ArrayMesh); + m->add_surface_from_arrays(cubem.surface_get_primitive_type(0), cubem.surface_get_arrays(0)); + m->surface_set_material(0, p_material); + add_mesh(m); +} + void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) { ERR_FAIL_NULL(p_node); @@ -2334,6 +2344,14 @@ void ParticlesGizmo::redraw() { add_lines(lines, material); add_collision_segments(lines); + + if (is_selected()) { + + gizmo_color.a = 0.1; + Ref solid_material = create_material("particles_solid_material", gizmo_color); + add_solid_box(solid_material, aabb.get_size()); + } + //add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05); add_handles(handles); } @@ -2487,6 +2505,14 @@ void ReflectionProbeGizmo::redraw() { add_lines(lines, material); add_lines(internal_lines, material_internal); + + if (is_selected()) { + + gizmo_color.a = 0.1; + Ref solid_material = create_material("reflection_probe_solid_material", gizmo_color); + add_solid_box(solid_material, probe->get_extents() * 2.0); + } + //add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05); add_collision_segments(lines); add_handles(handles); @@ -2639,6 +2665,13 @@ void GIProbeGizmo::redraw() { handles.push_back(ax); } + if (is_selected()) { + + gizmo_color.a = 0.1; + Ref solid_material = create_material("gi_probe_solid_material", gizmo_color); + add_solid_box(solid_material, aabb.get_size()); + } + add_handles(handles); } GIProbeGizmo::GIProbeGizmo(GIProbe *p_probe) { diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index a7c74977631..d63a804055c 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -102,6 +102,7 @@ protected: void add_collision_triangles(const Ref &p_tmesh); void add_unscaled_billboard(const Ref &p_material, float p_scale = 1); void add_handles(const Vector &p_handles, bool p_billboard = false, bool p_secondary = false); + void add_solid_box(Ref &p_material, Vector3 size); void set_spatial_node(Spatial *p_node); From 07e8d7270e2bf9ef30aa50b66828ca56fa8aa882 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Mon, 28 Aug 2017 13:32:28 -0500 Subject: [PATCH 2/2] Improved directional light arrow and gizmo highlighting --- editor/spatial_editor_gizmos.cpp | 47 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 6a49e240126..be30369dfed 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -131,9 +131,9 @@ void EditorSpatialGizmo::add_lines(const Vector &p_lines, const Ref::Write w = color.write(); for (int i = 0; i < p_lines.size(); i++) { if (is_selected()) - w[i] = Color(1, 1, 1, 0.6); + w[i] = Color(1, 1, 1, 0.8); else - w[i] = Color(1, 1, 1, 0.25); + w[i] = Color(1, 1, 1, 0.2); } } @@ -550,8 +550,9 @@ Ref EditorSpatialGizmo::create_material(const String &p_name, c if (!is_editable()) { color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instanced"); - } else if (!is_selected()) { - color.a *= 0.5; + } + if (!is_selected()) { + color.a *= 0.3; } Ref line_material; @@ -597,7 +598,7 @@ Ref EditorSpatialGizmo::create_icon_material(const String &p_na if (!is_editable()) { color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instanced"); } else if (!is_selected()) { - color.a *= 0.5; + color.a *= 0.3; } Ref icon; @@ -780,34 +781,32 @@ void LightSpatialGizmo::redraw() { Ref material = create_material("light_directional_material", gizmo_color); Ref icon = create_icon_material("light_directional_icon", SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons")); - const int arrow_points = 5; + const int arrow_points = 7; + const float arrow_length = 1.5; + Vector3 arrow[arrow_points] = { - Vector3(0, 0, 2), - Vector3(1, 1, 2), - Vector3(1, 1, -1), - Vector3(2, 2, -1), - Vector3(0, 0, -3) + Vector3(0, 0, -1), + Vector3(0, 0.8, 0), + Vector3(0, 0.3, 0), + Vector3(0, 0.3, arrow_length), + Vector3(0, -0.3, arrow_length), + Vector3(0, -0.3, 0), + Vector3(0, -0.8, 0) }; - int arrow_sides = 4; + int arrow_sides = 2; Vector lines; for (int i = 0; i < arrow_sides; i++) { + for (int j = 0; j < arrow_points; j++) { + Basis ma(Vector3(0, 0, 1), Math_PI * i / arrow_sides); - Basis ma(Vector3(0, 0, 1), Math_PI * 2 * float(i) / arrow_sides); - Basis mb(Vector3(0, 0, 1), Math_PI * 2 * float(i + 1) / arrow_sides); + Vector3 v1 = arrow[j] - Vector3(0, 0, arrow_length); + Vector3 v2 = arrow[(j + 1) % arrow_points] - Vector3(0, 0, arrow_length); - for (int j = 1; j < arrow_points - 1; j++) { - - if (j != 2) { - lines.push_back(ma.xform(arrow[j])); - lines.push_back(ma.xform(arrow[j + 1])); - } - if (j < arrow_points - 1) { - lines.push_back(ma.xform(arrow[j])); - lines.push_back(mb.xform(arrow[j])); - } + lines.push_back(ma.xform(v1)); + lines.push_back(ma.xform(v2)); } }