X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=csgray;a=blobdiff_plain;f=src%2Fgeom.h;fp=src%2Fgeom.h;h=7405fa3b27cab735ff8930b4b0e5096bff0bbe7b;hp=0000000000000000000000000000000000000000;hb=07ca36e28aa10804ba5a544276eb5a25f8105e0f;hpb=40a4c5772ab19e7f27c62768d40f697bf5d80a12 diff --git a/src/geom.h b/src/geom.h new file mode 100644 index 0000000..7405fa3 --- /dev/null +++ b/src/geom.h @@ -0,0 +1,36 @@ +#ifndef GEOM_H_ +#define GEOM_H_ + +#include "csgray.h" +#include "csgimpl.h" + +struct ray { + float x, y, z; + float dx, dy, dz; +}; + +struct hit { + float t; + float x, y, z; + float nx, ny, nz; + csg_object *o; + + struct hit *next; +}; + +struct hit *alloc_hit(void); +void free_hit(struct hit *hit); +void free_hit_list(struct hit *hit); + +struct hit *ray_intersect(struct ray *ray, csg_object *o); + +struct hit *ray_sphere(struct ray *ray, csg_object *o); +struct hit *ray_cylinder(struct ray *ray, csg_object *o); +struct hit *ray_plane(struct ray *ray, csg_object *o); +struct hit *ray_csg_un(struct ray *ray, csg_object *o); +struct hit *ray_csg_isect(struct ray *ray, csg_object *o); +struct hit *ray_csg_sub(struct ray *ray, csg_object *o); + +void xform_ray(struct ray *ray, float *mat); + +#endif /* GEOM_H_ */