Correct issue in AABB algorithm
parent
711ddeef17
commit
84b5f4f57b
Binary file not shown.
|
@ -2,82 +2,83 @@
|
|||
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 2056 1668560221885291500 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
2 1995 1668622564396040497 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
|
||||
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
|
||||
1 1286 1668560874272501152 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b
|
||||
2 1543 1668622563948027039 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
|
||||
2824 2893 1668560222721315613 Step_3 f055ce2b85635598
|
||||
3050 3123 1668622565524074384 Step_3 f055ce2b85635598
|
||||
4 521 1668323535452746847 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_impl_glfw.cpp.o 6aef9db88eb3d76d
|
||||
2 2187 1668560222017295308 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 2276 1668622564660048427 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
|
||||
521 6249 1668323541180911801 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_widgets.cpp.o 84017388bc7af144
|
||||
2 1784 1668560221613283655 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
2 1727 1668622564132032567 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 2824 1668560222653313653 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
1 3050 1668622565452072221 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2 2095 1668366224050642556 CMakeFiles/Step_3.dir/src/engine/util/parser.cpp.o 1007c86c207ac940
|
||||
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
|
||||
2 1964 1668566401025537861 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
3 2028 1668566401089539771 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
2 2289 1668566401349547534 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
2 2366 1668566401425549802 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
2 2923 1668566401981566405 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2923 3043 1668566402101569987 Step_3 f055ce2b85635598
|
||||
1 2496 1668566811137562153 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2496 2588 1668566811229564294 Step_3 f055ce2b85635598
|
||||
1 2491 1668566929524384233 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2492 2565 1668566929596385987 Step_3 f055ce2b85635598
|
||||
1 2498 1668566958325089586 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2498 2570 1668566958397091357 Step_3 f055ce2b85635598
|
||||
1 1441 1668622607837344423 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
1 1673 1668622608069351382 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
1 1950 1668622608345359658 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
1 2010 1668622608405361457 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 2653 1668622609049380774 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2653 2750 1668622609145383654 Step_3 f055ce2b85635598
|
||||
2 1660 1668622637558235386 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
2 2114 1668622638014249048 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
2 2170 1668622638070250728 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
2 2326 1668622638226255400 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 2922 1668622638822273258 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2923 2993 1668622638894275415 Step_3 f055ce2b85635598
|
||||
2 1570 1668622687967744606 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
1 1886 1668622688283754060 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
1 1941 1668622688335755615 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
1 2385 1668622688783769017 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 2594 1668622688979774881 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2594 2664 1668622689059777275 Step_3 f055ce2b85635598
|
||||
1 1414 1668622816167573181 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
1 1548 1668622816299577119 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
1 1870 1668622816623586779 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
1 1920 1668622816671588209 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 2561 1668622817315607411 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2561 2630 1668622817383609440 Step_3 f055ce2b85635598
|
||||
2 1498 1668623394036721715 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
2 1631 1668623394168725619 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
2 1908 1668623394444733784 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
1 2026 1668623394564737332 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 2711 1668623395248757565 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2711 2784 1668623395320759695 Step_3 f055ce2b85635598
|
||||
1 1392 1668623561945685407 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
2 1677 1668623562229693801 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
2 1795 1668623562345697226 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
1 1841 1668623562393698646 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 2551 1668623563101719564 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2551 2617 1668623563169721575 Step_3 f055ce2b85635598
|
||||
1 1604 1668623738746907088 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
2 1619 1668623738762907560 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
1 1887 1668623739030915474 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 1901 1668623739042915826 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
1 2605 1668623739746936611 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2605 2679 1668623739818938737 Step_3 f055ce2b85635598
|
||||
2 1693 1668623919580244173 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
1 1791 1668623919676247003 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
1 2021 1668623919908253848 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
1 2141 1668623920028257391 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
1 2964 1668623920852281703 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2964 3050 1668623920936284182 Step_3 f055ce2b85635598
|
||||
2 1438 1668623936664748250 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
|
||||
2 1562 1668623936788751908 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
|
||||
2 1937 1668623937164763004 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
|
||||
2 2009 1668623937236765127 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
|
||||
2 2578 1668623937804781888 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
|
||||
2578 2651 1668623937876784012 Step_3 f055ce2b85635598
|
||||
1 897 1668624045079946555 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b
|
||||
897 974 1668624045159948915 Step_3 f055ce2b85635598
|
||||
1 869 1668624303947576324 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b
|
||||
869 958 1668624304035578916 Step_3 f055ce2b85635598
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,3 +1,3 @@
|
|||
Start testing: Nov 15 21:49 EST
|
||||
Start testing: Nov 16 13:45 EST
|
||||
----------------------------------------------------------
|
||||
End testing: Nov 15 21:49 EST
|
||||
End testing: Nov 16 13:45 EST
|
||||
|
|
|
@ -9,7 +9,7 @@ Size=550,680
|
|||
Collapsed=1
|
||||
|
||||
[Window][Debug Menu]
|
||||
Pos=45,46
|
||||
Pos=47,47
|
||||
Size=339,226
|
||||
Collapsed=0
|
||||
|
||||
|
@ -74,8 +74,8 @@ Size=324,211
|
|||
Collapsed=0
|
||||
|
||||
[Window][BVH Data ]
|
||||
Pos=1221,308
|
||||
Size=522,476
|
||||
Pos=1080,448
|
||||
Size=522,762
|
||||
Collapsed=0
|
||||
|
||||
[Window][Example: Long text display]
|
||||
|
|
|
@ -70,6 +70,7 @@ namespace Raytracing {
|
|||
}
|
||||
BVHHitData doesRayIntersect(const Ray& r, PRECISION_TYPE min, PRECISION_TYPE max){
|
||||
auto ourHitData = aabb.intersects(r, min, max);
|
||||
tlog << "Does " << index << " hit? " << ourHitData.hit << "\n";
|
||||
if (!ourHitData.hit)
|
||||
return {this, ourHitData, false};
|
||||
|
||||
|
@ -78,20 +79,24 @@ namespace Raytracing {
|
|||
BVHHitData leftHit{};
|
||||
BVHHitData rightHit{};
|
||||
if (left != nullptr)
|
||||
leftHit = left->doesRayIntersect(r, min, ourHitData.tMax);
|
||||
leftHit = left->doesRayIntersect(r, min, max);
|
||||
if (right != nullptr)
|
||||
rightHit = right->doesRayIntersect(r, min, leftHit.hit ? leftHit.data.tMax : ourHitData.tMax);
|
||||
rightHit = right->doesRayIntersect(r, min, max);
|
||||
|
||||
if (leftHit.data.tMax < rightHit.data.tMax)
|
||||
if (leftHit.hit && leftHit.data.tMax < rightHit.data.tMax)
|
||||
return leftHit;
|
||||
else if (rightHit.data.tMax > leftHit.data.tMax)
|
||||
else if (rightHit.hit && rightHit.data.tMax > leftHit.data.tMax)
|
||||
return rightHit;
|
||||
return {this, ourHitData, true};;
|
||||
|
||||
tlog << index << "I " << leftHit.hit << " ? " << rightHit.hit << " " << left << " " << right << " : " << objs.size() << " is empty? " << objs.empty() << "\n" ;
|
||||
this->hit = !objs.empty();
|
||||
return {this, ourHitData, !objs.empty()};
|
||||
}
|
||||
#ifdef COMPILE_GUI
|
||||
void draw(Shader& worldShader) {
|
||||
worldShader.setVec3("color", {1.0, 1.0, 1.0});
|
||||
if (selected == index || hit) {
|
||||
aabbVAO->bind();
|
||||
if (selected == index) {
|
||||
if (selected == index && ImGui::BeginListBox("", ImVec2(250, 350))) {
|
||||
std::stringstream strs;
|
||||
strs << aabb;
|
||||
|
@ -106,30 +111,32 @@ namespace Raytracing {
|
|||
ImGui::EndListBox();
|
||||
}
|
||||
|
||||
aabbVAO->bind();
|
||||
for (const auto& obj: objs) {
|
||||
auto transform = getTransform(obj.aabb);
|
||||
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);
|
||||
|
||||
auto splitAABBs = aabb.splitByLongestAxis();
|
||||
/*auto splitAABBs = aabb.splitByLongestAxis();
|
||||
transform = getTransform(splitAABBs.second);
|
||||
worldShader.setMatrix("transform", transform);
|
||||
aabbVAO->draw(worldShader);
|
||||
transform = getTransform(splitAABBs.first);
|
||||
worldShader.setMatrix("transform", transform);
|
||||
aabbVAO->draw(worldShader);*/
|
||||
}
|
||||
if (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
|
||||
worldShader.setVec3("color", {1.0, 0.5, 0.5});
|
||||
auto transform = getTransform(aabb);
|
||||
worldShader.setMatrix("transform", transform);
|
||||
aabbVAO->draw(worldShader);
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +222,10 @@ namespace Raytracing {
|
|||
if (!partitionedObjs.right.empty())
|
||||
right = addObjectsRecur(partitionedObjs.right, partitionedObjs);
|
||||
|
||||
return new BVHNode(objects, world, left, right);
|
||||
if (left == nullptr && right == nullptr)
|
||||
return new BVHNode(objects, world, left, right);
|
||||
else
|
||||
return new BVHNode({}, world, left, right);
|
||||
}
|
||||
#ifdef COMPILE_GUI
|
||||
void drawNodesRecur(Shader& worldShader, BVHNode* node) {
|
||||
|
@ -277,10 +287,9 @@ namespace Raytracing {
|
|||
RTAssert(root != nullptr);
|
||||
auto results = root->doesRayIntersect(ray, min, max);
|
||||
RTAssert(results.ptr != nullptr);
|
||||
if (results.hit) {
|
||||
results.ptr->hit = 1;
|
||||
if (results.hit)
|
||||
return results.ptr->objs;
|
||||
}else
|
||||
else
|
||||
return {};
|
||||
}
|
||||
void resetNodes(){
|
||||
|
|
|
@ -84,8 +84,8 @@ namespace Raytracing {
|
|||
PRECISION_TYPE tx1 = (min.x() - ray.getStartingPoint().x())*ray.getInverseDirection().x();
|
||||
PRECISION_TYPE tx2 = (max.x() - ray.getStartingPoint().x())*ray.getInverseDirection().x();
|
||||
|
||||
tmin = std::min(tmin, std::min(tx1, tx2));
|
||||
tmax = std::max(tmax, std::max(tx1, tx2));
|
||||
tmin = std::max(tmin, std::min(tx1, tx2));
|
||||
tmax = std::min(tmax, std::max(tx1, tx2));
|
||||
|
||||
PRECISION_TYPE ty1 = (min.y() - ray.getStartingPoint().y())*ray.getInverseDirection().y();
|
||||
PRECISION_TYPE ty2 = (max.y() - ray.getStartingPoint().y())*ray.getInverseDirection().y();
|
||||
|
@ -102,7 +102,7 @@ namespace Raytracing {
|
|||
tmin = std::max(tmin, 0.0);
|
||||
|
||||
// TODO: nans?
|
||||
//tlog << "TMin: " << tmin << " TMax: " << tmax << " Case: " << (tmax > tmin) << "\n";
|
||||
tlog << "TMin: " << tmin << " TMax: " << tmax << " Case: " << (tmax > tmin) << "\n";
|
||||
AABBHitData data{};
|
||||
data.hit = tmax > tmin;
|
||||
data.tMin = tmin;
|
||||
|
|
Loading…
Reference in New Issue