e3865d22b8bd758df9297aa5c1a09729ff34efb2
[csgray] / src / geom.h
1 #ifndef GEOM_H_
2 #define GEOM_H_
3
4 #include "csgray.h"
5 #include "csgimpl.h"
6
7 struct ray {
8         float x, y, z;
9         float dx, dy, dz;
10 };
11
12 struct hit {
13         float t;
14         float x, y, z;
15         float nx, ny, nz;
16         csg_object *o;
17 };
18
19 struct hinterv {
20         struct hit end[2];
21         csg_object *o;
22
23         struct hinterv *next;
24 };
25
26
27 struct hinterv *alloc_hits(int n);
28 void free_hit(struct hinterv *hv);
29 void free_hit_list(struct hinterv *hv);
30
31 struct hinterv *ray_intersect(struct ray *ray, csg_object *o);
32
33 struct hinterv *ray_sphere(struct ray *ray, csg_object *o);
34 struct hinterv *ray_cylinder(struct ray *ray, csg_object *o);
35 struct hinterv *ray_plane(struct ray *ray, csg_object *o);
36 struct hinterv *ray_csg_un(struct ray *ray, csg_object *o);
37 struct hinterv *ray_csg_isect(struct ray *ray, csg_object *o);
38 struct hinterv *ray_csg_sub(struct ray *ray, csg_object *o);
39
40 void xform_ray(struct ray *ray, float *mat);
41
42 #endif  /* GEOM_H_ */