};
struct aabox {
- cgm_vec3 p, r;
+ cgm_vec3 vmin, vmax;
};
struct bvhnode {
struct aabox aabb;
- struct triangle **faces;
- int num_faces, max_faces;
+ struct triangle *faces;
+ int num_faces;
+ struct bvhnode *next;
struct bvhnode *sub;
int num_sub;
};
struct material *mtl;
};
+void free_bvh_tree(struct bvhnode *tree);
+
int ray_triangle(cgm_ray *ray, struct triangle *tri, float tmax, struct rayhit *hit);
int ray_aabox_any(cgm_ray *ray, struct aabox *box, float tmax);
int ray_bvhnode(cgm_ray *ray, struct bvhnode *bn, float tmax, struct rayhit *hit);