liberebus: moved public header to src/
[erebus2020] / liberebus / src / erebus.h
1 #ifndef RENDLIB_H_
2 #define RENDLIB_H_
3
4 #include <cgmath/cgmath.h>
5
6 struct erb_node;
7 struct erb_surf;
8 struct erb_ray;
9 struct erb_hit;
10
11 typedef int (*erb_intersect_func)(struct erb_surf *surf, struct erb_ray *ray, struct erb_hit *hit);
12 typedef void (*erb_sample_func)(struct erb_surf *surf, cgm_vec3 *pos);
13
14 struct erb_node {
15         struct erb_node *par;                                           /* parent node */
16         struct erb_node *clist;                                         /* child nodes */
17         struct erb_surf *surflist;                                      /* surfaces in this node */
18         float xform[16], inv_xform[16];                         /* global transformation */
19         float node_xform[16], inv_node_xform[16];       /* local transformation */
20 };
21
22 struct erb_surf {
23         struct erb_node *node;          /* transformation node for this surface */
24
25         erb_intersect_func isect;       /* intersection routine */
26         erb_sample_func sample;         /* random sample generation */
27 };
28
29 struct erb_ray {
30         cgm_vec3 o, d;          /* origin and direction */
31         float tmin, tmax;       /* segment bounds */
32         float ior;                      /* IOR of the medium through which this ray travels */
33         float total_dist;       /* travel distance accumulator */
34 };
35
36 struct erb_hit {
37         float t, err;
38         struct erb_surf *surf;
39 };
40
41 int erb_init(void);
42 void erb_cleanup(void);
43
44 #endif  /* RENDLIB_H_ */