diff --git a/Step 3/cmake-build-release/.ninja_deps b/Step 3/cmake-build-release/.ninja_deps index 8980b28..8f27e5a 100644 Binary files a/Step 3/cmake-build-release/.ninja_deps and b/Step 3/cmake-build-release/.ninja_deps differ diff --git a/Step 3/cmake-build-release/.ninja_log b/Step 3/cmake-build-release/.ninja_log index c8774cd..0027d25 100644 --- a/Step 3/cmake-build-release/.ninja_log +++ b/Step 3/cmake-build-release/.ninja_log @@ -2,66 +2,70 @@ 374 3235 1668323538168825062 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_tables.cpp.o f6dab204e07e8dcf 2 2022 1668323499583713805 CMakeFiles/Step_3.dir/src/graphics/gl/gl.c.o 30ab06816e8637c1 4 3390 1668323512856096078 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_demo.cpp.o 7798aba97da63e31 -2 2114 1668546480900864797 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +2 2056 1668560221885291500 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 2 1641 1668366223598629532 CMakeFiles/Step_3.dir/src/engine/util/debug.cpp.o d86a254d2bce8f74 1 6863 1668489146695541389 CMakeFiles/Step_3.dir/src/engine/image/image.cpp.o 1c68ba16e6b4d09b 2 1301 1668366223258619732 CMakeFiles/Step_3.dir/src/graphics/debug_gui.cpp.o 9493619f74acd06a 4 605 1668323535536749264 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_impl_x11.cpp.o d1e9a2fcb31e2ec8 0 26 1668358519550031316 build.ninja ccb5de0c063412ab -2 1171 1668539611850637805 CMakeFiles/Step_3.dir/src/engine/globals.cpp.o 4ef77d2224f86511 -1 818 1668545258765546884 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b -2 1391 1668546480176844883 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +1 1437 1668553279255395930 CMakeFiles/Step_3.dir/src/engine/globals.cpp.o 4ef77d2224f86511 +2 858 1668553424047747799 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b +2 1619 1668560221449278925 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 3 6633 1668323516100189511 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui.cpp.o 55e7538fd27b47be -2466 2536 1668546481320876352 Step_3 f055ce2b85635598 +2824 2893 1668560222721315613 Step_3 f055ce2b85635598 4 521 1668323535452746847 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_impl_glfw.cpp.o 6aef9db88eb3d76d -1 1817 1668546480604856656 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +2 2187 1668560222017295308 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 1 827 1668366742693637470 CMakeFiles/Step_3.dir/src/graphics/input.cpp.o 510001b0955ab019 5 4715 1668323514180134213 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_draw.cpp.o f89fa3d7b779872a -2 1656 1668546480440852145 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 521 6249 1668323541180911801 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_widgets.cpp.o 84017388bc7af144 -3 1504 1668539612182647872 CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o 330ad35a6abf06c3 +2 1784 1668560221613283655 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1 1651 1668553279471402444 CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o 330ad35a6abf06c3 4 374 1668323535308742700 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_impl_opengl3.cpp.o 1b5f0fbe3cf8ce4e 2 1655 1668489141487439674 CMakeFiles/Step_3.dir/src/graphics/gl/shader.cpp.o 2553d57dba16057b -1 2466 1668546481252874479 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +1 2824 1668560222653313653 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 2 2095 1668366224050642556 CMakeFiles/Step_3.dir/src/engine/util/parser.cpp.o 1007c86c207ac940 -1 1595 1668546503513487557 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d -1596 1677 1668546503593489763 Step_3 f055ce2b85635598 -1 1667 1668546613472534906 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 -1 1765 1668546613568537578 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d -1 2011 1668546613816544487 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca -1 2634 1668546614440561861 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 -1 2839 1668546614644567542 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e -2840 2924 1668546614728569881 Step_3 f055ce2b85635598 -2 1503 1668546664905969925 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 -2 1774 1668546665177977529 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d -1 1837 1668546665241979318 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca -2 2200 1668546665605989494 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 -1 2541 1668546665945998998 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e -2541 2621 1668546666026001236 Step_3 f055ce2b85635598 -2 1815 1668546866179632251 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d -2 1821 1668546866187632477 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 -2 1885 1668546866251634287 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 -2 2159 1668546866523641982 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca -1 2761 1668546867127659070 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e -2761 2826 1668546867191660882 Step_3 f055ce2b85635598 -1 1633 1668546918285108046 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d -1 1633 1668546918285108046 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 -1 1915 1668546918565115986 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 -1 1997 1668546918649118365 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca -1 2691 1668546919341137991 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e -2691 2758 1668546919409139920 Step_3 f055ce2b85635598 -1 983 1668547097978221140 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b -983 1070 1668547098062223537 Step_3 f055ce2b85635598 -1 819 1668547150995735542 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b -819 897 1668547151071737716 Step_3 f055ce2b85635598 -1 822 1668547225097855828 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b -822 890 1668547225161857663 Step_3 f055ce2b85635598 -1 980 1668547305172151145 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b -980 1050 1668547305240153096 Step_3 f055ce2b85635598 -1 1255 1668547390318595902 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b -1 1473 1668547390534602108 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 -2 1618 1668547390678606246 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d -1 2014 1668547391074617625 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca -1 2020 1668547391082617856 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 -1 3089 1668547392150648545 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e -3089 3168 1668547392226650728 Step_3 f055ce2b85635598 +2 1509 1668560252966188047 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +2 1665 1668560253126192663 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +2 1929 1668560253390200279 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +2 1992 1668560253450202009 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +2 2780 1668560254238224744 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +2780 2859 1668560254318227051 Step_3 f055ce2b85635598 +1 1481 1668560339880695960 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1481 1555 1668560339952698039 Step_3 f055ce2b85635598 +1 1679 1668560468476408446 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +1 1871 1668560468668413990 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1 2029 1668560468824418498 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +1 2223 1668560469020424158 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +1 2703 1668560469500438019 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +2703 2817 1668560469612441251 Step_3 f055ce2b85635598 +3 1921 1668560587747853354 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +2 2151 1668560587975859941 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +2 2273 1668560588099863524 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +2 2538 1668560588363871149 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +1 3013 1668560588839884901 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +3013 3085 1668560588911886981 Step_3 f055ce2b85635598 +1 1627 1668560649853673478 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +1 1864 1668560650093680853 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1 1984 1668560650213684538 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +1 2049 1668560650277686507 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +1 2755 1668560650981708138 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +2755 2843 1668560651069710841 Step_3 f055ce2b85635598 +1 1488 1668560671698343966 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +2 1799 1668560672010353531 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1 1890 1668560672102356352 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +1 1947 1668560672158358069 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +1 2753 1668560672962382719 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +2753 2821 1668560673030384802 Step_3 f055ce2b85635598 +1 1510 1668560703463316419 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +2 1760 1668560703715324122 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +2 2002 1668560703955331457 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +1 2168 1668560704123336593 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +1 2726 1668560704679353588 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +2726 2796 1668560704747355667 Step_3 f055ce2b85635598 +1 1286 1668560874272501152 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b +2 2073 1668560875100526126 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1 2244 1668560875272531314 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +2 2318 1668560875324532882 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +1 2698 1668560875724544946 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +1 3094 1668560876120556890 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +3094 3172 1668560876196559183 Step_3 f055ce2b85635598 diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/main.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/main.cpp.o index f7164b7..81e5364 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/main.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/main.cpp.o differ diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o index 1cc873d..b81afe4 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o differ diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/world.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/world.cpp.o index cc304b4..1fe0aea 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/world.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/world.cpp.o differ diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o index 48cafef..50ad88a 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o differ diff --git a/Step 3/cmake-build-release/Step_3 b/Step 3/cmake-build-release/Step_3 index 8ceff0c..4061e5e 100755 Binary files a/Step 3/cmake-build-release/Step_3 and b/Step 3/cmake-build-release/Step_3 differ diff --git a/Step 3/cmake-build-release/Testing/Temporary/LastTest.log b/Step 3/cmake-build-release/Testing/Temporary/LastTest.log index 12867bf..ac03c72 100644 --- a/Step 3/cmake-build-release/Testing/Temporary/LastTest.log +++ b/Step 3/cmake-build-release/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Nov 15 16:23 EST +Start testing: Nov 15 20:07 EST ---------------------------------------------------------- -End testing: Nov 15 16:23 EST +End testing: Nov 15 20:07 EST diff --git a/Step 3/cmake-build-release/imgui.ini b/Step 3/cmake-build-release/imgui.ini index d00001d..1a32e0c 100644 --- a/Step 3/cmake-build-release/imgui.ini +++ b/Step 3/cmake-build-release/imgui.ini @@ -9,7 +9,7 @@ Size=550,680 Collapsed=1 [Window][Debug Menu] -Pos=35,13 +Pos=-21,27 Size=339,226 Collapsed=0 @@ -74,7 +74,7 @@ Size=324,211 Collapsed=0 [Window][BVH Data ] -Pos=897,115 +Pos=1113,250 Size=522,476 Collapsed=0 diff --git a/Step 3/include/engine/math/bvh.h b/Step 3/include/engine/math/bvh.h index 975622a..36cd048 100644 --- a/Step 3/include/engine/math/bvh.h +++ b/Step 3/include/engine/math/bvh.h @@ -70,38 +70,28 @@ namespace Raytracing { } BVHHitData doesRayIntersect(const Ray& r, PRECISION_TYPE min, PRECISION_TYPE max){ auto ourHitData = aabb.intersects(r, min, max); - ilog << "Our hit did hit? " << ourHitData.hit << "\n"; if (!ourHitData.hit) return {this, ourHitData, false}; - /*this->hit = 2; + this->hit = 2; BVHHitData leftHit{}; BVHHitData rightHit{}; if (left != nullptr) - leftHit = left->doesRayIntersect(r, min, max); + leftHit = left->doesRayIntersect(r, min, ourHitData.tMax); if (right != nullptr) - rightHit = right->doesRayIntersect(r, min, max); + rightHit = right->doesRayIntersect(r, min, leftHit.hit ? leftHit.data.tMin : ourHitData.tMax); - if (!leftHit.hit && !rightHit.hit) - return {this, ourHitData, ourHitData.hit}; - - return leftHit.hit ? leftHit : rightHit;*/ - tlog << ourHitData.hit << "\n"; - return {this, ourHitData, true}; + if (leftHit.data.tMax < rightHit.data.tMax) + return leftHit; + else if (rightHit.data.tMax > leftHit.data.tMax) + return rightHit; + return {this, ourHitData, true};; } #ifdef COMPILE_GUI void draw(Shader& worldShader) { worldShader.setVec3("color", {1.0, 1.0, 1.0}); if (selected == index || hit) { - if (hit == 1) - worldShader.setVec3("color", {0.0, 0.0, 1.0}); - else if (hit == 2) - worldShader.setVec3("color", {0.0, 1.0, 0.0}); - else if (hit == 0) - worldShader.setVec3("color", {1.0, 1.0, 1.0}); - else - worldShader.setVec3("color", {1.0, 0.5, 0.5}); if (selected == index && ImGui::BeginListBox("", ImVec2(250, 350))) { std::stringstream strs; strs << aabb; @@ -122,6 +112,14 @@ namespace Raytracing { worldShader.setMatrix("transform", transform); aabbVAO->draw(worldShader); } + if (hit == 1) + worldShader.setVec3("color", {0.0, 0.0, 1.0}); + else if (hit == 2) + worldShader.setVec3("color", {0.0, 1.0, 0.0}); + else if (hit == 0) + worldShader.setVec3("color", {1.0, 1.0, 1.0}); + else + worldShader.setVec3("color", {1.0, 0.5, 0.5}); auto transform = getTransform(aabb); worldShader.setMatrix("transform", transform); aabbVAO->draw(worldShader); @@ -278,8 +276,12 @@ namespace Raytracing { std::vector rayIntersect(const Ray& ray, PRECISION_TYPE min, PRECISION_TYPE max) { RTAssert(root != nullptr); auto results = root->doesRayIntersect(ray, min, max); - results.ptr->hit = 1; - return results.ptr->objs; + RTAssert(results.ptr != nullptr); + if (results.hit) { + results.ptr->hit = 1; + return results.ptr->objs; + }else + return {}; } void resetNodes(){ reset(root); diff --git a/Step 3/include/engine/math/colliders.h b/Step 3/include/engine/math/colliders.h index 584f71a..538b27c 100644 --- a/Step 3/include/engine/math/colliders.h +++ b/Step 3/include/engine/math/colliders.h @@ -12,7 +12,7 @@ namespace Raytracing { // 3D Axis Aligned Bounding Box for use in a BVH struct AABBHitData { bool hit; - PRECISION_TYPE tMax; + PRECISION_TYPE tMin, tMax; }; class AABB { diff --git a/Step 3/src/engine/math/colliders.cpp b/Step 3/src/engine/math/colliders.cpp index 01fe2d6..e3a5348 100644 --- a/Step 3/src/engine/math/colliders.cpp +++ b/Step 3/src/engine/math/colliders.cpp @@ -102,9 +102,12 @@ namespace Raytracing { tmin = std::max(tmin, 0.0); // TODO: nans? - tlog << "TMin: " << tmin << " TMax: " << tmax << " Case: " << (tmax > tmin) << "\n"; - - return {tmax > tmin, tmin}; + //tlog << "TMin: " << tmin << " TMax: " << tmax << " Case: " << (tmax > tmin) << "\n"; + AABBHitData data{}; + data.hit = tmax > tmin; + data.tMin = tmin; + data.tMax = tmax; + return data; } AABBHitData AABB::intersects(const Ray& ray, PRECISION_TYPE tmin, PRECISION_TYPE tmax) { diff --git a/Step 3/src/graphics/graphics.cpp b/Step 3/src/graphics/graphics.cpp index 290c0ac..2c20eb4 100644 --- a/Step 3/src/graphics/graphics.cpp +++ b/Step 3/src/graphics/graphics.cpp @@ -563,8 +563,14 @@ namespace Raytracing { auto results = m_world.checkIfHit(ray, 0, 1000).first; auto bvh = m_world.getBVH()->rayIntersect(ray, 0, 1000); - ilog << "World Results: " << results.hit << " " << results.hitPoint << " " << results.length << "\n"; - ilog << "BVH Results: " << bvh.size() << " " << bvh[0].ptr->getPosition() << "\n"; + if (results.hit) + ilog << "World Results: " << results.hitPoint << " " << results.length << "\n"; + else + ilog << "World not hit.\n"; + if (!bvh.empty()) + ilog << "BVH Results: " << bvh.size() << " " << bvh[0].ptr->getPosition() << "\n"; + else + ilog << "BVH not hit.\n"; } if (Input::isKeyDown(GLFW_KEY_R) && Input::isState(GLFW_KEY_R)) m_world.getBVH()->resetNodes();