Skip to content

Commit c2984f3

Browse files
authored
Merge pull request #2 from Ultimaker/CURA-12743_slow-performance-while-painting
CURA-12743 optimize painting performance
2 parents 35590d9 + 58b5a5f commit c2984f3

29 files changed

+850
-285
lines changed

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ project(uvula)
44
find_package(standardprojectsettings REQUIRED)
55
find_package(spdlog REQUIRED)
66
find_package(range-v3 REQUIRED)
7+
find_package(clipper REQUIRED)
78

89
option(EXTENSIVE_WARNINGS "Build with all warnings" ON)
910

@@ -21,8 +22,13 @@ message(STATUS "Configuring Uvula version: ${UVULA_VERSION}")
2122
set(UVULA_SRC
2223
src/xatlas.cpp
2324
src/unwrap.cpp
24-
src/Vector.cpp
25-
src/Matrix.cpp
25+
src/project.cpp
26+
src/Vector3F.cpp
27+
src/Vector2F.cpp
28+
src/Matrix33F.cpp
29+
src/Matrix44F.cpp
30+
src/Triangle3F.cpp
31+
src/Point3F.cpp
2632
src/geometry_utils.cpp
2733
)
2834
add_library(libuvula STATIC ${UVULA_SRC})
@@ -31,6 +37,7 @@ target_link_libraries(libuvula
3137
PUBLIC
3238
spdlog::spdlog
3339
range-v3::range-v3
40+
clipper::clipper
3441
)
3542

3643
target_include_directories(libuvula

cli/cli.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <spdlog/stopwatch.h>
1515

1616
#include "Face.h"
17-
#include "UVCoord.h"
18-
#include "Vertex.h"
17+
#include "Point2F.h"
18+
#include "Point3F.h"
1919
#include "unwrap.h"
2020

2121
int main(int argc, char** argv)
@@ -84,7 +84,7 @@ int main(int argc, char** argv)
8484
spdlog::info("Processing (unnamed) mesh", mesh->mName.data);
8585
}
8686

87-
std::vector<Vertex> vertices;
87+
std::vector<Point3F> vertices;
8888
vertices.reserve(mesh->mNumVertices);
8989
for (size_t j = 0; j < mesh->mNumVertices; j++)
9090
{
@@ -100,7 +100,7 @@ int main(int argc, char** argv)
100100
indices.emplace_back(face.mIndices[0], face.mIndices[1], face.mIndices[2]);
101101
}
102102

103-
std::vector<UVCoord> uv_coords(mesh->mNumVertices, { 0.0, 0.0 });
103+
std::vector<Point2F> uv_coords(mesh->mNumVertices, { 0.0, 0.0 });
104104
uint32_t texture_width, texture_height;
105105

106106
spdlog::stopwatch timer;
@@ -132,10 +132,10 @@ int main(int argc, char** argv)
132132
export_mesh->mTextureCoords[j] = new aiVector3D[export_mesh->mNumVertices];
133133
for (size_t k = 0; k < export_mesh->mNumVertices; k++)
134134
{
135-
const UVCoord& uv = uv_coords[k];
135+
const Point2F& uv = uv_coords[k];
136136
aiVector3D& export_uv = export_mesh->mTextureCoords[j][k];
137-
export_uv.x = uv.u;
138-
export_uv.y = uv.v;
137+
export_uv.x = uv.x;
138+
export_uv.y = uv.y;
139139
}
140140
}
141141
else

conanfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def layout(self):
9292
def requirements(self):
9393
self.requires("spdlog/1.15.1")
9494
self.requires("range-v3/0.12.0")
95+
self.requires("clipper/6.4.2@ultimaker/stable")
9596
if self.options.get_safe("with_python_bindings", False):
9697
self.requires("cpython/3.12.2")
9798
self.requires("pybind11/2.11.1")

include/Face.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44

55
#include <cstdint>
66

7-
struct Face
7+
template<typename IndexType>
8+
struct FaceIndex
89
{
9-
uint32_t i1{ 0 };
10-
uint32_t i2{ 0 };
11-
uint32_t i3{ 0 };
10+
IndexType i1{ 0 };
11+
IndexType i2{ 0 };
12+
IndexType i3{ 0 };
1213
};
14+
15+
using Face = FaceIndex<uint32_t>;
16+
17+
using FaceSigned = FaceIndex<int32_t>;

include/Matrix.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

include/Matrix33F.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// (c) 2025, UltiMaker -- see LICENCE for details
2+
3+
#pragma once
4+
5+
struct Point2F;
6+
class Point3F;
7+
class Vector3F;
8+
9+
class Matrix33F
10+
{
11+
public:
12+
explicit Matrix33F() = default;
13+
14+
void transpose();
15+
16+
[[nodiscard]] Point2F project(const Point3F& vertex) const;
17+
18+
static Matrix33F makeOrthogonalBasis(const Vector3F& normal);
19+
20+
private:
21+
float values_[3][3];
22+
};

include/Matrix44F.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// (c) 2025, UltiMaker -- see LICENCE for details
2+
3+
#pragma once
4+
#include "Point3F.h"
5+
6+
class Matrix44F
7+
{
8+
public:
9+
explicit Matrix44F() = default;
10+
11+
explicit Matrix44F(const float values[4][4]);
12+
13+
Point3F preMultiply(const Point3F& point) const;
14+
15+
private:
16+
float values_[4][4];
17+
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#pragma once
44

5-
struct UVCoord
5+
struct Point2F
66
{
7-
float u{ 0.0 };
8-
float v{ 0.0 };
7+
float x{ 0.0 };
8+
float y{ 0.0 };
99
};

include/Point3F.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// (c) 2025, UltiMaker -- see LICENCE for details
2+
3+
#pragma once
4+
5+
class Matrix44F;
6+
7+
class Point3F
8+
{
9+
public:
10+
explicit Point3F(const float x, const float y, const float z);
11+
12+
[[nodiscard]] float x() const
13+
{
14+
return x_;
15+
}
16+
17+
[[nodiscard]] float y() const
18+
{
19+
return y_;
20+
}
21+
22+
[[nodiscard]] float z() const
23+
{
24+
return z_;
25+
}
26+
27+
Point3F& operator/=(const float scale);
28+
29+
friend bool operator<(const Point3F& lhs, const Point3F& rhs)
30+
{
31+
if (lhs.x_ != rhs.x_)
32+
{
33+
return lhs.x_ < rhs.x_;
34+
}
35+
36+
if (lhs.y_ != rhs.y_)
37+
{
38+
return lhs.y_ < rhs.y_;
39+
}
40+
41+
return lhs.z_ < rhs.z_;
42+
}
43+
44+
private:
45+
float x_{ 0.0 };
46+
float y_{ 0.0 };
47+
float z_{ 0.0 };
48+
};

include/Triangle2F.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// (c) 2025, UltiMaker -- see LICENCE for details
2+
3+
#pragma once
4+
5+
#include "Point2F.h"
6+
7+
struct Triangle2F
8+
{
9+
Point2F p1;
10+
Point2F p2;
11+
Point2F p3;
12+
};

0 commit comments

Comments
 (0)