diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-04-03 11:55:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-03 11:55:01 +0200 |
commit | a10be201de2aac2a239568970e02dce04261bc3b (patch) | |
tree | 7c3bd8d659b7c1553b9a8f770f0d6d794921bbb7 | |
parent | 5dc514acedc136d596085bfd6454947bcf36bfc3 (diff) | |
parent | a492d229529018f0277f75aa7b99661b5dd40420 (diff) |
Merge pull request #17902 from Noshyaar/outline
Mesh: fix crash when creating mesh outline from QuadMesh
-rw-r--r-- | editor/plugins/mesh_instance_editor_plugin.cpp | 4 | ||||
-rw-r--r-- | scene/resources/mesh.cpp | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp index cb5f7ba76c..7ea2b27744 100644 --- a/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_editor_plugin.cpp @@ -344,6 +344,10 @@ void MeshInstanceEditor::_create_outline_mesh() { err_dialog->set_text(TTR("Mesh has not surface to create outlines from!")); err_dialog->popup_centered_minsize(); return; + } else if (mesh->get_surface_count() == 1 && mesh->surface_get_primitive_type(0) != Mesh::PRIMITIVE_TRIANGLES) { + err_dialog->set_text(TTR("Mesh primitive type is not PRIMITIVE_TRIANGLES!")); + err_dialog->popup_centered_minsize(); + return; } Ref<Mesh> mesho = mesh->create_outline(outline_size->get_value()); diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 949ba12a4c..b832ea1239 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -315,6 +315,8 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const { } } + ERR_FAIL_COND_V(arrays.size() != ARRAY_MAX, Ref<ArrayMesh>()); + { PoolVector<int>::Write ir; PoolVector<int> indices = arrays[ARRAY_INDEX]; |