summaryrefslogtreecommitdiff
path: root/scene/resources/mesh.cpp
diff options
context:
space:
mode:
authorPoommetee Ketson <poommetee@protonmail.com>2018-04-01 22:06:47 +0700
committerPoommetee Ketson <poommetee@protonmail.com>2018-04-01 22:06:47 +0700
commita492d229529018f0277f75aa7b99661b5dd40420 (patch)
treeca8d018d9671eba4fc1acd0ecad280637e8f4166 /scene/resources/mesh.cpp
parentd2eb731878a4d660dd4a6babaea5967183b8f324 (diff)
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.
Diffstat (limited to 'scene/resources/mesh.cpp')
-rw-r--r--scene/resources/mesh.cpp2
1 files changed, 2 insertions, 0 deletions
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];