Draw 3D collision shape/raycast gizmos in grayscale when disabled
This makes them easier to distinguish from their enabled counterparts, as is already done in the 2D editor.
This commit is contained in:
parent
48eaf14030
commit
a350fd4a57
3 changed files with 22 additions and 6 deletions
|
@ -2037,8 +2037,11 @@ PortalSpatialGizmo::PortalSpatialGizmo(Portal *p_portal) {
|
||||||
|
|
||||||
RayCastSpatialGizmoPlugin::RayCastSpatialGizmoPlugin() {
|
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);
|
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) {
|
bool RayCastSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
|
||||||
|
@ -2064,7 +2067,8 @@ void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||||
lines.push_back(Vector3());
|
lines.push_back(Vector3());
|
||||||
lines.push_back(raycast->get_cast_to());
|
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_lines(lines, material);
|
||||||
p_gizmo->add_collision_segments(lines);
|
p_gizmo->add_collision_segments(lines);
|
||||||
|
@ -3108,8 +3112,11 @@ void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||||
////
|
////
|
||||||
|
|
||||||
CollisionShapeSpatialGizmoPlugin::CollisionShapeSpatialGizmoPlugin() {
|
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);
|
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");
|
create_handle_material("handles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3432,7 +3439,8 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||||
if (s.is_null())
|
if (s.is_null())
|
||||||
return;
|
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");
|
Ref<Material> handles_material = get_material("handles");
|
||||||
|
|
||||||
if (Object::cast_to<SphereShape>(*s)) {
|
if (Object::cast_to<SphereShape>(*s)) {
|
||||||
|
@ -3733,8 +3741,11 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||||
/////
|
/////
|
||||||
|
|
||||||
CollisionPolygonSpatialGizmoPlugin::CollisionPolygonSpatialGizmoPlugin() {
|
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);
|
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) {
|
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));
|
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_lines(lines, material);
|
||||||
p_gizmo->add_collision_segments(lines);
|
p_gizmo->add_collision_segments(lines);
|
||||||
|
|
|
@ -151,6 +151,8 @@ float CollisionPolygon::get_depth() const {
|
||||||
|
|
||||||
void CollisionPolygon::set_disabled(bool p_disabled) {
|
void CollisionPolygon::set_disabled(bool p_disabled) {
|
||||||
disabled = p_disabled;
|
disabled = p_disabled;
|
||||||
|
update_gizmo();
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent->shape_owner_set_disabled(owner_id, p_disabled);
|
parent->shape_owner_set_disabled(owner_id, p_disabled);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,8 @@ Vector3 RayCast::get_collision_normal() const {
|
||||||
void RayCast::set_enabled(bool p_enabled) {
|
void RayCast::set_enabled(bool p_enabled) {
|
||||||
|
|
||||||
enabled = p_enabled;
|
enabled = p_enabled;
|
||||||
|
update_gizmo();
|
||||||
|
|
||||||
if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
|
if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
|
||||||
set_physics_process_internal(p_enabled);
|
set_physics_process_internal(p_enabled);
|
||||||
if (!p_enabled)
|
if (!p_enabled)
|
||||||
|
|
Loading…
Reference in a new issue