diff options
Diffstat (limited to 'scene/resources/surface_tool.cpp')
-rw-r--r-- | scene/resources/surface_tool.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 06d53e4e2f..9f2fad410c 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -802,7 +802,7 @@ void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, Local const uint32_t SurfaceTool::custom_mask[RS::ARRAY_CUSTOM_COUNT] = { Mesh::ARRAY_FORMAT_CUSTOM0, Mesh::ARRAY_FORMAT_CUSTOM1, Mesh::ARRAY_FORMAT_CUSTOM2, Mesh::ARRAY_FORMAT_CUSTOM3 }; const uint32_t SurfaceTool::custom_shift[RS::ARRAY_CUSTOM_COUNT] = { Mesh::ARRAY_FORMAT_CUSTOM0_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM1_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM2_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM3_SHIFT }; -void SurfaceTool::create_vertex_array_from_triangle_arrays(const Array &p_arrays, LocalVector<SurfaceTool::Vertex> &ret, uint64_t *r_format) { +void SurfaceTool::create_vertex_array_from_arrays(const Array &p_arrays, LocalVector<SurfaceTool::Vertex> &ret, uint64_t *r_format) { ret.clear(); Vector<Vector3> varr = p_arrays[RS::ARRAY_VERTEX]; @@ -932,7 +932,7 @@ void SurfaceTool::create_vertex_array_from_triangle_arrays(const Array &p_arrays } void SurfaceTool::_create_list_from_arrays(Array arr, LocalVector<Vertex> *r_vertex, LocalVector<int> *r_index, uint64_t &lformat) { - create_vertex_array_from_triangle_arrays(arr, *r_vertex, &lformat); + create_vertex_array_from_arrays(arr, *r_vertex, &lformat); ERR_FAIL_COND(r_vertex->size() == 0); //indices @@ -949,9 +949,9 @@ void SurfaceTool::_create_list_from_arrays(Array arr, LocalVector<Vertex> *r_ver } } -void SurfaceTool::create_from_triangle_arrays(const Array &p_arrays) { +void SurfaceTool::create_from_arrays(const Array &p_arrays, Mesh::PrimitiveType p_primitive_type) { clear(); - primitive = Mesh::PRIMITIVE_TRIANGLES; + primitive = p_primitive_type; _create_list_from_arrays(p_arrays, &vertex_array, &index_array, format); for (int j = 0; j < RS::ARRAY_CUSTOM_COUNT; j++) { @@ -961,6 +961,10 @@ void SurfaceTool::create_from_triangle_arrays(const Array &p_arrays) { } } +void SurfaceTool::create_from_triangle_arrays(const Array &p_arrays) { + create_from_arrays(p_arrays, Mesh::PRIMITIVE_TRIANGLES); +} + 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"); @@ -1377,6 +1381,7 @@ void SurfaceTool::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &SurfaceTool::clear); ClassDB::bind_method(D_METHOD("create_from", "existing", "surface"), &SurfaceTool::create_from); + ClassDB::bind_method(D_METHOD("create_from_arrays", "arrays", "primitive_type"), &SurfaceTool::create_from_arrays, DEFVAL(Mesh::PRIMITIVE_TRIANGLES)); ClassDB::bind_method(D_METHOD("create_from_blend_shape", "existing", "surface", "blend_shape"), &SurfaceTool::create_from_blend_shape); ClassDB::bind_method(D_METHOD("append_from", "existing", "surface", "transform"), &SurfaceTool::append_from); ClassDB::bind_method(D_METHOD("commit", "existing", "flags"), &SurfaceTool::commit, DEFVAL(Variant()), DEFVAL(0)); |