diff --git a/src/scene/AABB.h b/src/scene/AABB.h index aa7ef05..50479d7 100644 --- a/src/scene/AABB.h +++ b/src/scene/AABB.h @@ -46,13 +46,9 @@ struct AABB } bool intersects(Ray ray, float tmin, float tmax) { - std::cout << "Hello1" << std::endl; glm::vec3 invD = 1.0f / ray.direction; - std::cout << "Hello2: " << min.x << " " << min.y << " " << min.z << " " << max.x << " " << max.y << " " << max.z << " " << std::endl; glm::vec3 t0s = glm::vec3(min - ray.origin) * invD; - std::cout << "Hello3" << std::endl; glm::vec3 t1s = glm::vec3(max - ray.origin) * invD; - std::cout << "Hello4" << std::endl; glm::vec3 tsmaller = glm::min(t0s, t1s); glm::vec3 tbigger = glm::max(t0s, t1s); diff --git a/src/scene/BVH.cpp b/src/scene/BVH.cpp index 82e7ca3..3b054bb 100644 --- a/src/scene/BVH.cpp +++ b/src/scene/BVH.cpp @@ -14,14 +14,14 @@ void BVH::addModel(PModel model, glm::mat4 transform) void BVH::addModels(std::vector _models, glm::mat4 transform) { - for (int i = 0; i < _models.size(); ++i) + for (auto & _model : _models) { - _models[i]->boundingBox.transform(transform); - for (auto& point : _models[i]->positions) + _model->boundingBox.transform(transform); + for (auto& point : _model->positions) { point = glm::vec3(transform * glm::vec4(point, 1)); } - models.push_back(std::move(_models[i])); + models.push_back(std::move(_model)); } } diff --git a/src/scene/Scene.cpp b/src/scene/Scene.cpp index a6180b5..9299677 100644 --- a/src/scene/Scene.cpp +++ b/src/scene/Scene.cpp @@ -46,12 +46,10 @@ void Scene::render(Camera cam, RenderParameter params) { Ray r = Ray{ .origin = glm::vec3(0.0f), - .direction = glm::vec3(0.0f, 0.0f, 1.0f) + .direction = glm::normalize(glm::vec3((float)std::rand() / RAND_MAX, (float)std::rand() / RAND_MAX, (float)std::rand() / RAND_MAX)) }; bvh.traceRay(r); - std::cout << "HELLO" << std::endl; - accumulator[w + h * params.width] += glm::vec3(w / float(params.width * params.numSamples), h / float(params.height * params.numSamples), 0); } diff --git a/src/util/Model.cpp b/src/util/Model.cpp index 710009f..60e9417 100644 --- a/src/util/Model.cpp +++ b/src/util/Model.cpp @@ -7,9 +7,9 @@ std::optional Model::intersect(const Ray ray) for(size_t posIndex=0, eIndex=0, normalIndex=0; posIndex