Browse Source

Merge pull request #63679 from PrecisionRender/master

Fix `ShapeCast3D` creating runtime shape in editor
Rémi Verschelde 3 years ago
parent
commit
cca072aa86
2 changed files with 10 additions and 3 deletions
  1. 4 1
      editor/plugins/node_3d_editor_gizmos.cpp
  2. 6 2
      scene/3d/shape_cast_3d.cpp

+ 4 - 1
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());
 }
 

+ 6 - 2
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;