2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2009 Blender Foundation.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): André Pinto.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file blender/render/intern/include/rayobject.h
33 #ifndef __RAYOBJECT_H__
34 #define __RAYOBJECT_H__
41 struct ObjectInstanceRen;
46 * Can be a face/triangle, bvh tree, object instance, etc. This is the
47 * public API used by the renderer, see rayobject_internal.h for the
48 * internal implementation details.
50 typedef struct RayObject RayObject;
52 /* Intersection, see rayintersection.h */
54 int RE_rayobject_raycast(RayObject *r, struct Isect *i);
56 /* Acceleration Structures */
58 RayObject *RE_rayobject_octree_create(int ocres, int size);
59 RayObject *RE_rayobject_instance_create(RayObject *target, float transform[4][4], void *ob, void *target_ob);
60 RayObject *RE_rayobject_empty_create(void);
62 RayObject *RE_rayobject_blibvh_create(int size); /* BLI_kdopbvh.c */
63 RayObject *RE_rayobject_vbvh_create(int size); /* raytrace/rayobject_vbvh.c */
64 RayObject *RE_rayobject_svbvh_create(int size); /* raytrace/rayobject_svbvh.c */
65 RayObject *RE_rayobject_qbvh_create(int size); /* raytrace/rayobject_qbvh.c */
69 void RE_rayobject_add(RayObject *r, RayObject *);
70 void RE_rayobject_done(RayObject *r);
71 void RE_rayobject_free(RayObject *r);
73 void RE_rayobject_set_control(RayObject *r, void *data, int (*test_break)(void *data));
75 /* RayObject representing faces, all data is locally available instead
76 * of referring to some external data structure, for possibly faster
77 * intersection tests. */
79 typedef struct RayFace {
80 float v1[4], v2[4], v3[4], v4[3];
86 #define RE_rayface_isQuad(a) ((a)->quad)
88 RayObject *RE_rayface_from_vlak(RayFace *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr);
90 RayObject *RE_rayface_from_coords(RayFace *rayface, void *ob, void *face, float *v1, float *v2, float *v3, float *v4);
92 /* RayObject representing faces directly from a given VlakRen structure. Thus
93 * allowing to save memory, but making code triangle intersection dependent on
94 * render structures. */
96 typedef struct VlakPrimitive {
97 struct ObjectInstanceRen *ob;
101 RayObject *RE_vlakprimitive_from_vlak(VlakPrimitive *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr);
105 /* extend min/max coords so that the rayobject is inside them */
106 void RE_rayobject_merge_bb(RayObject *ob, float *min, float *max);
108 /* initializes an hint for optimizing raycast where it is know that a ray will pass by the given BB often the origin point */
109 void RE_rayobject_hint_bb(RayObject *r, struct RayHint *hint, float min[3], float max[3]);
111 /* initializes an hint for optimizing raycast where it is know that a ray will be contained inside the given cone*/
112 /* void RE_rayobject_hint_cone(RayObject *r, struct RayHint *hint, float *); */
116 #include "../raytrace/rayobject_internal.h"