X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgeom.h;fp=src%2Fgeom.h;h=86a6d230c00980d0b98225fc4b3e2d5788ca0d6c;hb=d2f1a6ab443b86a42e9fd28a19ebdbcf729a5d51;hp=0000000000000000000000000000000000000000;hpb=d05988274bf2ff6274e2c874976681aa989b7d89;p=cyberay diff --git a/src/geom.h b/src/geom.h new file mode 100644 index 0000000..86a6d23 --- /dev/null +++ b/src/geom.h @@ -0,0 +1,44 @@ +#ifndef GEOM_H_ +#define GEOM_H_ + +#include +#include "rt.h" + +struct vertex { + cgm_vec3 pos; + cgm_vec3 norm; + cgm_vec2 tex; +}; + +struct triangle { + struct vertex v[3]; + cgm_vec3 norm; + struct material *mtl; +}; + +struct aabox { + cgm_vec3 p, r; +}; + +struct bvhnode { + struct aabox aabb; + + struct triangle **faces; + int num_faces, max_faces; + + struct bvhnode *sub; + int num_sub; +}; + +struct rayhit { + float t; + struct vertex v; + cgm_ray ray; + struct material *mtl; +}; + +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); + +#endif /* GEOM_H_ */