Blender V2.61 - r43446

rayobject.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version. 
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2009 Blender Foundation.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): André Pinto.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #ifndef RE_RAYOBJECT_H
00034 #define RE_RAYOBJECT_H
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 struct Isect;
00041 struct ObjectInstanceRen;
00042 struct RayHint;
00043 struct VlakRen;
00044 
00045 /* RayObject
00046 
00047    Can be a face/triangle, bvh tree, object instance, etc. This is the
00048    public API used by the renderer, see rayobject_internal.h for the
00049    internal implementation details. */
00050 
00051 typedef struct RayObject RayObject;
00052 
00053 /* Intersection, see rayintersection.h */
00054 
00055 int RE_rayobject_raycast(RayObject *r, struct Isect *i);
00056 
00057 /* Acceleration Structures */
00058 
00059 RayObject* RE_rayobject_octree_create(int ocres, int size);
00060 RayObject* RE_rayobject_instance_create(RayObject *target, float transform[][4], void *ob, void *target_ob);
00061 RayObject* RE_rayobject_empty_create(void);
00062 
00063 RayObject* RE_rayobject_blibvh_create(int size);    /* BLI_kdopbvh.c   */
00064 RayObject* RE_rayobject_vbvh_create(int size);      /* raytrace/rayobject_vbvh.c */
00065 RayObject* RE_rayobject_svbvh_create(int size);     /* raytrace/rayobject_svbvh.c */
00066 RayObject* RE_rayobject_qbvh_create(int size);      /* raytrace/rayobject_qbvh.c */
00067 
00068 /* Building */
00069 
00070 void RE_rayobject_add(RayObject *r, RayObject *);
00071 void RE_rayobject_done(RayObject *r);
00072 void RE_rayobject_free(RayObject *r);
00073 
00074 void RE_rayobject_set_control(RayObject *r, void *data, int (*test_break)(void *data));
00075 
00076 /* RayObject representing faces, all data is locally available instead
00077    of referring to some external data structure, for possibly faster
00078    intersection tests. */
00079 
00080 typedef struct RayFace {
00081     float v1[4], v2[4], v3[4], v4[3];
00082     int quad;
00083     void *ob;
00084     void *face;
00085 } RayFace;
00086 
00087 #define RE_rayface_isQuad(a) ((a)->quad)
00088 
00089 RayObject* RE_rayface_from_vlak(RayFace *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr);
00090 
00091 /* RayObject representing faces directly from a given VlakRen structure. Thus
00092    allowing to save memory, but making code triangle intersection dependant on
00093    render structures. */
00094 
00095 typedef struct VlakPrimitive {
00096     struct ObjectInstanceRen *ob;
00097     struct VlakRen *face;
00098 } VlakPrimitive;
00099 
00100 RayObject* RE_vlakprimitive_from_vlak(VlakPrimitive *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr);
00101 
00102 /* Bounding Box */
00103 
00104 /* extend min/max coords so that the rayobject is inside them */
00105 void RE_rayobject_merge_bb(RayObject *ob, float *min, float *max);
00106 
00107 /* initializes an hint for optiming raycast where it is know that a ray will pass by the given BB often the origin point */
00108 void RE_rayobject_hint_bb(RayObject *r, struct RayHint *hint, float *min, float *max);
00109 
00110 /* initializes an hint for optiming raycast where it is know that a ray will be contained inside the given cone*/
00111 /* void RE_rayobject_hint_cone(RayObject *r, struct RayHint *hint, float *); */
00112 
00113 /* Internals */
00114 
00115 #include "../raytrace/rayobject_internal.h"
00116 
00117 #ifdef __cplusplus
00118 }
00119 #endif
00120 
00121 #endif
00122