aboutsummaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorPoommetee Ketson2018-04-01 22:06:47 +0700
committerHein-Pieter van Braam2018-04-28 20:16:22 +0200
commitc5dfe6824c6faf91121cfec14ca960c61c53259e (patch)
treedeac5157e1484d031ce6b628a6de8dd4e40d445c /editor/plugins
parent640063334de0b3a034c64fe8a2a631be04a62dc4 (diff)
downloadgodot-c5dfe6824c6faf91121cfec14ca960c61c53259e.tar.gz
godot-c5dfe6824c6faf91121cfec14ca960c61c53259e.tar.zst
godot-c5dfe6824c6faf91121cfec14ca960c61c53259e.zip
Mesh: fix crash when creating mesh outline from QuadMesh
Since create_outline can only make outline for PRIMITIVE_TRIANGLES, when QuadMesh (which is PRIMITIVE_TRIANGLE_FAN) is used to create outline, will leave `arrays` empty, and crash when it is being indexed for "indices" subarray. This PR shows error when there's only one surface and it is not TRIANGLES. Also prevent the crash if it has more than one surface and none of them are TRIANGLES (and any other cases that could leave `arrays` empty) by checking the size of `arrays` == 8 before indexing it, since the method seems to expect `arrays` to be of that size. (cherry picked from commit a492d229529018f0277f75aa7b99661b5dd40420)
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp
index cb5f7ba76..7ea2b2774 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());