Highlight currently selected gizmo.

Work with, GIProbe, ReflectionProbe and Particles.
This commit is contained in:
Daniel J. Ramirez 2017-08-28 01:21:54 -05:00
parent 8fce79aaee
commit 3003e19ab1
2 changed files with 34 additions and 0 deletions

View file

@ -36,6 +36,7 @@
#include "scene/resources/capsule_shape.h" #include "scene/resources/capsule_shape.h"
#include "scene/resources/convex_polygon_shape.h" #include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/plane_shape.h" #include "scene/resources/plane_shape.h"
#include "scene/resources/primitive_meshes.h"
#include "scene/resources/ray_shape.h" #include "scene/resources/ray_shape.h"
#include "scene/resources/sphere_shape.h" #include "scene/resources/sphere_shape.h"
#include "scene/resources/surface_tool.h" #include "scene/resources/surface_tool.h"
@ -296,6 +297,15 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi
} }
} }
void EditorSpatialGizmo::add_solid_box(Ref<Material> &p_material, Vector3 size) {
CubeMesh cubem;
cubem.set_size(size);
Ref<ArrayMesh> 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) { void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) {
ERR_FAIL_NULL(p_node); ERR_FAIL_NULL(p_node);
@ -2334,6 +2344,14 @@ void ParticlesGizmo::redraw() {
add_lines(lines, material); add_lines(lines, material);
add_collision_segments(lines); add_collision_segments(lines);
if (is_selected()) {
gizmo_color.a = 0.1;
Ref<Material> 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_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_handles(handles); add_handles(handles);
} }
@ -2487,6 +2505,14 @@ void ReflectionProbeGizmo::redraw() {
add_lines(lines, material); add_lines(lines, material);
add_lines(internal_lines, material_internal); add_lines(internal_lines, material_internal);
if (is_selected()) {
gizmo_color.a = 0.1;
Ref<Material> 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_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_collision_segments(lines); add_collision_segments(lines);
add_handles(handles); add_handles(handles);
@ -2639,6 +2665,13 @@ void GIProbeGizmo::redraw() {
handles.push_back(ax); handles.push_back(ax);
} }
if (is_selected()) {
gizmo_color.a = 0.1;
Ref<Material> solid_material = create_material("gi_probe_solid_material", gizmo_color);
add_solid_box(solid_material, aabb.get_size());
}
add_handles(handles); add_handles(handles);
} }
GIProbeGizmo::GIProbeGizmo(GIProbe *p_probe) { GIProbeGizmo::GIProbeGizmo(GIProbe *p_probe) {

View file

@ -102,6 +102,7 @@ protected:
void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh); void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh);
void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1); void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1);
void add_handles(const Vector<Vector3> &p_handles, bool p_billboard = false, bool p_secondary = false); void add_handles(const Vector<Vector3> &p_handles, bool p_billboard = false, bool p_secondary = false);
void add_solid_box(Ref<Material> &p_material, Vector3 size);
void set_spatial_node(Spatial *p_node); void set_spatial_node(Spatial *p_node);