Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rayintersection.h « include « intern « render « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1935e4ef59caf851716489ab4827ac03976be6e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2007 Blender Foundation.
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * Contributor(s): André Pinto.
 *
 * ***** END GPL LICENSE BLOCK *****
 * RE_raytrace.h: ray tracing api, can be used independently from the renderer. 
 */

/** \file blender/render/intern/include/rayintersection.h
 *  \ingroup render
 */


#ifndef __RAYINTERSECTION_H__
#define __RAYINTERSECTION_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "BLI_math_geom.h"

struct RayObject;

/* Ray Hints */

#define RE_RAY_LCTS_MAX_SIZE	256
#define RT_USE_LAST_HIT			/* last shadow hit is reused before raycasting on whole tree */
//#define RT_USE_HINT			/* last hit object is reused before raycasting on whole tree */

typedef struct LCTSHint {
	int size;
	struct RayObject *stack[RE_RAY_LCTS_MAX_SIZE];
} LCTSHint;

typedef struct RayHint {
	union { LCTSHint lcts; } data;
} RayHint;

/* Ray Intersection */

typedef struct Isect {
	/* ray start, direction (normalized vector), and max distance. on hit,
	 * the distance is modified to be the distance to the hit point. */
	float start[3];
	float dir[3];
	float dist;

	/* for envmap and incremental view update renders */
	float origstart[3];
	float origdir[3];
	
	/* precomputed values to accelerate bounding box intersection */
	int bv_index[6];
	float idot_axis[3];

	/* intersection options */
	int mode;				/* RE_RAY_SHADOW, RE_RAY_MIRROR, RE_RAY_SHADOW_TRA */
	int lay;				/* -1 default, set for layer lamps */
	int skip;				/* skip flags */
	int check;				/* check flags */
	void *userdata;			/* used by bake check */

	/* hit information */
	float u, v;
	int isect;				/* which half of quad */
	
	struct {
		void *ob;
		void *face;
	} hit, orig;
	
	/* last hit optimization */
	struct RayObject *last_hit;

	/* hints */
#ifdef RT_USE_HINT
	RayTraceHint *hint, *hit_hint;
#endif
	RayHint *hint;
	
	/* ray counter */
#ifdef RE_RAYCOUNTER
	RayCounter *raycounter;
#endif

	/* Precalculated coefficients for watertight intersection check. */
	struct IsectRayPrecalc isect_precalc;
} Isect;

/* ray types */
#define RE_RAY_SHADOW 0
#define RE_RAY_MIRROR 1
#define RE_RAY_SHADOW_TRA 2

/* skip options */
#define RE_SKIP_CULLFACE                (1 << 0)
/* if using this flag then *face should be a pointer to a VlakRen */
#define RE_SKIP_VLR_NEIGHBOUR           (1 << 1)

/* check options */
#define RE_CHECK_VLR_NONE               0
#define RE_CHECK_VLR_RENDER             1
#define RE_CHECK_VLR_NON_SOLID_MATERIAL 2
#define RE_CHECK_VLR_BAKE               3

/* arbitrary, but can't use e.g. FLT_MAX because of precision issues */
#define RE_RAYTRACE_MAXDIST	1e15f
#define RE_RAYTRACE_EPSILON 0.0f

#ifdef __cplusplus
}
#endif

#endif /* __RAYINTERSECTION_H__ */