From 0dafba17af044532fa2f14c61176e7994336f56c Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sun, 1 Aug 2021 16:48:27 +0200 Subject: Use SAH to generate BVH & fix ray triangle intersection --- src/scene.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/scene.cpp') 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()); } -- cgit v1.3