X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fbvh.h;fp=src%2Fbvh.h;h=03bc7260ef7e7d30ba570f4f82f4c2ca96b7bcc8;hb=68f8983b5a92709e92355c2d6e756890b4348319;hp=0000000000000000000000000000000000000000;hpb=d2894c1a2380cee76476d63e4800188dcbc121f8;p=cyberay diff --git a/src/bvh.h b/src/bvh.h new file mode 100644 index 0000000..03bc726 --- /dev/null +++ b/src/bvh.h @@ -0,0 +1,24 @@ +#ifndef BVH_H_ +#define BVH_H_ + +#include "geom.h" + +struct bvhnode { + struct aabox aabb; + int axis; + + struct triangle *faces; + int num_faces, max_faces; + + struct bvhnode *left, *right; +}; + +/* build_bvh* needs to be called with a pointer to a single-node tree, + * containing all the faces, left/right as null, and a pre-computed aabb + */ +int build_bvh_sah(struct bvhnode *tree); +void free_bvh_tree(struct bvhnode *tree); + +int ray_bvhnode(cgm_ray *ray, struct bvhnode *bn, float tmax, struct rayhit *hit); + +#endif /* BVH_H_ */