diff --git a/dust3d.pro b/dust3d.pro index da6da3e9..d4c11df0 100644 --- a/dust3d.pro +++ b/dust3d.pro @@ -471,8 +471,8 @@ HEADERS += src/boxmesh.h SOURCES += src/meshrecombiner.cpp HEADERS += src/meshrecombiner.h -SOURCES += src/triangulate.cpp -HEADERS += src/triangulate.h +SOURCES += src/triangulatefaces.cpp +HEADERS += src/triangulatefaces.h SOURCES += src/booleanmesh.cpp HEADERS += src/booleanmesh.h diff --git a/src/boxmesh.cpp b/src/boxmesh.cpp index de1fa56f..260c59e7 100644 --- a/src/boxmesh.cpp +++ b/src/boxmesh.cpp @@ -1,34 +1,32 @@ #include "boxmesh.h" -#include "strokemeshbuilder.h" -#include "triangulate.h" static const std::vector subdivedBoxObjVertices = { - {-0.025357, -0.025357, 0.025357}, - {-0.025357, 0.025357, 0.025357}, - {-0.025357, 0.025357, -0.025357}, - {-0.025357, -0.025357, -0.025357}, - {0.025357, -0.025357, 0.025357}, - {0.025357, -0.025357, -0.025357}, - {0.025357, 0.025357, 0.025357}, - {0.025357, 0.025357, -0.025357}, - {-0.030913, -0.030913, -0.000000}, - {-0.030913, -0.000000, 0.030913}, - {-0.030913, 0.030913, 0.000000}, - {-0.030913, 0.000000, -0.030913}, - {0.030913, -0.030913, -0.000000}, - {0.000000, -0.030913, 0.030913}, - {-0.000000, -0.030913, -0.030913}, - {0.030913, -0.000000, 0.030913}, - {-0.000000, 0.030913, 0.030913}, - {0.030913, 0.030913, 0.000000}, - {0.030913, 0.000000, -0.030913}, - {-0.000000, 0.030913, -0.030913}, - {-0.042574, 0.000000, -0.000000}, - {-0.000000, -0.042574, -0.000000}, - {0.000000, -0.000000, 0.042574}, - {0.042574, -0.000000, -0.000000}, - {-0.000000, 0.000000, -0.042574}, - {0.000000, 0.042574, 0.000000}, + {-0.025357f, -0.025357f, 0.025357f}, + {-0.025357f, 0.025357f, 0.025357f}, + {-0.025357f, 0.025357f, -0.025357f}, + {-0.025357f, -0.025357f, -0.025357f}, + {0.025357f, -0.025357f, 0.025357f}, + {0.025357f, -0.025357f, -0.025357f}, + {0.025357f, 0.025357f, 0.025357f}, + {0.025357f, 0.025357f, -0.025357f}, + {-0.030913f, -0.030913f, -0.000000f}, + {-0.030913f, -0.000000f, 0.030913f}, + {-0.030913f, 0.030913f, 0.000000f}, + {-0.030913f, 0.000000f, -0.030913f}, + {0.030913f, -0.030913f, -0.000000f}, + {0.000000f, -0.030913f, 0.030913f}, + {-0.000000f, -0.030913f, -0.030913f}, + {0.030913f, -0.000000f, 0.030913f}, + {-0.000000f, 0.030913f, 0.030913f}, + {0.030913f, 0.030913f, 0.000000f}, + {0.030913f, 0.000000f, -0.030913f}, + {-0.000000f, 0.030913f, -0.030913f}, + {-0.042574f, 0.000000f, -0.000000f}, + {-0.000000f, -0.042574f, -0.000000f}, + {0.000000f, -0.000000f, 0.042574f}, + {0.042574f, -0.000000f, -0.000000f}, + {-0.000000f, 0.000000f, -0.042574f}, + {0.000000f, 0.042574f, 0.000000f}, }; static const std::vector> subdivedBoxObjFaces = { diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index 83e68745..6c4b9b00 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -15,7 +15,7 @@ #include "partbase.h" #include "imageforever.h" #include "gridmeshbuilder.h" -#include "triangulate.h" +#include "triangulatefaces.h" MeshGenerator::MeshGenerator(Snapshot *snapshot) : m_snapshot(snapshot) @@ -770,7 +770,7 @@ MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString, } if (partCache.previewTriangles.empty()) { partPreviewVertices = partCache.vertices; - triangulate(partPreviewVertices, partCache.faces, partCache.previewTriangles); + triangulateFacesWithoutKeepVertices(partPreviewVertices, partCache.faces, partCache.previewTriangles); #ifdef IN_DEVELOPMENT { QFile file("/Users/jeremy/Desktop/dust3d_debug.obj"); diff --git a/src/strokemeshbuilder.h b/src/strokemeshbuilder.h index 4a5f285a..efa7d354 100644 --- a/src/strokemeshbuilder.h +++ b/src/strokemeshbuilder.h @@ -123,16 +123,16 @@ private: std::map m_weldMap; std::set m_swallowedEdges; std::set m_swallowedNodes; - float m_deformThickness = 1.0; - float m_deformWidth = 1.0; - float m_cutRotation = 0.0; + float m_deformThickness = 1.0f; + float m_deformWidth = 1.0f; + float m_cutRotation = 0.0f; bool m_baseNormalOnX = true; bool m_baseNormalOnY = true; bool m_baseNormalOnZ = true; bool m_baseNormalAverageEnabled = false; const QImage *m_deformMapImage = nullptr; - float m_deformMapScale = 0.0; - float m_hollowThickness = 0.2; + float m_deformMapScale = 0.0f; + float m_hollowThickness = 0.2f; std::vector> m_endCuts; void sortNodeIndices(); diff --git a/src/triangulate.h b/src/triangulate.h deleted file mode 100644 index bfcbfbe0..00000000 --- a/src/triangulate.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef DUST3D_TRIANGULATE_H -#define DUST3D_TRIANGULATE_H -#include -#include - -bool triangulate(std::vector &vertices, const std::vector> &faces, std::vector> &triangles); - -#endif diff --git a/src/triangulate.cpp b/src/triangulatefaces.cpp similarity index 93% rename from src/triangulate.cpp rename to src/triangulatefaces.cpp index 02e61b49..b57ad769 100644 --- a/src/triangulate.cpp +++ b/src/triangulatefaces.cpp @@ -4,13 +4,13 @@ #include #include #include "booleanmesh.h" -#include "triangulate.h" +#include "triangulatefaces.h" #include "util.h" typedef CGAL::Exact_predicates_inexact_constructions_kernel InexactKernel; typedef CGAL::Surface_mesh InexactMesh; -bool triangulate(std::vector &vertices, const std::vector> &faces, std::vector> &triangles) +bool triangulateFacesWithoutKeepVertices(std::vector &vertices, const std::vector> &faces, std::vector> &triangles) { auto cgalMesh = buildCgalMesh(vertices, faces); bool isSucceed = CGAL::Polygon_mesh_processing::triangulate_faces(*cgalMesh); diff --git a/src/triangulatefaces.h b/src/triangulatefaces.h new file mode 100644 index 00000000..73b29f54 --- /dev/null +++ b/src/triangulatefaces.h @@ -0,0 +1,8 @@ +#ifndef DUST3D_TRIANGULATE_FACES_H +#define DUST3D_TRIANGULATE_FACES_H +#include +#include + +bool triangulateFacesWithoutKeepVertices(std::vector &vertices, const std::vector> &faces, std::vector> &triangles); + +#endif