aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/mesh.cpp
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2026-02-03 20:26:01 +0100
committervimene <vincent.menegaux@gmail.com>2026-02-03 20:26:01 +0100
commitcbf7d23623b5bb2d2092cb6c86bc965138b4ea75 (patch)
tree7234b255b871cecca24aadc03c8d0857202f48e4 /src/o3d/mesh.cpp
parent0d10b77f77459333c5549711334f417623ab1f3e (diff)
downloadengine-cbf7d23623b5bb2d2092cb6c86bc965138b4ea75.tar.gz
added mipmaps for the hw renderer, improvementsHEADmain
This commit add mipmaps, but for now, mipmaps are generated on the gpu at runtime. We should generate them in advance. - added mipmaps for the hardware renderer - renamed stb_image.c to stb_image.cpp - add compiler flag to stb_image.cpp to prevent warning - added pipe notation for various objects to have all clipping functions be left to right. We need this for the time being because dot notation would considerably complicate the current implementation - small improvements
Diffstat (limited to 'src/o3d/mesh.cpp')
-rw-r--r--src/o3d/mesh.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/o3d/mesh.cpp b/src/o3d/mesh.cpp
index fc5ff78..c3314b4 100644
--- a/src/o3d/mesh.cpp
+++ b/src/o3d/mesh.cpp
@@ -21,7 +21,7 @@ struct VertexIndicesHasher {
}
};
-Mesh Mesh::plane(float width, float height) {
+Mesh Mesh::plane(float width, float height) noexcept {
const float w2 = width / 2,
h2 = height / 2;
return {
@@ -50,18 +50,18 @@ Mesh Mesh::plane(float width, float height) {
};
}
-std::tuple<std::vector<engine::vk::Vertex>, std::vector<uint16_t>> Mesh::linearize_indices() const & {
+std::tuple<std::vector<engine::vk::Vertex>, std::vector<uint16_t>> Mesh::linearize_indices() const & noexcept {
std::unordered_map<std::array<size_t, 3>, size_t, VertexIndicesHasher<3>> unique_vertices;
std::vector<engine::vk::Vertex> linearized_vertices;
std::vector<uint16_t> linearized_indices;
- for (const auto& triangle_indices : this->indices) {
+ for (const auto& triangle_indices : indices) {
for (const auto& vertex_indices : triangle_indices) {
auto it = unique_vertices.find(vertex_indices);
if (it == unique_vertices.end()) {
- linearized_vertices.emplace_back(this->vertices[vertex_indices[0]], this->normals[vertex_indices[1]], this->uvs[vertex_indices[2]]);
+ linearized_vertices.emplace_back(vertices[vertex_indices[0]], normals[vertex_indices[1]], uvs[vertex_indices[2]]);
size_t idx = linearized_vertices.size() - 1;
- unique_vertices.emplace(vertex_indices, idx);
+ unique_vertices[vertex_indices] = idx;
linearized_indices.emplace_back(idx);
} else {
linearized_indices.emplace_back((*it).second);