diff --git a/SCsub b/SCsub index 2ba8196..872e198 100644 --- a/SCsub +++ b/SCsub @@ -7,6 +7,7 @@ module_env = env.Clone() if os.path.isdir('../mesh_data_resource'): module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) +module_env.Append(CPPFLAGS=["-std=c++11"]) sources = [ @@ -31,6 +32,9 @@ sources = [ "meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.cpp", "meshers/transvoxel_uv_mesher/transvoxel_tables.cpp", + "meshers/mesh_simplifiers/mesh_simplifier.cpp", + "meshers/mesh_simplifiers/fast_quadratic_mesh_simplifier.cpp", + "world/voxel_world.cpp", "world/voxel_chunk.cpp", "world/voxel_structure.cpp", @@ -56,7 +60,6 @@ sources = [ "clutter/ground_clutter_foliage.cpp", ] - if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': # Shared lib compilation module_env.Append(CCFLAGS=['-fPIC']) diff --git a/meshers/mesh_simplifier/mesh_simplifier.cpp b/meshers/mesh_simplifiers/fast_quadratic_mesh_simplifier.cpp similarity index 80% rename from meshers/mesh_simplifier/mesh_simplifier.cpp rename to meshers/mesh_simplifiers/fast_quadratic_mesh_simplifier.cpp index 4130609..1c9bb89 100644 --- a/meshers/mesh_simplifier/mesh_simplifier.cpp +++ b/meshers/mesh_simplifiers/fast_quadratic_mesh_simplifier.cpp @@ -1,4 +1,4 @@ -#include "mesh_simplifier.h" +#include "fast_quadratic_mesh_simplifier.h" #include "../voxel_mesher.h" @@ -6,7 +6,7 @@ //Mesh Simplification //Ported from https://github.com/Whinarn/UnityMeshSimplifier //Original license: MIT License Copyright (c) 2017 Mattias Edlund -void MeshSimplifier::initialize(Ref mesher) { +void FastQuadraticMeshSimplifier::initialize(Ref mesher) { _mesher = mesher; _vertices = mesher->get_vertices(); @@ -36,7 +36,7 @@ void MeshSimplifier::initialize(Ref mesher) { } } -void MeshSimplifier::refresh_vertices() { +void FastQuadraticMeshSimplifier::refresh_vertices() { _vertices.resize(_mu_vertices.size()); for (int i = 0; i < _mu_vertices.size(); ++i) { MUVertex vert = _mu_vertices[i]; @@ -49,9 +49,9 @@ void MeshSimplifier::refresh_vertices() { //private ResizableArray vertices = null; //Mesh Simplification -//Ported from https://github.com/Whinarn/UnityMeshSimplifier +//Ported from https://github.com/Whinarn/UnityFastQuadraticMeshSimplifier //Original license: MIT License Copyright (c) 2017 Mattias Edlund -void MeshSimplifier::SimplifyMesh(float quality) { +void FastQuadraticMeshSimplifier::SimplifyMesh(float quality) { quality = CLAMP(quality, 0, 1); int deletedTris = 0; @@ -74,7 +74,7 @@ void MeshSimplifier::SimplifyMesh(float quality) { // Clear dirty flag for (int i = 0; i < _mu_triangles.size(); ++i) { - _mu_triangles[i].dirty = false; + _mu_triangles[i].set_dirty(false); } // All triangles with edges below the threshold will be removed @@ -95,9 +95,9 @@ void MeshSimplifier::SimplifyMesh(float quality) { } //Mesh Simplification -//Ported from https://github.com/Whinarn/UnityMeshSimplifier +//Ported from https://github.com/Whinarn/UnityFastQuadraticMeshSimplifier //Original license: MIT License Copyright (c) 2017 Mattias Edlund -void MeshSimplifier::SimplifyMeshLossless() { +void FastQuadraticMeshSimplifier::SimplifyMeshLossless() { int deletedTris = 0; PoolVector deleted0; PoolVector deleted1; @@ -109,7 +109,7 @@ void MeshSimplifier::SimplifyMeshLossless() { // Clear dirty flag for (int i = 0; i < _mu_triangles.size(); ++i) { - _mu_triangles[i].dirty = false; + _mu_triangles[i].set_dirty(false); } // All triangles with edges below the threshold will be removed @@ -134,7 +134,7 @@ void MeshSimplifier::SimplifyMeshLossless() { //Debug.LogFormat("Finished simplification with triangle count {0}", this.triangles.Length); } -void MeshSimplifier::UpdateMesh(int iteration) { +void FastQuadraticMeshSimplifier::UpdateMesh(int iteration) { if (iteration > 0) // compact triangles { int dst = 0; @@ -160,9 +160,9 @@ void MeshSimplifier::UpdateMesh(int iteration) { int vsize = 0; for (int i = 0; i < _mu_vertices.size(); i++) { - _mu_vertices[i].borderEdge = false; - _mu_vertices[i].uvSeamEdge = false; - _mu_vertices[i].uvFoldoverEdge = false; + _mu_vertices[i].set_border_edge(false); + _mu_vertices[i].set_uv_seam_edge(false); + _mu_vertices[i].set_uv_foldover_edge(false); } int ofs; @@ -203,7 +203,7 @@ void MeshSimplifier::UpdateMesh(int iteration) { for (int j = 0; j < vsize; j++) { if (vcount[j] == 1) { id = vids[j]; - _mu_vertices[id].borderEdge = true; + _mu_vertices[id].set_border_edge(true); ++borderVertexCount; if (enableSmartLink) { @@ -260,16 +260,16 @@ void MeshSimplifier::UpdateMesh(int iteration) { double sqrMagnitude = sqrX + sqrY + sqrZ; if (sqrMagnitude <= vertexLinkDistanceSqr) { - borderVertices.get(j).index = -1; // NOTE: This makes sure that the "other" vertex is not processed again - _mu_vertices[myIndex].borderEdge = false; - _mu_vertices[otherIndex].borderEdge = false; + borderVertices.get(j).set_index(-1); // NOTE: This makes sure that the "other" vertex is not processed again + _mu_vertices[myIndex].set_border_edge(false); + _mu_vertices[otherIndex].set_border_edge(false); if (AreUVsTheSame(0, myIndex, otherIndex)) { - _mu_vertices[myIndex].uvFoldoverEdge = true; - _mu_vertices[otherIndex].uvFoldoverEdge = true; + _mu_vertices[myIndex].set_uv_foldover_edge(true); + _mu_vertices[otherIndex].set_uv_foldover_edge(true); } else { - _mu_vertices[myIndex].uvSeamEdge = true; - _mu_vertices[otherIndex].uvSeamEdge = true; + _mu_vertices[myIndex].set_uv_seam_edge(true); + _mu_vertices[otherIndex].set_uv_seam_edge(true); } int otherTriangleCount = _mu_vertices[otherIndex].tcount; @@ -323,32 +323,32 @@ void MeshSimplifier::UpdateMesh(int iteration) { for (int i = 0; i < _mu_triangles.size(); ++i) { // Calc Edge Error MUTriangle triangle = _mu_triangles[i]; - _mu_triangles[i].err0 = CalculateError(_mu_vertices[triangle.v0], _mu_vertices[triangle.v1], &dummy); - _mu_triangles[i].err1 = CalculateError(_mu_vertices[triangle.v1], _mu_vertices[triangle.v2], &dummy); - _mu_triangles[i].err2 = CalculateError(_mu_vertices[triangle.v2], _mu_vertices[triangle.v0], &dummy); - _mu_triangles[i].err3 = MeshSimplifier::Min3(_mu_triangles[i].err0, _mu_triangles[i].err1, _mu_triangles[i].err2); + _mu_triangles[i].set_err0(CalculateError(_mu_vertices[triangle.v0], _mu_vertices[triangle.v1], &dummy)); + _mu_triangles[i].set_err1(CalculateError(_mu_vertices[triangle.v1], _mu_vertices[triangle.v2], &dummy)); + _mu_triangles[i].set_err2(CalculateError(_mu_vertices[triangle.v2], _mu_vertices[triangle.v0], &dummy)); + _mu_triangles[i].set_err3(FastQuadraticMeshSimplifier::Min3(_mu_triangles[i].err0, _mu_triangles[i].err1, _mu_triangles[i].err2)); } } } -void MeshSimplifier::UpdateReferences() { +void FastQuadraticMeshSimplifier::UpdateReferences() { // Init Reference ID list for (int i = 0; i < _mu_vertices.size(); i++) { - _mu_vertices[i].tstart = 0; - _mu_vertices[i].tcount = 0; + _mu_vertices[i].set_tstart(0); + _mu_vertices[i].set_tcount(0); } for (int i = 0; i < _mu_triangles.size(); i++) { - ++_mu_vertices[_mu_triangles[i].v0].tcount; - ++_mu_vertices[_mu_triangles[i].v1].tcount; - ++_mu_vertices[_mu_triangles[i].v2].tcount; + _mu_vertices[_mu_triangles[i].v0].set_tcount(_mu_vertices[_mu_triangles[i].v0].tcount + 1); + _mu_vertices[_mu_triangles[i].v1].set_tcount(_mu_vertices[_mu_triangles[i].v1].tcount + 1); + _mu_vertices[_mu_triangles[i].v2].set_tcount(_mu_vertices[_mu_triangles[i].v2].tcount + 1); } int tstart = 0; for (int i = 0; i < _mu_vertices.size(); i++) { - _mu_vertices[i].tstart = tstart; + _mu_vertices[i].set_tstart(tstart); tstart += _mu_vertices[i].tcount; - _mu_vertices[i].tcount = 0; + _mu_vertices[i].set_tcount(0); } // Write References @@ -368,20 +368,20 @@ void MeshSimplifier::UpdateReferences() { _mu_refs[start1 + count1].Set(i, 1); _mu_refs[start2 + count2].Set(i, 2); - ++_mu_vertices[v0].tcount; - ++_mu_vertices[v1].tcount; - ++_mu_vertices[v2].tcount; + _mu_vertices[v0].set_tcount(_mu_vertices[v0].tcount + 1); + _mu_vertices[v1].set_tcount(_mu_vertices[v1].tcount + 1); + _mu_vertices[v2].set_tcount(_mu_vertices[v2].tcount + 1); } } /// /// Finally compact mesh before exiting. /// -void MeshSimplifier::CompactMesh() { +void FastQuadraticMeshSimplifier::CompactMesh() { int dst = 0; for (int i = 0; i < _mu_vertices.size(); i++) { - _mu_vertices[i].tcount = 0; + _mu_vertices[i].set_tcount(0); } for (int i = 0; i < _mu_triangles.size(); i++) { @@ -415,9 +415,9 @@ void MeshSimplifier::CompactMesh() { int newTriangleIndex = ++dst; _mu_triangles[newTriangleIndex] = triangle; - _mu_vertices[triangle.v0].tcount = 1; - _mu_vertices[triangle.v1].tcount = 1; - _mu_vertices[triangle.v2].tcount = 1; + _mu_vertices[triangle.v0].set_tcount(1); + _mu_vertices[triangle.v1].set_tcount(1); + _mu_vertices[triangle.v2].set_tcount(1); } } @@ -463,9 +463,9 @@ void MeshSimplifier::CompactMesh() { if (_indices.size() > 0) _indices.resize(dst); } -bool MeshSimplifier::AreUVsTheSame(int channel, int indexA, int indexB) { +bool FastQuadraticMeshSimplifier::AreUVsTheSame(int channel, int indexA, int indexB) { if (_uv2s.size() > 0) { - Vector2 vertUV = _uv2s[channel]; + //Vector2 vertUV = _uv2s[channel]; Vector2 uvA = _uv2s[indexA]; Vector2 uvB = _uv2s[indexB]; @@ -476,7 +476,7 @@ bool MeshSimplifier::AreUVsTheSame(int channel, int indexA, int indexB) { } /// Remove vertices and mark deleted triangles -int MeshSimplifier::RemoveVertexPass(int startTrisCount, int targetTrisCount, double threshold, PoolVector deleted0, PoolVector deleted1, int deletedTris) { +int FastQuadraticMeshSimplifier::RemoveVertexPass(int startTrisCount, int targetTrisCount, double threshold, PoolVector &deleted0, PoolVector &deleted1, int deletedTris) { Vector3 p; Vector3 barycentricCoord; for (int tid = 0; tid < _mu_triangles.size(); tid++) { @@ -519,9 +519,9 @@ int MeshSimplifier::RemoveVertexPass(int startTrisCount, int targetTrisCount, do deleted1.resize(_mu_vertices[i1].tcount); // normals temporarily // Don't remove if flipped - if (Flipped(&p, i0, i1, &(_mu_vertices[i0]), deleted0)) + if (Flipped(p, i0, i1, _mu_vertices[i0], deleted0)) continue; - if (Flipped(&p, i1, i0, &(_mu_vertices[i1]), deleted1)) + if (Flipped(p, i1, i0, _mu_vertices[i1], deleted1)) continue; // Calculate the barycentric coordinates within the triangle @@ -544,8 +544,8 @@ int MeshSimplifier::RemoveVertexPass(int startTrisCount, int targetTrisCount, do } int tstart = _mu_refs.size(); - deletedTris = UpdateTriangles(i0, ia0, &(_mu_vertices[i0]), deleted0, deletedTris); - deletedTris = UpdateTriangles(i0, ia0, &(_mu_vertices[i1]), deleted1, deletedTris); + deletedTris = UpdateTriangles(i0, ia0, _mu_vertices[i0], deleted0, deletedTris); + deletedTris = UpdateTriangles(i0, ia0, _mu_vertices[i1], deleted1, deletedTris); int tcount = _mu_refs.size() - tstart; if (tcount <= _mu_vertices[i0].tcount) { @@ -558,10 +558,10 @@ int MeshSimplifier::RemoveVertexPass(int startTrisCount, int targetTrisCount, do } } else { // append - _mu_vertices[i0].tstart = tstart; + _mu_vertices[i0].set_tstart(tstart); } - _mu_vertices[i0].tcount = tcount; + _mu_vertices[i0].set_tcount(tcount); break; } @@ -573,11 +573,11 @@ int MeshSimplifier::RemoveVertexPass(int startTrisCount, int targetTrisCount, do return deletedTris; } -double MeshSimplifier::VertexError(SymmetricMatrix q, double x, double y, double z) { +double FastQuadraticMeshSimplifier::VertexError(SymmetricMatrix q, double x, double y, double z) { return q.m0 * x * x + 2 * q.m1 * x * y + 2 * q.m2 * x * z + 2 * q.m3 * x + q.m4 * y * y + 2 * q.m5 * y * z + 2 * q.m6 * y + q.m7 * z * z + 2 * q.m8 * z + q.m9; } -double MeshSimplifier::CalculateError(MUVertex vert0, MUVertex vert1, Vector3 *result) { +double FastQuadraticMeshSimplifier::CalculateError(MUVertex vert0, MUVertex vert1, Vector3 *result) { // compute interpolated vertex SymmetricMatrix q = (vert0.q + vert1.q); bool borderEdge = (vert0.borderEdge & vert1.borderEdge); @@ -599,7 +599,7 @@ double MeshSimplifier::CalculateError(MUVertex vert0, MUVertex vert1, Vector3 *r double error2 = VertexError(q, p2.x, p2.y, p2.z); double error3 = VertexError(q, p3.x, p3.y, p3.z); - error = MeshSimplifier::Min3(error1, error2, error3); + error = FastQuadraticMeshSimplifier::Min3(error1, error2, error3); if (error == error3) { result->x = p3.x; result->y = p3.y; @@ -621,20 +621,20 @@ double MeshSimplifier::CalculateError(MUVertex vert0, MUVertex vert1, Vector3 *r return error; } -int MeshSimplifier::UpdateTriangles(int i0, int ia0, MUVertex *v, PoolVector deleted, int p_deletedTriangles) { +int FastQuadraticMeshSimplifier::UpdateTriangles(int i0, int ia0, const MUVertex &v, PoolVector &deleted, int p_deletedTriangles) { Vector3 p; int deletedTriangles = p_deletedTriangles; - int tcount = v->tcount; + int tcount = v.tcount; for (int k = 0; k < tcount; k++) { - MURef r = _mu_refs[v->tstart + k]; + MURef r = _mu_refs[v.tstart + k]; int tid = r.tid; MUTriangle t = _mu_triangles[tid]; if (t.deleted) continue; if (deleted[k]) { - _mu_triangles[tid].deleted = true; + _mu_triangles[tid].set_deleted(true); ++deletedTriangles; continue; } @@ -648,7 +648,7 @@ int MeshSimplifier::UpdateTriangles(int i0, int ia0, MUVertex *v, PoolVector &deleted) { - int tcount = v0->tcount; +bool FastQuadraticMeshSimplifier::Flipped(const Vector3 &p, int i0, int i1, const MUVertex &v0, PoolVector &deleted) { + int tcount = v0.tcount; for (int k = 0; k < tcount; k++) { - MURef r = _mu_refs[v0->tstart + k]; + MURef r = _mu_refs[v0.tstart + k]; if (_mu_triangles[r.tid].deleted) continue; @@ -673,9 +673,9 @@ bool MeshSimplifier::Flipped(Vector3 *p, int i0, int i1, MUVertex *v0, PoolVecto continue; } - Vector3 d1 = _mu_vertices[id1].p - (*p); + Vector3 d1 = _mu_vertices[id1].p - p; d1.normalize(); - Vector3 d2 = _mu_vertices[id2].p - (*p); + Vector3 d2 = _mu_vertices[id2].p - p; d2.normalize(); double dot = d1.dot(d2); if (Math::abs(dot) > 0.999) @@ -692,7 +692,7 @@ bool MeshSimplifier::Flipped(Vector3 *p, int i0, int i1, MUVertex *v0, PoolVecto return false; } -Vector3 MeshSimplifier::CalculateBarycentricCoords(Vector3 const &point, Vector3 const &a, Vector3 const &b, Vector3 const &c) { +Vector3 FastQuadraticMeshSimplifier::CalculateBarycentricCoords(Vector3 const &point, Vector3 const &a, Vector3 const &b, Vector3 const &c) { Vector3 v0 = (Vector3)(b - a), v1 = (Vector3)(c - a), v2 = (Vector3)(point - a); float d00 = v0.dot(v0); float d01 = v0.dot(v1); @@ -707,7 +707,7 @@ Vector3 MeshSimplifier::CalculateBarycentricCoords(Vector3 const &point, Vector3 return Vector3(u, v, w); } -void MeshSimplifier::InterpolateVertexAttributes(int dst, int i0, int i1, int i2, Vector3 &barycentricCoord) { +void FastQuadraticMeshSimplifier::InterpolateVertexAttributes(int dst, int i0, int i1, int i2, Vector3 &barycentricCoord) { if (_normals.size() > 0) { _normals[dst] = (_normals[i0] * barycentricCoord.x) + (_normals[i1] * barycentricCoord.y) + (_normals[i2] * barycentricCoord.z).normalized(); } @@ -725,7 +725,7 @@ void MeshSimplifier::InterpolateVertexAttributes(int dst, int i0, int i1, int i2 } } -MeshSimplifier::MeshSimplifier() { +FastQuadraticMeshSimplifier::FastQuadraticMeshSimplifier() { maxIterationCount = 100; agressiveness = 7.0; enableSmartLink = true; diff --git a/meshers/mesh_simplifier/mesh_simplifier.h b/meshers/mesh_simplifiers/fast_quadratic_mesh_simplifier.h similarity index 72% rename from meshers/mesh_simplifier/mesh_simplifier.h rename to meshers/mesh_simplifiers/fast_quadratic_mesh_simplifier.h index 83ca4e0..2aca534 100644 --- a/meshers/mesh_simplifier/mesh_simplifier.h +++ b/meshers/mesh_simplifiers/fast_quadratic_mesh_simplifier.h @@ -1,5 +1,9 @@ -#ifndef MESH_SIMPLIFIER_H -#define MESH_SIMPLIFIER_H +#ifndef FAST_QUADRATIC_MESH_SIMPLIFIER_H +#define FAST_QUADRATIC_MESH_SIMPLIFIER_H + +#include "mesh_simplifier.h" + +#include #include "mesh_utils.h" @@ -8,7 +12,8 @@ class VoxelMesher; -class MeshSimplifier { +class FastQuadraticMeshSimplifier : public MeshSimplifier { + GDCLASS(FastQuadraticMeshSimplifier, MeshSimplifier); public: void initialize(Ref mesher); @@ -17,13 +22,13 @@ public: void SimplifyMeshLossless(); void UpdateMesh(int iteration); void UpdateReferences(); - int RemoveVertexPass(int startTrisCount, int targetTrisCount, double threshold, PoolVector deleted0, PoolVector deleted1, int deletedTris); + int RemoveVertexPass(int startTrisCount, int targetTrisCount, double threshold, PoolVector &deleted0, PoolVector &deleted1, int deletedTris); void CompactMesh(); bool AreUVsTheSame(int channel, int indexA, int indexB); double VertexError(SymmetricMatrix q, double x, double y, double z); double CalculateError(MUVertex vert0, MUVertex vert1, Vector3 *result); - int UpdateTriangles(int i0, int ia0, MUVertex *v, PoolVector deleted, int deletedTriangles); - bool Flipped(Vector3 *p, int i0, int i1, MUVertex *v0, PoolVector &deleted); + int UpdateTriangles(int i0, int ia0, const MUVertex &v, PoolVector &deleted, int deletedTriangles); + bool Flipped(const Vector3 &p, int i0, int i1, const MUVertex &v0, PoolVector &deleted); static Vector3 CalculateBarycentricCoords(Vector3 const &point, Vector3 const &a, Vector3 const &b, Vector3 const &c); void InterpolateVertexAttributes(int dst, int i0, int i1, int i2, Vector3 &barycentricCoord); @@ -31,7 +36,7 @@ public: return (val1 < val2 ? (val1 < val3 ? val1 : val3) : (val2 < val3 ? val2 : val3)); } - MeshSimplifier(); + FastQuadraticMeshSimplifier(); private: PoolVector _vertices; diff --git a/meshers/mesh_simplifiers/mesh_simplifier.cpp b/meshers/mesh_simplifiers/mesh_simplifier.cpp new file mode 100644 index 0000000..3538bb9 --- /dev/null +++ b/meshers/mesh_simplifiers/mesh_simplifier.cpp @@ -0,0 +1,4 @@ +#include "mesh_simplifier.h" + +MeshSimplifier::MeshSimplifier() { +} \ No newline at end of file diff --git a/meshers/mesh_simplifiers/mesh_simplifier.h b/meshers/mesh_simplifiers/mesh_simplifier.h new file mode 100644 index 0000000..b464b2b --- /dev/null +++ b/meshers/mesh_simplifiers/mesh_simplifier.h @@ -0,0 +1,19 @@ +#ifndef MESH_SIMPLIFIER_H +#define MESH_SIMPLIFIER_H + +#include "core/reference.h" + +#include "core/pool_vector.h" +#include "core/resource.h" + +class MeshSimplifier : public Reference { + GDCLASS(MeshSimplifier, Reference); + +public: + MeshSimplifier(); + +protected: + static void _bind_methods() {} +}; + +#endif \ No newline at end of file diff --git a/meshers/mesh_simplifier/mesh_utils.h b/meshers/mesh_simplifiers/mesh_utils.h similarity index 81% rename from meshers/mesh_simplifier/mesh_utils.h rename to meshers/mesh_simplifiers/mesh_utils.h index 71a16bb..38c7406 100644 --- a/meshers/mesh_simplifier/mesh_utils.h +++ b/meshers/mesh_simplifiers/mesh_utils.h @@ -54,7 +54,7 @@ struct SymmetricMatrix { /// The m44 component. double m9; - _FORCE_INLINE_ const double &operator[](int p_index) const { + _FORCE_INLINE_ const double get(int p_index) const { CRASH_BAD_INDEX(p_index, 10); switch (p_index) { @@ -213,12 +213,12 @@ struct SymmetricMatrix { int a21, int a22, int a23, int a31, int a32, int a33) { double det = - this[a11] * this[a22] * this[a33] + - this[a13] * this[a21] * this[a32] + - this[a12] * this[a23] * this[a31] - - this[a13] * this[a22] * this[a31] - - this[a11] * this[a23] * this[a32] - - this[a12] * this[a21] * this[a33]; + get(a11) * get(a22) * get(a33) + + get(a13) * get(a21) * get(a32) + + get(a12) * get(a23) * get(a31) - + get(a13) * get(a22) * get(a31) - + get(a11) * get(a23) * get(a32) - + get(a12) * get(a21) * get(a33); return det; } @@ -275,7 +275,7 @@ struct MUTriangle { return (p_index == 0 ? v0 : (p_index == 1 ? v1 : v2)); } - _FORCE_INLINE_ int set(int p_index, int value) { + _FORCE_INLINE_ void set(int p_index, int value) { CRASH_BAD_INDEX(p_index, 3); switch (p_index) { @@ -289,8 +289,44 @@ struct MUTriangle { v2 = value; break; } + } - return 0; + _FORCE_INLINE_ void set_dirty(bool p_value) { + dirty = p_value; + } + + _FORCE_INLINE_ void set_err0(double p_value) { + err0 = p_value; + } + + _FORCE_INLINE_ void set_err1(double p_value) { + err1 = p_value; + } + + _FORCE_INLINE_ void set_err2(double p_value) { + err2 = p_value; + } + + _FORCE_INLINE_ void set_err3(double p_value) { + err3 = p_value; + } + + _FORCE_INLINE_ void set_deleted(double p_value) { + deleted = p_value; + } + + MUTriangle() { + v0 = 0; + v1 = 0; + v2 = 0; + subMeshIndex = 0; + + va0 = 0; + va1 = 0; + va2 = 0; + + err0 = err1 = err2 = err3 = 0; + deleted = dirty = false; } MUTriangle(int p_v0, int p_v1, int p_v2, int p_subMeshIndex) { @@ -353,6 +389,34 @@ struct MUVertex { bool uvSeamEdge; bool uvFoldoverEdge; + _FORCE_INLINE_ void set_tstart(int p_value) { + tstart = p_value; + } + + _FORCE_INLINE_ void set_tcount(int p_value) { + tcount = p_value; + } + + _FORCE_INLINE_ void set_border_edge(bool p_value) { + borderEdge = p_value; + } + + _FORCE_INLINE_ void set_uv_seam_edge(bool p_value) { + uvSeamEdge = p_value; + } + + _FORCE_INLINE_ void set_uv_foldover_edge(bool p_value) { + uvFoldoverEdge = p_value; + } + + MUVertex() { + tstart = 0; + tcount = 0; + borderEdge = true; + uvSeamEdge = false; + uvFoldoverEdge = false; + } + MUVertex(float x, float y, float z) { p = Vector3(x, y, z); tstart = 0; @@ -391,6 +455,10 @@ struct BorderVertex { int index; int hash; + _FORCE_INLINE_ void set_index(int p_value) { + index = p_value; + } + BorderVertex() { index = 0; hash = 0; @@ -403,7 +471,7 @@ struct BorderVertex { }; struct BorderVertexComparer { - _FORCE_INLINE_ bool operator()(const BorderVertex &a, const BorderVertex &b) const { return x.hash < y.hash; } + _FORCE_INLINE_ bool operator()(const BorderVertex &a, const BorderVertex &b) const { return a.hash < b.hash; } }; #endif \ No newline at end of file diff --git a/register_types.cpp b/register_types.cpp index 43b14e5..8781ea4 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -16,6 +16,9 @@ #include "meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.h" #include "meshers/voxel_mesher.h" +#include "meshers/mesh_simplifiers/fast_quadratic_mesh_simplifier.h" +#include "meshers/mesh_simplifiers/mesh_simplifier.h" + #include "world/environment_data.h" #include "world/voxel_chunk.h" #include "world/voxel_chunk_prop_data.h" @@ -52,6 +55,9 @@ void register_voxelman_types() { ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();