diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 13:23:58 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:54:55 +0200 |
commit | 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch) | |
tree | a27e497da7104dd0a64f98a04fa3067668735e91 /scene/resources/mesh_data_tool.cpp | |
parent | 710b34b70227becdc652b4ae027fe0ac47409642 (diff) | |
download | redot-engine-0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a.tar.gz |
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.
This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.
There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).
Part of #33027.
Diffstat (limited to 'scene/resources/mesh_data_tool.cpp')
-rw-r--r-- | scene/resources/mesh_data_tool.cpp | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp index 76d96786bc..d428191f96 100644 --- a/scene/resources/mesh_data_tool.cpp +++ b/scene/resources/mesh_data_tool.cpp @@ -31,7 +31,6 @@ #include "mesh_data_tool.h" void MeshDataTool::clear() { - vertices.clear(); edges.clear(); faces.clear(); @@ -40,7 +39,6 @@ void MeshDataTool::clear() { } Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surface) { - ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_mesh->surface_get_primitive_type(p_surface) != Mesh::PRIMITIVE_TRIANGLES, ERR_INVALID_PARAMETER); @@ -88,7 +86,6 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf vertices.resize(vcount); for (int i = 0; i < vcount; i++) { - Vertex v; v.vertex = vr[i]; if (nr) @@ -103,7 +100,6 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf v.color = col[i]; if (we) { - v.weights.push_back(we[i * 4 + 0]); v.weights.push_back(we[i * 4 + 1]); v.weights.push_back(we[i * 4 + 2]); @@ -111,7 +107,6 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf } if (bo) { - v.bones.push_back(bo[i * 4 + 0]); v.bones.push_back(bo[i * 4 + 1]); v.bones.push_back(bo[i * 4 + 2]); @@ -124,7 +119,6 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf Vector<int> indices; if (arrays[Mesh::ARRAY_INDEX].get_type() != Variant::NIL) { - indices = arrays[Mesh::ARRAY_INDEX]; } else { //make code simpler @@ -140,14 +134,12 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf Map<Point2i, int> edge_indices; for (int i = 0; i < icount; i += 3) { - Vertex *v[3] = { &vertices.write[r[i + 0]], &vertices.write[r[i + 1]], &vertices.write[r[i + 2]] }; int fidx = faces.size(); Face face; for (int j = 0; j < 3; j++) { - face.v[j] = r[i + j]; Point2i edge(r[i + j], r[i + (j + 1) % 3]); @@ -180,7 +172,6 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf } Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { - ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER); Array arr; arr.resize(Mesh::ARRAY_MAX); @@ -198,7 +189,6 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { Vector<int> in; { - v.resize(vcount); Vector3 *vr = v.ptrw(); @@ -245,7 +235,6 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { } for (int i = 0; i < vcount; i++) { - const Vertex &vtx = vertices[i]; vr[i] = vtx.vertex; @@ -265,7 +254,6 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { col[i] = vtx.color; if (we) { - we[i * 4 + 0] = vtx.weights[0]; we[i * 4 + 1] = vtx.weights[1]; we[i * 4 + 2] = vtx.weights[2]; @@ -273,7 +261,6 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { } if (bo) { - bo[i * 4 + 0] = vtx.bones[0]; bo[i * 4 + 1] = vtx.bones[1]; bo[i * 4 + 2] = vtx.bones[2]; @@ -285,7 +272,6 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { in.resize(fc * 3); int *iw = in.ptrw(); for (int i = 0; i < fc; i++) { - iw[i * 3 + 0] = faces[i].v[0]; iw[i * 3 + 1] = faces[i].v[1]; iw[i * 3 + 2] = faces[i].v[2]; @@ -318,108 +304,89 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { } int MeshDataTool::get_format() const { - return format; } int MeshDataTool::get_vertex_count() const { - return vertices.size(); } int MeshDataTool::get_edge_count() const { - return edges.size(); } int MeshDataTool::get_face_count() const { - return faces.size(); } Vector3 MeshDataTool::get_vertex(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3()); return vertices[p_idx].vertex; } void MeshDataTool::set_vertex(int p_idx, const Vector3 &p_vertex) { - ERR_FAIL_INDEX(p_idx, vertices.size()); vertices.write[p_idx].vertex = p_vertex; } Vector3 MeshDataTool::get_vertex_normal(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3()); return vertices[p_idx].normal; } void MeshDataTool::set_vertex_normal(int p_idx, const Vector3 &p_normal) { - ERR_FAIL_INDEX(p_idx, vertices.size()); vertices.write[p_idx].normal = p_normal; format |= Mesh::ARRAY_FORMAT_NORMAL; } Plane MeshDataTool::get_vertex_tangent(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Plane()); return vertices[p_idx].tangent; } void MeshDataTool::set_vertex_tangent(int p_idx, const Plane &p_tangent) { - ERR_FAIL_INDEX(p_idx, vertices.size()); vertices.write[p_idx].tangent = p_tangent; format |= Mesh::ARRAY_FORMAT_TANGENT; } Vector2 MeshDataTool::get_vertex_uv(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2()); return vertices[p_idx].uv; } void MeshDataTool::set_vertex_uv(int p_idx, const Vector2 &p_uv) { - ERR_FAIL_INDEX(p_idx, vertices.size()); vertices.write[p_idx].uv = p_uv; format |= Mesh::ARRAY_FORMAT_TEX_UV; } Vector2 MeshDataTool::get_vertex_uv2(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2()); return vertices[p_idx].uv2; } void MeshDataTool::set_vertex_uv2(int p_idx, const Vector2 &p_uv2) { - ERR_FAIL_INDEX(p_idx, vertices.size()); vertices.write[p_idx].uv2 = p_uv2; format |= Mesh::ARRAY_FORMAT_TEX_UV2; } Color MeshDataTool::get_vertex_color(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Color()); return vertices[p_idx].color; } void MeshDataTool::set_vertex_color(int p_idx, const Color &p_color) { - ERR_FAIL_INDEX(p_idx, vertices.size()); vertices.write[p_idx].color = p_color; format |= Mesh::ARRAY_FORMAT_COLOR; } Vector<int> MeshDataTool::get_vertex_bones(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>()); return vertices[p_idx].bones; } void MeshDataTool::set_vertex_bones(int p_idx, const Vector<int> &p_bones) { - ERR_FAIL_INDEX(p_idx, vertices.size()); vertices.write[p_idx].bones = p_bones; format |= Mesh::ARRAY_FORMAT_BONES; } Vector<float> MeshDataTool::get_vertex_weights(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<float>()); return vertices[p_idx].weights; } @@ -430,75 +397,62 @@ void MeshDataTool::set_vertex_weights(int p_idx, const Vector<float> &p_weights) } Variant MeshDataTool::get_vertex_meta(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Variant()); return vertices[p_idx].meta; } void MeshDataTool::set_vertex_meta(int p_idx, const Variant &p_meta) { - ERR_FAIL_INDEX(p_idx, vertices.size()); vertices.write[p_idx].meta = p_meta; } Vector<int> MeshDataTool::get_vertex_edges(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>()); return vertices[p_idx].edges; } Vector<int> MeshDataTool::get_vertex_faces(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>()); return vertices[p_idx].faces; } int MeshDataTool::get_edge_vertex(int p_edge, int p_vertex) const { - ERR_FAIL_INDEX_V(p_edge, edges.size(), -1); ERR_FAIL_INDEX_V(p_vertex, 2, -1); return edges[p_edge].vertex[p_vertex]; } Vector<int> MeshDataTool::get_edge_faces(int p_edge) const { - ERR_FAIL_INDEX_V(p_edge, edges.size(), Vector<int>()); return edges[p_edge].faces; } Variant MeshDataTool::get_edge_meta(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, edges.size(), Variant()); return edges[p_idx].meta; } void MeshDataTool::set_edge_meta(int p_idx, const Variant &p_meta) { - ERR_FAIL_INDEX(p_idx, edges.size()); edges.write[p_idx].meta = p_meta; } int MeshDataTool::get_face_vertex(int p_face, int p_vertex) const { - ERR_FAIL_INDEX_V(p_face, faces.size(), -1); ERR_FAIL_INDEX_V(p_vertex, 3, -1); return faces[p_face].v[p_vertex]; } int MeshDataTool::get_face_edge(int p_face, int p_vertex) const { - ERR_FAIL_INDEX_V(p_face, faces.size(), -1); ERR_FAIL_INDEX_V(p_vertex, 3, -1); return faces[p_face].edges[p_vertex]; } Variant MeshDataTool::get_face_meta(int p_face) const { - ERR_FAIL_INDEX_V(p_face, faces.size(), Variant()); return faces[p_face].meta; } void MeshDataTool::set_face_meta(int p_face, const Variant &p_meta) { - ERR_FAIL_INDEX(p_face, faces.size()); faces.write[p_face].meta = p_meta; } Vector3 MeshDataTool::get_face_normal(int p_face) const { - ERR_FAIL_INDEX_V(p_face, faces.size(), Vector3()); Vector3 v0 = vertices[faces[p_face].v[0]].vertex; Vector3 v1 = vertices[faces[p_face].v[1]].vertex; @@ -508,17 +462,14 @@ Vector3 MeshDataTool::get_face_normal(int p_face) const { } Ref<Material> MeshDataTool::get_material() const { - return material; } void MeshDataTool::set_material(const Ref<Material> &p_material) { - material = p_material; } void MeshDataTool::_bind_methods() { - ClassDB::bind_method(D_METHOD("clear"), &MeshDataTool::clear); ClassDB::bind_method(D_METHOD("create_from_surface", "mesh", "surface"), &MeshDataTool::create_from_surface); ClassDB::bind_method(D_METHOD("commit_to_surface", "mesh"), &MeshDataTool::commit_to_surface); @@ -578,6 +529,5 @@ void MeshDataTool::_bind_methods() { } MeshDataTool::MeshDataTool() { - clear(); } |