Add the hit function to get the closest non negative hit, and add some mecanisme to test that properly and report when no valid hit occur.

This commit is contained in:
Godzil
2020-02-17 12:24:15 +00:00
parent 1900d1f45d
commit c4418683c6
4 changed files with 99 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ public:
void add(Intersection i);
int count() { return this->num; };
Intersection operator[](const int p) { return this->list[p]; }
Intersection hit();
};
#endif //DORAYME_INTERSECT_H

View File

@@ -21,6 +21,9 @@ public:
public:
Intersection(double t, Object *object) : t(t), object(object) { };
bool nothing() { return (this->object == nullptr); };
bool operator==(const Intersection &b) const { return ((this->t == b.t) && (this->object == b.object)); };
};
#endif //DORAYME_INTERSECTION_H