From 3205a92ad872f918c8322cdcd1434c231a1fd251 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 17 Feb 2020 18:06:54 -0300 Subject: PoolVector is gone, replaced by Vector Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector`. --- scene/resources/mesh_data_tool.cpp | 116 ++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 58 deletions(-) (limited to 'scene/resources/mesh_data_tool.cpp') diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp index 7a303443e3..675cfc6d64 100644 --- a/scene/resources/mesh_data_tool.cpp +++ b/scene/resources/mesh_data_tool.cpp @@ -47,7 +47,7 @@ Error MeshDataTool::create_from_surface(const Ref &p_mesh, int p_surf Array arrays = p_mesh->surface_get_arrays(p_surface); ERR_FAIL_COND_V(arrays.empty(), ERR_INVALID_PARAMETER); - PoolVector varray = arrays[Mesh::ARRAY_VERTEX]; + Vector varray = arrays[Mesh::ARRAY_VERTEX]; int vcount = varray.size(); ERR_FAIL_COND_V(vcount == 0, ERR_INVALID_PARAMETER); @@ -56,34 +56,34 @@ Error MeshDataTool::create_from_surface(const Ref &p_mesh, int p_surf format = p_mesh->surface_get_format(p_surface); material = p_mesh->surface_get_material(p_surface); - PoolVector::Read vr = varray.read(); + const Vector3 *vr = varray.ptr(); - PoolVector::Read nr; + const Vector3 *nr; if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL) - nr = arrays[Mesh::ARRAY_NORMAL].operator PoolVector().read(); + nr = arrays[Mesh::ARRAY_NORMAL].operator Vector().ptr(); - PoolVector::Read ta; + const real_t *ta; if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL) - ta = arrays[Mesh::ARRAY_TANGENT].operator PoolVector().read(); + ta = arrays[Mesh::ARRAY_TANGENT].operator Vector().ptr(); - PoolVector::Read uv; + const Vector2 *uv; if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL) - uv = arrays[Mesh::ARRAY_TEX_UV].operator PoolVector().read(); - PoolVector::Read uv2; + uv = arrays[Mesh::ARRAY_TEX_UV].operator Vector().ptr(); + const Vector2 *uv2; if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL) - uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator PoolVector().read(); + uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator Vector().ptr(); - PoolVector::Read col; + const Color *col; if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL) - col = arrays[Mesh::ARRAY_COLOR].operator PoolVector().read(); + col = arrays[Mesh::ARRAY_COLOR].operator Vector().ptr(); - PoolVector::Read bo; + const int *bo; if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL) - bo = arrays[Mesh::ARRAY_BONES].operator PoolVector().read(); + bo = arrays[Mesh::ARRAY_BONES].operator Vector().ptr(); - PoolVector::Read we; + const real_t *we; if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL) - we = arrays[Mesh::ARRAY_WEIGHTS].operator PoolVector().read(); + we = arrays[Mesh::ARRAY_WEIGHTS].operator Vector().ptr(); vertices.resize(vcount); @@ -91,18 +91,18 @@ Error MeshDataTool::create_from_surface(const Ref &p_mesh, int p_surf Vertex v; v.vertex = vr[i]; - if (nr.ptr()) + if (nr) v.normal = nr[i]; - if (ta.ptr()) + if (ta) v.tangent = Plane(ta[i * 4 + 0], ta[i * 4 + 1], ta[i * 4 + 2], ta[i * 4 + 3]); - if (uv.ptr()) + if (uv) v.uv = uv[i]; - if (uv2.ptr()) + if (uv2) v.uv2 = uv2[i]; - if (col.ptr()) + if (col) v.color = col[i]; - if (we.ptr()) { + if (we) { v.weights.push_back(we[i * 4 + 0]); v.weights.push_back(we[i * 4 + 1]); @@ -110,7 +110,7 @@ Error MeshDataTool::create_from_surface(const Ref &p_mesh, int p_surf v.weights.push_back(we[i * 4 + 3]); } - if (bo.ptr()) { + if (bo) { v.bones.push_back(bo[i * 4 + 0]); v.bones.push_back(bo[i * 4 + 1]); @@ -121,7 +121,7 @@ Error MeshDataTool::create_from_surface(const Ref &p_mesh, int p_surf vertices.write[i] = v; } - PoolVector indices; + Vector indices; if (arrays[Mesh::ARRAY_INDEX].get_type() != Variant::NIL) { @@ -129,13 +129,13 @@ Error MeshDataTool::create_from_surface(const Ref &p_mesh, int p_surf } else { //make code simpler indices.resize(vcount); - PoolVector::Write iw = indices.write(); + int *iw = indices.ptrw(); for (int i = 0; i < vcount; i++) iw[i] = i; } int icount = indices.size(); - PoolVector::Read r = indices.read(); + const int *r = indices.ptr(); Map edge_indices; @@ -187,61 +187,61 @@ Error MeshDataTool::commit_to_surface(const Ref &p_mesh) { int vcount = vertices.size(); - PoolVector v; - PoolVector n; - PoolVector t; - PoolVector u; - PoolVector u2; - PoolVector c; - PoolVector b; - PoolVector w; - PoolVector in; + Vector v; + Vector n; + Vector t; + Vector u; + Vector u2; + Vector c; + Vector b; + Vector w; + Vector in; { v.resize(vcount); - PoolVector::Write vr = v.write(); + Vector3 *vr = v.ptrw(); - PoolVector::Write nr; + Vector3 *nr; if (format & Mesh::ARRAY_FORMAT_NORMAL) { n.resize(vcount); - nr = n.write(); + nr = n.ptrw(); } - PoolVector::Write ta; + real_t *ta; if (format & Mesh::ARRAY_FORMAT_TANGENT) { t.resize(vcount * 4); - ta = t.write(); + ta = t.ptrw(); } - PoolVector::Write uv; + Vector2 *uv; if (format & Mesh::ARRAY_FORMAT_TEX_UV) { u.resize(vcount); - uv = u.write(); + uv = u.ptrw(); } - PoolVector::Write uv2; + Vector2 *uv2; if (format & Mesh::ARRAY_FORMAT_TEX_UV2) { u2.resize(vcount); - uv2 = u2.write(); + uv2 = u2.ptrw(); } - PoolVector::Write col; + Color *col; if (format & Mesh::ARRAY_FORMAT_COLOR) { c.resize(vcount); - col = c.write(); + col = c.ptrw(); } - PoolVector::Write bo; + int *bo; if (format & Mesh::ARRAY_FORMAT_BONES) { b.resize(vcount * 4); - bo = b.write(); + bo = b.ptrw(); } - PoolVector::Write we; + real_t *we; if (format & Mesh::ARRAY_FORMAT_WEIGHTS) { w.resize(vcount * 4); - we = w.write(); + we = w.ptrw(); } for (int i = 0; i < vcount; i++) { @@ -249,22 +249,22 @@ Error MeshDataTool::commit_to_surface(const Ref &p_mesh) { const Vertex &vtx = vertices[i]; vr[i] = vtx.vertex; - if (nr.ptr()) + if (nr) nr[i] = vtx.normal; - if (ta.ptr()) { + if (ta) { ta[i * 4 + 0] = vtx.tangent.normal.x; ta[i * 4 + 1] = vtx.tangent.normal.y; ta[i * 4 + 2] = vtx.tangent.normal.z; ta[i * 4 + 3] = vtx.tangent.d; } - if (uv.ptr()) + if (uv) uv[i] = vtx.uv; - if (uv2.ptr()) + if (uv2) uv2[i] = vtx.uv2; - if (col.ptr()) + if (col) col[i] = vtx.color; - if (we.ptr()) { + if (we) { we[i * 4 + 0] = vtx.weights[0]; we[i * 4 + 1] = vtx.weights[1]; @@ -272,7 +272,7 @@ Error MeshDataTool::commit_to_surface(const Ref &p_mesh) { we[i * 4 + 3] = vtx.weights[3]; } - if (bo.ptr()) { + if (bo) { bo[i * 4 + 0] = vtx.bones[0]; bo[i * 4 + 1] = vtx.bones[1]; @@ -283,7 +283,7 @@ Error MeshDataTool::commit_to_surface(const Ref &p_mesh) { int fc = faces.size(); in.resize(fc * 3); - PoolVector::Write iw = in.write(); + int *iw = in.ptrw(); for (int i = 0; i < fc; i++) { iw[i * 3 + 0] = faces[i].v[0]; -- cgit v1.2.3