diff --git a/Step 3/cmake-build-release/.ninja_deps b/Step 3/cmake-build-release/.ninja_deps index aad4241..d9b5681 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 fcd8a15..e53f8ec 100644 --- a/Step 3/cmake-build-release/.ninja_log +++ b/Step 3/cmake-build-release/.ninja_log @@ -32,3 +32,21 @@ 2024 2092 1668636254845829121 Step_3 9d5d6ad8db7a0552 1 2159 1668636510057295808 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e 2159 2281 1668636510177299347 Step_3 9d5d6ad8db7a0552 +7 1557 1668638729558081224 CMakeFiles/Step_3.dir/src/graphics/debug_gui.cpp.o 9493619f74acd06a +7 1574 1668638729574081674 CMakeFiles/Step_3.dir/src/engine/math/colliders.cpp.o 39e9f435096d066b +6 1747 1668638729746086503 CMakeFiles/Step_3.dir/src/engine/globals.cpp.o 4ef77d2224f86511 +7 1869 1668638729870089983 CMakeFiles/Step_3.dir/src/engine/util/debug.cpp.o d86a254d2bce8f74 +8 1915 1668638729914091218 CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o 330ad35a6abf06c3 +6 2036 1668638730038094702 CMakeFiles/Step_3.dir/src/engine/math/bvh.cpp.o 7d05e3e63b85d471 +7 2214 1668638730214099644 CMakeFiles/Step_3.dir/src/engine/util/parser.cpp.o 1007c86c207ac940 +7 2355 1668638730354103574 CMakeFiles/Step_3.dir/src/engine/util/models.cpp.o 164394d360c43072 +7 2359 1668638730358103688 CMakeFiles/Step_3.dir/src/engine/world.cpp.o 6470df278966c4 +6 2756 1668638730758114918 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +1747 2768 1668638730770115257 CMakeFiles/Step_3.dir/src/graphics/input.cpp.o 510001b0955ab019 +1558 3089 1668638731090124243 CMakeFiles/Step_3.dir/src/graphics/gl/shader.cpp.o 2553d57dba16057b +6 8726 1668638736726282542 CMakeFiles/Step_3.dir/src/engine/image/image.cpp.o 1c68ba16e6b4d09b +1 1000 1668638793499880427 CMakeFiles/Step_3.dir/src/engine/globals.cpp.o 4ef77d2224f86511 +1 1393 1668638820428640327 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1 1823 1668638855401629000 CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o 11f0e227e9fda9ca +1 1938 1668638882162386794 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +1938 2015 1668638882238388948 Step_3 9d5d6ad8db7a0552 diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/globals.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/globals.cpp.o index 2479ec5..1c8ce7e 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/globals.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/globals.cpp.o differ 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 a7e37f3..a4fa3cb 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/raytracing.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o index 76d78a9..2cb62ec 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/raytracing.cpp.o differ diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/util/parser.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/util/parser.cpp.o index 798948e..5dfa497 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/util/parser.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/engine/util/parser.cpp.o differ diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/debug_gui.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/debug_gui.cpp.o index a1281ba..cd00c14 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/debug_gui.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/debug_gui.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 818a992..0d76ea4 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/CMakeFiles/Step_3.dir/src/graphics/input.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/input.cpp.o index 73107bf..75d6b94 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/input.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/input.cpp.o differ diff --git a/Step 3/cmake-build-release/Step_3 b/Step 3/cmake-build-release/Step_3 index ef86825..3f0d36e 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 ab4e83a..a163711 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 16 17:11 EST +Start testing: Nov 16 17:48 EST ---------------------------------------------------------- -End testing: Nov 16 17:11 EST +End testing: Nov 16 17:48 EST diff --git a/Step 3/include/engine/util/std.h b/Step 3/include/engine/util/std.h index 5519a37..3632ca3 100644 --- a/Step 3/include/engine/util/std.h +++ b/Step 3/include/engine/util/std.h @@ -56,6 +56,11 @@ static inline double degreeeToRadian(double deg) { } namespace Raytracing { + struct Signals { + bool haltExecution {false}; + bool pauseRaytracing {false}; + bool haltRaytracing {false}; + }; class AlignedAllocator { private: public: diff --git a/Step 3/src/engine/globals.cpp b/Step 3/src/engine/globals.cpp index acc3306..cf4bdc5 100644 --- a/Step 3/src/engine/globals.cpp +++ b/Step 3/src/engine/globals.cpp @@ -4,19 +4,16 @@ */ // Yes, globals are bad. #include "engine/util/debug.h" - +#include #include #ifdef COMPILE_GUI #include #endif -bool* haltExecution; -bool* pauseRaytracing; -bool* haltRaytracing; - namespace Raytracing { std::unordered_map> profiles; + Signals* RTSignal = new Signals {}; #ifdef COMPILE_GUI std::shared_ptr aabbVAO = nullptr; int count = 0; diff --git a/Step 3/src/engine/main.cpp b/Step 3/src/engine/main.cpp index cdd77fe..07fa793 100644 --- a/Step 3/src/engine/main.cpp +++ b/Step 3/src/engine/main.cpp @@ -24,11 +24,11 @@ * */ -using namespace Raytracing; +namespace Raytracing{ + extern Signals* RTSignal; +} -extern bool* haltExecution; -extern bool* pauseRaytracing; -extern bool* haltRaytracing; +using namespace Raytracing; int main(int argc, char** args) { // since this is linux only we can easily set our process priority to be high with a syscall @@ -77,20 +77,13 @@ int main(int argc, char** args) { if (parser.parse(args, argc)) return 0; - // yes this is a very stupid and bad way of doing this. - haltExecution = new bool; - pauseRaytracing = new bool; - haltRaytracing = new bool; - *haltExecution = false; - *pauseRaytracing = false; - *haltRaytracing = false; if (signal(SIGTERM, [] (int sig) -> void { ilog<<"Computations complete.\nHalting now...\n"; - *haltExecution = true; + RTSignal->haltExecution = true; })==SIG_ERR) { elog<<"Unable to change signal handler.\n"; return 1; } if (signal(SIGINT, [] (int sig) -> void { ilog<<"Computations complete.\nHalting now...\n"; - *haltExecution = true; + RTSignal->haltExecution = true; })==SIG_ERR) { elog<<"Unable to change signal handler.\n"; return 1; } tlog << "Parsing complete! Starting raytracer with options:" << std::endl; @@ -160,7 +153,7 @@ int main(int argc, char** args) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); window.endUpdate(); } - *haltExecution = true; + RTSignal->haltExecution= true; raycaster.join(); delete(spiderVAO); delete(houseVAO); @@ -201,9 +194,7 @@ int main(int argc, char** args) { ilog << "Writing Image!\n"; imageOutput.write(parser.getOptionValue("--output") + timeString.str(), parser.getOptionValue("--format")); - delete(haltExecution); - delete(haltRaytracing); - delete(pauseRaytracing); + delete(RTSignal); #ifdef COMPILE_GUI deleteQuad(); #endif diff --git a/Step 3/src/engine/raytracing.cpp b/Step 3/src/engine/raytracing.cpp index 4de6c79..c1cacd3 100644 --- a/Step 3/src/engine/raytracing.cpp +++ b/Step 3/src/engine/raytracing.cpp @@ -8,12 +8,10 @@ #include #include -extern bool* haltExecution; -extern bool* pauseRaytracing; -extern bool* haltRaytracing; - namespace Raytracing { + extern Signals* RTSignal; + Ray Camera::projectRay(PRECISION_TYPE x, PRECISION_TYPE y) { // transform the x and y to points from image coords to be inside the camera's viewport. double transformedX = (x / (image.getWidth() - 1)); @@ -93,9 +91,9 @@ namespace Raytracing { Ray localRay = ray; Vec4 color {1.0, 1.0, 1.0}; for (int CURRENT_BOUNCE = 0; CURRENT_BOUNCE < maxBounceDepth; CURRENT_BOUNCE++){ - if (*haltExecution || *haltRaytracing) + if (RTSignal->haltExecution || RTSignal->haltRaytracing) return color; - while (*pauseRaytracing) // sleep for 1/60th of a second, or about 1 frame. + while (RTSignal->pauseRaytracing) // sleep for 1/60th of a second, or about 1 frame. std::this_thread::sleep_for(std::chrono::milliseconds(16)); auto hit = world.checkIfHit(localRay, 0.001, infinity); if (hit.first.hit) { @@ -153,9 +151,9 @@ namespace Raytracing { PRECISION_TYPE sf = 1.0 / raysPerPixel; // apply pixel color with gamma correction image.setPixelColor(i, j, {std::sqrt(sf * color.r()), std::sqrt(sf * color.g()), std::sqrt(sf * color.b())}); - if (*haltExecution || *haltRaytracing) + if (RTSignal->haltExecution || RTSignal->haltRaytracing) return; - while (*pauseRaytracing) // sleep for 1/60th of a second, or about 1 frame. + while (RTSignal->pauseRaytracing) // sleep for 1/60th of a second, or about 1 frame. std::this_thread::sleep_for(std::chrono::milliseconds(16)); } } @@ -227,9 +225,9 @@ namespace Raytracing { PRECISION_TYPE sf = 1.0 / raysPerPixel; // apply pixel color with gamma correction image.setPixelColor(x, y, {std::sqrt(sf * color.r()), std::sqrt(sf * color.g()), std::sqrt(sf * color.b())}); - if (*haltExecution || *haltRaytracing) + if (RTSignal->haltExecution || RTSignal->haltRaytracing) return; - while (*pauseRaytracing) // sleep for 1/60th of a second, or about 1 frame. + while (RTSignal->pauseRaytracing) // sleep for 1/60th of a second, or about 1 frame. std::this_thread::sleep_for(std::chrono::milliseconds(16)); } catch (std::exception& error) { flog << "Possibly fatal error in the multithreaded raytracer!\n"; diff --git a/Step 3/src/graphics/graphics.cpp b/Step 3/src/graphics/graphics.cpp index 3bf34d6..4b0e799 100644 --- a/Step 3/src/graphics/graphics.cpp +++ b/Step 3/src/graphics/graphics.cpp @@ -7,13 +7,12 @@ #include #include "engine/image/stb_image.h" #include "graphics/debug_gui.h" - -extern bool* haltExecution; -extern bool* pauseRaytracing; -extern bool* haltRaytracing; +#include namespace Raytracing { + extern Signals* RTSignal; + const std::vector vertices = { 1.0f, 1.0f, 0.0f, // top right 1.0f, -1.0f, 0.0f, // bottom right @@ -482,14 +481,14 @@ namespace Raytracing { static float yaw = 0, pitch = 0; void DisplayRenderer::draw() { - if (*haltExecution){m_window.closeWindow();} + if (RTSignal->haltExecution){m_window.closeWindow();} if (Input::isKeyDown(GLFW_KEY_ESCAPE) && Input::isState(GLFW_KEY_ESCAPE)) m_window.setMouseGrabbed(!m_window.isMouseGrabbed()); DebugUI::render([this]() -> void { if (ImGui::Button("Start") && !started){ started = true; - *haltRaytracing = false; + RTSignal->haltRaytracing = false; ilog << "Running raycaster!\n"; if(m_parser.hasOption("--multi")) { m_raycaster.runMulti(std::max(std::stoi(m_parser.getOptionValue("-t")), std::stoi(m_parser.getOptionValue("--threads")))); @@ -497,9 +496,9 @@ namespace Raytracing { m_raycaster.runSingle(); } } - if (ImGui::Checkbox("Pause", pauseRaytracing)){} + if (ImGui::Checkbox("Pause", &RTSignal->pauseRaytracing)){} if (ImGui::Button("Stop") && started){ - *haltRaytracing = true; + RTSignal->haltRaytracing = true; started = false; m_raycaster.deleteThreads(); }