Merge pull request #53889 from Klowner/surfacetool-generate-lod-assert-crash

Add check to SurfaceTool.generate_lod(); ensure target index count >=…
This commit is contained in:
Rémi Verschelde 2021-10-18 07:51:43 +02:00 committed by GitHub
commit b6ee9ed8c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1174,9 +1174,11 @@ Vector<int> SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun
Vector<int> lod;
ERR_FAIL_COND_V(simplify_func == nullptr, lod);
ERR_FAIL_COND_V(p_target_index_count < 0, lod);
ERR_FAIL_COND_V(vertex_array.size() == 0, lod);
ERR_FAIL_COND_V(index_array.size() == 0, lod);
ERR_FAIL_COND_V(index_array.size() % 3 != 0, lod);
ERR_FAIL_COND_V(index_array.size() < (unsigned int)p_target_index_count, lod);
lod.resize(index_array.size());
LocalVector<float> vertices; //uses floats