diff options
author | PrecisionRender <austin08dean@gmail.com> | 2022-07-30 10:21:53 -0500 |
---|---|---|
committer | PrecisionRender <austin08dean@gmail.com> | 2022-07-30 10:21:53 -0500 |
commit | 2f46749f4e53420894f648873e01fd91ce8bcf3f (patch) | |
tree | 1ba1370976535d8edf418ad2c46818c1b7d5bc0a | |
parent | 335fc2a94675de9c063743301fe4ce02bf344d63 (diff) |
Fix `ShapeCast3D` creating runtime shape in editor
-rw-r--r-- | editor/plugins/node_3d_editor_gizmos.cpp | 5 | ||||
-rw-r--r-- | scene/3d/shape_cast_3d.cpp | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 5c66026c1b..0070226d40 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -2569,9 +2569,12 @@ void ShapeCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { const Ref<StandardMaterial3D> material = shapecast->is_enabled() ? shapecast->get_debug_material() : get_material("shape_material_disabled"); - p_gizmo->add_lines(shapecast->get_debug_shape_vertices(), material); p_gizmo->add_lines(shapecast->get_debug_line_vertices(), material); + if (shapecast->get_shape().is_valid()) { + p_gizmo->add_lines(shapecast->get_debug_shape_vertices(), material); + } + p_gizmo->add_collision_segments(shapecast->get_debug_line_vertices()); } diff --git a/scene/3d/shape_cast_3d.cpp b/scene/3d/shape_cast_3d.cpp index df8bd7dfc9..ac804280fe 100644 --- a/scene/3d/shape_cast_3d.cpp +++ b/scene/3d/shape_cast_3d.cpp @@ -577,14 +577,18 @@ void ShapeCast3D::_update_debug_shape() { _create_debug_shape(); } + _update_debug_shape_vertices(); + + if (Engine::get_singleton()->is_editor_hint()) { + return; + } + MeshInstance3D *mi = static_cast<MeshInstance3D *>(debug_shape); Ref<ArrayMesh> mesh = mi->get_mesh(); if (!mesh.is_valid()) { return; } - _update_debug_shape_vertices(); - mesh->clear_surfaces(); Array a; |