BVH now works as first hit

main
Brett 2022-11-16 14:17:41 -05:00
parent 84b5f4f57b
commit e0569f4f29
11 changed files with 111 additions and 82 deletions

View File

@ -2,83 +2,103 @@
374 3235 1668323538168825062 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_tables.cpp.o f6dab204e07e8dcf 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 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 4 3390 1668323512856096078 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_demo.cpp.o 7798aba97da63e31
2 1995 1668622564396040497 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 3 2443 1668624863468056087 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
2 1641 1668366223598629532 CMakeFiles/Step_3.dir/src/engine/util/debug.cpp.o d86a254d2bce8f74 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 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 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 4 605 1668323535536749264 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_impl_x11.cpp.o d1e9a2fcb31e2ec8
0 26 1668358519550031316 build.ninja ccb5de0c063412ab 0 26 1668358519550031316 build.ninja ccb5de0c063412ab
1 1437 1668553279255395930 CMakeFiles/Step_3.dir/src/engine/globals.cpp.o 4ef77d2224f86511 1 1437 1668553279255395930 CMakeFiles/Step_3.dir/src/engine/globals.cpp.o 4ef77d2224f86511
1 1286 1668560874272501152 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b 1 894 1668624669410339888 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 2 1680 1668624862704033582 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 3 6633 1668323516100189511 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui.cpp.o 55e7538fd27b47be
3050 3123 1668622565524074384 Step_3 f055ce2b85635598 2847 2941 1668624863964070696 Step_3 f055ce2b85635598
4 521 1668323535452746847 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_impl_glfw.cpp.o 6aef9db88eb3d76d 4 521 1668323535452746847 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_impl_glfw.cpp.o 6aef9db88eb3d76d
1 2276 1668622564660048427 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 2 2546 1668624863572059151 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 827 1668366742693637470 CMakeFiles/Step_3.dir/src/graphics/input.cpp.o 510001b0955ab019 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 5 4715 1668323514180134213 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_draw.cpp.o f89fa3d7b779872a
3 1806 1668624862832037352 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 521 6249 1668323541180911801 CMakeFiles/Step_3.dir/src/graphics/imgui/imgui_widgets.cpp.o 84017388bc7af144
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 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 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 2 1655 1668489141487439674 CMakeFiles/Step_3.dir/src/graphics/gl/shader.cpp.o 2553d57dba16057b
1 3050 1668622565452072221 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 1 2847 1668624863872067988 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 2095 1668366224050642556 CMakeFiles/Step_3.dir/src/engine/util/parser.cpp.o 1007c86c207ac940
1 1441 1668622607837344423 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 2 1502 1668624886008720074 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
1 1673 1668622608069351382 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 2 1640 1668624886144724078 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1 1950 1668622608345359658 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 2 1933 1668624886440732800 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 2010 1668622608405361457 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 2 1952 1668624886456733272 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 2653 1668622609049380774 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 2 2605 1668624887112752596 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2653 2750 1668622609145383654 Step_3 f055ce2b85635598 2606 2691 1668624887196755071 Step_3 f055ce2b85635598
2 1660 1668622637558235386 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 1 1606 1668624923021810389 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
2 2114 1668622638014249048 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 1 2012 1668624923429822407 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
2 2170 1668622638070250728 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 1 2049 1668624923465823468 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
2 2326 1668622638226255400 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 1 2133 1668624923549825943 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 2922 1668622638822273258 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 1 3050 1668624924465852926 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2923 2993 1668622638894275415 Step_3 f055ce2b85635598 3050 3124 1668624924537855046 Step_3 f055ce2b85635598
2 1570 1668622687967744606 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 1 1488 1668625031885017292 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
1 1886 1668622688283754060 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 2 1670 1668625032069022712 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1 1941 1668622688335755615 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 2 2398 1668625032797044162 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 2385 1668622688783769017 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 1 2506 1668625032905047343 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 2594 1668622688979774881 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 1 2608 1668625033005050287 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2594 2664 1668622689059777275 Step_3 f055ce2b85635598 2608 2677 1668625033073052290 Step_3 f055ce2b85635598
1 1414 1668622816167573181 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 2 1815 1668625107987259169 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1 1548 1668622816299577119 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 2 1892 1668625108067261527 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
1 1870 1668622816623586779 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 1 2104 1668625108275267655 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 1920 1668622816671588209 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 2 2122 1668625108295268244 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 2561 1668622817315607411 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 1 3088 1668625109263296760 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2561 2630 1668622817383609440 Step_3 f055ce2b85635598 3089 3165 1668625109335298882 Step_3 f055ce2b85635598
2 1498 1668623394036721715 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 1 2065 1668625179621369449 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 2633 1668625180189386184 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
2 1908 1668623394444733784 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 1 2665 1668625180221387125 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 2026 1668623394564737332 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 2 2849 1668625180405392545 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 2711 1668623395248757565 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 1 3316 1668625180869406215 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2711 2784 1668623395320759695 Step_3 f055ce2b85635598 3316 3397 1668625180953408691 Step_3 f055ce2b85635598
1 1392 1668623561945685407 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 2 1886 1668625239263126467 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
2 1677 1668623562229693801 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 3 1886 1668625239263126467 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
2 1795 1668623562345697226 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 2 2073 1668625239451132003 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 1841 1668623562393698646 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 3 2272 1668625239647137779 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 2551 1668623563101719564 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 2 2823 1668625240199154041 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2551 2617 1668623563169721575 Step_3 f055ce2b85635598 2823 2897 1668625240271156163 Step_3 f055ce2b85635598
1 1604 1668623738746907088 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 2 1598 1668625273312129535 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
2 1619 1668623738762907560 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 2 1859 1668625273572137198 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1 1887 1668623739030915474 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 2 2039 1668625273752142497 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 1901 1668623739042915826 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 2 2144 1668625273856145561 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 2605 1668623739746936611 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 1 2695 1668625274408161827 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2605 2679 1668623739818938737 Step_3 f055ce2b85635598 2695 2769 1668625274480163945 Step_3 f055ce2b85635598
2 1693 1668623919580244173 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 1 1715 1668625321753556615 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
1 1791 1668623919676247003 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 2 1908 1668625321945562270 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1 2021 1668623919908253848 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 1 2177 1668625322213570165 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 2141 1668623920028257391 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 1 2255 1668625322293572524 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 2964 1668623920852281703 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 1 2819 1668625322857589138 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2964 3050 1668623920936284182 Step_3 f055ce2b85635598 2819 2893 1668625322929591261 Step_3 f055ce2b85635598
2 1438 1668623936664748250 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 2 2050 1668625704280826069 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 2056 1668625704284826190 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
2 1937 1668623937164763004 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 2 2499 1668625704732839388 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
2 2009 1668623937236765127 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca 2 2529 1668625704756840096 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
2 2578 1668623937804781888 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 1 2897 1668625705128851055 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2578 2651 1668623937876784012 Step_3 f055ce2b85635598 2897 2996 1668625705228854002 Step_3 f055ce2b85635598
1 897 1668624045079946555 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b 2 1604 1668625838336775507 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
897 974 1668624045159948915 Step_3 f055ce2b85635598 2 1701 1668625838432778334 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1 869 1668624303947576324 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b 2 2085 1668625838816789649 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
869 958 1668624304035578916 Step_3 f055ce2b85635598 2 2123 1668625838852790710 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 2839 1668625839568811805 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2839 2913 1668625839644814044 Step_3 f055ce2b85635598
1 1573 1668626125589238351 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
1 1824 1668626125841245776 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
1 2013 1668626126029251315 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
1 2040 1668626126057252141 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
1 2622 1668626126641269346 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2623 2695 1668626126713271469 Step_3 f055ce2b85635598
12 1766 1668626191207171554 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
3 1797 1668626191239172498 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
2 2059 1668626191499180157 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
12 2184 1668626191627183929 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
2 2688 1668626192131198777 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2688 2765 1668626192203200899 Step_3 f055ce2b85635598
2 1914 1668626213395825267 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d
2 1934 1668626213419825973 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072
2 2175 1668626213659833045 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4
2 2397 1668626213879839526 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca
2 2891 1668626214371854021 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e
2891 2971 1668626214451856381 Step_3 f055ce2b85635598

Binary file not shown.

View File

@ -1,3 +1,3 @@
Start testing: Nov 16 13:45 EST Start testing: Nov 16 14:16 EST
---------------------------------------------------------- ----------------------------------------------------------
End testing: Nov 16 13:45 EST End testing: Nov 16 14:16 EST

View File

@ -9,7 +9,7 @@ Size=550,680
Collapsed=1 Collapsed=1
[Window][Debug Menu] [Window][Debug Menu]
Pos=47,47 Pos=114,55
Size=339,226 Size=339,226
Collapsed=0 Collapsed=0
@ -74,7 +74,7 @@ Size=324,211
Collapsed=0 Collapsed=0
[Window][BVH Data ] [Window][BVH Data ]
Pos=1080,448 Pos=1184,623
Size=522,762 Size=522,762
Collapsed=0 Collapsed=0

View File

@ -70,27 +70,36 @@ namespace Raytracing {
} }
BVHHitData doesRayIntersect(const Ray& r, PRECISION_TYPE min, PRECISION_TYPE max){ BVHHitData doesRayIntersect(const Ray& r, PRECISION_TYPE min, PRECISION_TYPE max){
auto ourHitData = aabb.intersects(r, min, max); auto ourHitData = aabb.intersects(r, min, max);
tlog << "Does " << index << " hit? " << ourHitData.hit << "\n";
if (!ourHitData.hit) if (!ourHitData.hit)
return {this, ourHitData, false}; return {this, ourHitData, false};
this->hit = 2; this->hit = 2;
BVHHitData leftHit{}; BVHHitData leftHit{};
leftHit.hit = false;
BVHHitData rightHit{}; BVHHitData rightHit{};
rightHit.hit = false;
if (left != nullptr) if (left != nullptr)
leftHit = left->doesRayIntersect(r, min, max); leftHit = left->doesRayIntersect(r, min, ourHitData.tMax);
if (right != nullptr) if (right != nullptr)
rightHit = right->doesRayIntersect(r, min, max); rightHit = right->doesRayIntersect(r, min, leftHit.hit ? leftHit.data.tMin : ourHitData.tMax);
if (leftHit.hit && leftHit.data.tMax < rightHit.data.tMax) //tlog << "On the left we " << (leftHit.hit ? "hit" : "didn't hit") << ". with tmax " << leftHit.data.tMax << " and tmin " << leftHit.data.tMin << "\n";
//tlog << "On the right we " << (rightHit.hit ? "hit" : "didn't hit") << ". with tmax " << rightHit.data.tMax << " and tmin " << rightHit.data.tMin << "\n";
if (leftHit.hit && (leftHit.data.tMax < rightHit.data.tMax || !rightHit.hit))
return leftHit; return leftHit;
else if (rightHit.hit && rightHit.data.tMax > leftHit.data.tMax) else if (rightHit.hit && (rightHit.data.tMax < leftHit.data.tMax || !leftHit.hit))
return rightHit; return rightHit;
tlog << index << "I " << leftHit.hit << " ? " << rightHit.hit << " " << left << " " << right << " : " << objs.size() << " is empty? " << objs.empty() << "\n" ; //tlog << index << "I " << leftHit.hit << " ? " << rightHit.hit << " " << left << " " << right << " : " << objs.size() << " is empty? " << objs.empty() << "\n" ;
this->hit = !objs.empty(); this->hit = !objs.empty();
return {this, ourHitData, !objs.empty()}; if (objs.empty()){
//tlog << "we hit an empty box " << index << "\n";
return {this, ourHitData, false};
}
//tlog << "We hit a box with objects " << objs.size() << " ! " << index << "\n";
return {this, ourHitData, true};
} }
#ifdef COMPILE_GUI #ifdef COMPILE_GUI
void draw(Shader& worldShader) { void draw(Shader& worldShader) {

View File

@ -102,7 +102,7 @@ namespace Raytracing {
tmin = std::max(tmin, 0.0); tmin = std::max(tmin, 0.0);
// TODO: nans? // TODO: nans?
tlog << "TMin: " << tmin << " TMax: " << tmax << " Case: " << (tmax > tmin) << "\n"; //tlog << "TMin: " << tmin << " TMax: " << tmax << " Case: " << (tmax > tmin) << "\n";
AABBHitData data{}; AABBHitData data{};
data.hit = tmax > tmin; data.hit = tmax > tmin;
data.tMin = tmin; data.tMin = tmin;

View File

@ -561,12 +561,12 @@ namespace Raytracing {
if (Input::isKeyDown(GLFW_KEY_E) && Input::isState(GLFW_KEY_E)) { if (Input::isKeyDown(GLFW_KEY_E) && Input::isState(GLFW_KEY_E)) {
auto ray = m_camera.projectRay((PRECISION_TYPE) m_window.displayWidth() / 2, (PRECISION_TYPE) m_window.displayHeight() / 2); auto ray = m_camera.projectRay((PRECISION_TYPE) m_window.displayWidth() / 2, (PRECISION_TYPE) m_window.displayHeight() / 2);
auto results = m_world.checkIfHit(ray, 0, 1000).first; //auto results = m_world.checkIfHit(ray, 0, 1000).first;
auto bvh = m_world.getBVH()->rayIntersect(ray, 0, 1000); auto bvh = m_world.getBVH()->rayIntersect(ray, 0, 1000);
if (results.hit) //if (results.hit)
ilog << "World Results: " << results.hitPoint << " " << results.length << "\n"; // ilog << "World Results: " << results.hitPoint << " " << results.length << "\n";
else //else
ilog << "World not hit.\n"; // ilog << "World not hit.\n";
if (!bvh.empty()) if (!bvh.empty())
ilog << "BVH Results: " << bvh.size() << " " << bvh[0].ptr->getPosition() << "\n"; ilog << "BVH Results: " << bvh.size() << " " << bvh[0].ptr->getPosition() << "\n";
else else