aboutsummaryrefslogtreecommitdiffstats
path: root/src/scene.cpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-08-01 16:48:27 +0200
committerladevieq <ladevie.quentin@gmail.com>2021-08-01 16:48:27 +0200
commit0dafba17af044532fa2f14c61176e7994336f56c (patch)
tree076570f30f590b44e7e076ae497fddd18fd80ed9 /src/scene.cpp
parent17ccf3158443a245ceeabc49cd62f50129a8852d (diff)
Use SAH to generate BVH & fix ray triangle intersection
Diffstat (limited to 'src/scene.cpp')
-rw-r--r--src/scene.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/scene.cpp b/src/scene.cpp
index 8e25be7..b44abd5 100644
--- a/src/scene.cpp
+++ b/src/scene.cpp
@@ -80,9 +80,9 @@ scene::scene(camera cam, uint32_t width, uint32_t height)
auto i2 = mesh_part.indices[i + 1];
auto i3 = mesh_part.indices[i + 2];
- auto v1 = vertex { .position = mesh_part.positions[i1], .normal = mesh_part.normals[i1] };
- auto v2 = vertex { .position = mesh_part.positions[i2], .normal = mesh_part.normals[i2] };
- auto v3 = vertex { .position = mesh_part.positions[i3], .normal = mesh_part.normals[i3] };
+ auto v1 = vertex { .position = mesh_part.positions[i1] };
+ auto v2 = vertex { .position = mesh_part.positions[i2] };
+ auto v3 = vertex { .position = mesh_part.positions[i3] };
triangles.emplace_back(v1, v2, v3);
}
@@ -94,7 +94,5 @@ scene::scene(camera cam, uint32_t width, uint32_t height)
// bvh builder(spheres, nodes);
// builder.exporter();
- for (uint32_t idx = 0; idx < builder.nodes.size(); idx++) {
- nodes[idx] = builder.nodes[idx];
- }
+ std::memcpy(nodes.data(), builder.nodes.data(), sizeof(nodes[0]) * nodes.size());
}