Fixed checking only first intersection

This commit is contained in:
arvid schröder 2022-11-21 17:02:21 +01:00
parent ed9c300d77
commit 01c4b95c56

View file

@ -4,7 +4,6 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <array>
#include <sstream> #include <sstream>
#include "objmodel.h" #include "objmodel.h"
@ -68,11 +67,11 @@ void ObjModel::loadObj(const std::string& fileName, Vector3d scale, Vector3d tra
} }
bool ObjModel::intersect(Ray &ray) const { bool ObjModel::intersect(Ray &ray) const {
return std::any_of(this->faces.begin(), return std::count_if(this->faces.begin(),
this->faces.end(), this->faces.end(),
[&ray](auto& face){ [&ray](auto& face){
return face.intersect(ray); return face.intersect(ray);
}); }) > 0;
} }
float ObjModel::minimumBounds(int dimension) const { float ObjModel::minimumBounds(int dimension) const {