Fix SurfaceTool crash when passing invalid Mesh
This commit is contained in:
parent
33a0fb6e02
commit
524d27493b
1 changed files with 8 additions and 0 deletions
|
@ -663,6 +663,8 @@ void SurfaceTool::deindex() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, LocalVector<Vertex> *r_vertex, LocalVector<int> *r_index, uint32_t &lformat) {
|
void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, LocalVector<Vertex> *r_vertex, LocalVector<int> *r_index, uint32_t &lformat) {
|
||||||
|
ERR_FAIL_NULL_MSG(p_existing, "First argument in SurfaceTool::_create_list() must be a valid object of type Mesh");
|
||||||
|
|
||||||
Array arr = p_existing->surface_get_arrays(p_surface);
|
Array arr = p_existing->surface_get_arrays(p_surface);
|
||||||
ERR_FAIL_COND(arr.size() != RS::ARRAY_MAX);
|
ERR_FAIL_COND(arr.size() != RS::ARRAY_MAX);
|
||||||
_create_list_from_arrays(arr, r_vertex, r_index, lformat);
|
_create_list_from_arrays(arr, r_vertex, r_index, lformat);
|
||||||
|
@ -824,6 +826,8 @@ void SurfaceTool::create_from_triangle_arrays(const Array &p_arrays) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceTool::create_from(const Ref<Mesh> &p_existing, int p_surface) {
|
void SurfaceTool::create_from(const Ref<Mesh> &p_existing, int p_surface) {
|
||||||
|
ERR_FAIL_NULL_MSG(p_existing, "First argument in SurfaceTool::create_from() must be a valid object of type Mesh");
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
primitive = p_existing->surface_get_primitive_type(p_surface);
|
primitive = p_existing->surface_get_primitive_type(p_surface);
|
||||||
_create_list(p_existing, p_surface, &vertex_array, &index_array, format);
|
_create_list(p_existing, p_surface, &vertex_array, &index_array, format);
|
||||||
|
@ -831,6 +835,8 @@ void SurfaceTool::create_from(const Ref<Mesh> &p_existing, int p_surface) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_surface, const String &p_blend_shape_name) {
|
void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_surface, const String &p_blend_shape_name) {
|
||||||
|
ERR_FAIL_NULL_MSG(p_existing, "First argument in SurfaceTool::create_from_blend_shape() must be a valid object of type Mesh");
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
primitive = p_existing->surface_get_primitive_type(p_surface);
|
primitive = p_existing->surface_get_primitive_type(p_surface);
|
||||||
Array arr = p_existing->surface_get_blend_shape_arrays(p_surface);
|
Array arr = p_existing->surface_get_blend_shape_arrays(p_surface);
|
||||||
|
@ -851,6 +857,8 @@ void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_sur
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const Transform &p_xform) {
|
void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const Transform &p_xform) {
|
||||||
|
ERR_FAIL_NULL_MSG(p_existing, "First argument in SurfaceTool::append_from() must be a valid object of type Mesh");
|
||||||
|
|
||||||
if (vertex_array.size() == 0) {
|
if (vertex_array.size() == 0) {
|
||||||
primitive = p_existing->surface_get_primitive_type(p_surface);
|
primitive = p_existing->surface_get_primitive_type(p_surface);
|
||||||
format = 0;
|
format = 0;
|
||||||
|
|
Loading…
Reference in a new issue