Add empty implementation for ray intersection

This commit is contained in:
karl 2020-12-28 14:08:43 +01:00
parent ab2adf4173
commit c72dde9b84

View File

@ -37,11 +37,21 @@ struct Point {
Triangle *triangle;
};
struct Ray {
Ray(float origin[3], float direction[3]) : origin(origin), direction(direction) {}
float *origin;
float *direction;
};
class KDTree {
public:
KDTree(std::vector<Point *> points) { root = build(points, 0); }
~KDTree() = default;
~KDTree() = default; // TODO: Delete all allocated Nodes
Point *intersect_ray(Ray ray) { return intersect_ray_recurse(ray, root); }
std::string to_string() {
std::string str = "";
@ -105,6 +115,14 @@ class KDTree {
build(right_of_median, depth + 1));
}
Point *intersect_ray_recurse(Ray ray, Node *node) {
// Intersect ray with the point's splitting plane
// If there is an intersection: Recurse to both children (but the nearer one first)
// Otherwise: Recurse only to the nearer one
return node->point; // TODO
}
void to_string_recurse(std::string &str, Node *node, int depth) {
if (node == nullptr) { return; }