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