aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/raytrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmath/raytrace.h')
-rw-r--r--linden/indra/llmath/raytrace.h233
1 files changed, 233 insertions, 0 deletions
diff --git a/linden/indra/llmath/raytrace.h b/linden/indra/llmath/raytrace.h
new file mode 100644
index 0000000..58cca69
--- /dev/null
+++ b/linden/indra/llmath/raytrace.h
@@ -0,0 +1,233 @@
1/**
2 * @file raytrace.h
3 * @brief Ray intersection tests for primitives.
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_RAYTRACE_H
29#define LL_RAYTRACE_H
30
31class LLVector3;
32class LLQuaternion;
33
34// All functions produce results in the same reference frame as the arguments.
35//
36// Any arguments of the form "foo_direction" or "foo_normal" are assumed to
37// be normalized, or normalized vectors are stored in them.
38//
39// Vector arguments of the form "shape_scale" represent the scale of the
40// object along the three axes.
41//
42// All functions return the expected TRUE or FALSE, unless otherwise noted.
43// When FALSE is returned, any resulting values that might have been stored
44// are undefined.
45//
46// Rays are defined by a "ray_point" and a "ray_direction" (unit).
47//
48// Lines are defined by a "line_point" and a "line_direction" (unit).
49//
50// Line segements are defined by "point_a" and "point_b", and for intersection
51// purposes are assumed to point from "point_a" to "point_b".
52//
53// A ray is different from a line in that it starts at a point and extends
54// in only one direction.
55//
56// Intersection normals always point outside the object, normal to the object's
57// surface at the point of intersection.
58//
59// Object rotations passed as quaternions are expected to rotate from the
60// object's local frame to the absolute frame. So, if "foo" is a vector in
61// the object's local frame, then "foo * object_rotation" is in the absolute
62// frame.
63
64
65// returns TRUE iff line is not parallel to plane.
66BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction,
67 const LLVector3 &plane_point, const LLVector3 plane_normal,
68 LLVector3 &intersection);
69
70
71// returns TRUE iff line is not parallel to plane.
72BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction,
73 const LLVector3 &plane_point, const LLVector3 plane_normal,
74 LLVector3 &intersection);
75
76
77BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction,
78 const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius,
79 LLVector3 &intersection);
80
81// point_0 through point_2 define the plane_normal via the right-hand rule:
82// circle from point_0 to point_2 with fingers ==> thumb points in direction of normal
83BOOL ray_triangle(const LLVector3 &ray_point, const LLVector3 &ray_direction,
84 const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2,
85 LLVector3 &intersection, LLVector3 &intersection_normal);
86
87
88// point_0 is the lower-left corner, point_1 is the lower-right, point_2 is the upper-right
89// right-hand-rule... curl fingers from lower-left toward lower-right then toward upper-right
90// ==> thumb points in direction of normal
91// assumes a parallelogram, so point_3 is determined by the other points
92BOOL ray_quadrangle(const LLVector3 &ray_point, const LLVector3 &ray_direction,
93 const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2,
94 LLVector3 &intersection, LLVector3 &intersection_normal);
95
96
97BOOL ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction,
98 const LLVector3 &sphere_center, F32 sphere_radius,
99 LLVector3 &intersection, LLVector3 &intersection_normal);
100
101
102// finite right cylinder is defined by end centers: "cyl_top", "cyl_bottom",
103// and by the cylinder radius "cyl_radius"
104BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction,
105 const LLVector3 &cyl_center, const LLVector3 &cyl_scale, const LLQuaternion &cyl_rotation,
106 LLVector3 &intersection, LLVector3 &intersection_normal);
107
108
109// this function doesn't just return a BOOL because the return is currently
110// used to decide how to break up boxes that have been hit by shots...
111// a hack that will probably be changed later
112//
113// returns a number representing the side of the box that was hit by the ray,
114// or NO_SIDE if intersection test failed.
115U32 ray_box(const LLVector3 &ray_point, const LLVector3 &ray_direction,
116 const LLVector3 &box_center, const LLVector3 &box_scale, const LLQuaternion &box_rotation,
117 LLVector3 &intersection, LLVector3 &intersection_normal);
118
119
120/* TODO
121BOOL ray_ellipsoid(const LLVector3 &ray_point, const LLVector3 &ray_direction,
122 const LLVector3 &e_center, const LLVector3 &e_scale, const LLQuaternion &e_rotation,
123 LLVector3 &intersection, LLVector3 &intersection_normal);
124
125
126BOOL ray_cone(const LLVector3 &ray_point, const LLVector3 &ray_direction,
127 const LLVector3 &cone_tip, const LLVector3 &cone_bottom,
128 const LLVector3 &cone_scale, const LLQuaternion &cone_rotation,
129 LLVector3 &intersection, LLVector3 &intersection_normal);
130*/
131
132
133BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction,
134 const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation,
135 LLVector3 &intersection, LLVector3 &intersection_normal);
136
137
138BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction,
139 const LLVector3 &t_center, const LLVector3 &t_scale, const LLQuaternion &t_rotation,
140 LLVector3 &intersection, LLVector3 &intersection_normal);
141
142
143BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction,
144 const LLVector3 &p_center, const LLVector3 &p_scale, const LLQuaternion &p_rotation,
145 LLVector3 &intersection, LLVector3 &intersection_normal);
146
147
148
149/* TODO
150BOOL ray_hemiellipsoid(const LLVector3 &ray_point, const LLVector3 &ray_direction,
151 const LLVector3 &e_center, const LLVector3 &e_scale, const LLQuaternion &e_rotation,
152 const LLVector3 &e_cut_normal,
153 LLVector3 &intersection, LLVector3 &intersection_normal);
154
155
156BOOL ray_hemisphere(const LLVector3 &ray_point, const LLVector3 &ray_direction,
157 const LLVector3 &sphere_center, F32 sphere_radius, const LLVector3 &sphere_cut_normal,
158 LLVector3 &intersection, LLVector3 &intersection_normal);
159
160
161BOOL ray_hemicylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction,
162 const LLVector3 &cyl_top, const LLVector3 &cyl_bottom, F32 cyl_radius,
163 const LLVector3 &cyl_cut_normal,
164 LLVector3 &intersection, LLVector3 &intersection_normal);
165
166
167BOOL ray_hemicone(const LLVector3 &ray_point, const LLVector3 &ray_direction,
168 const LLVector3 &cone_tip, const LLVector3 &cone_bottom,
169 const LLVector3 &cone_scale, const LLVector3 &cyl_cut_normal,
170 LLVector3 &intersection, LLVector3 &intersection_normal);
171*/
172
173
174BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b,
175 const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius,
176 LLVector3 &intersection);
177
178// point_0 through point_2 define the plane_normal via the right-hand rule:
179// circle from point_0 to point_2 with fingers ==> thumb points in direction of normal
180BOOL linesegment_triangle(const LLVector3 &point_a, const LLVector3 &point_b,
181 const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2,
182 LLVector3 &intersection, LLVector3 &intersection_normal);
183
184
185// point_0 is the lower-left corner, point_1 is the lower-right, point_2 is the upper-right
186// right-hand-rule... curl fingers from lower-left toward lower-right then toward upper-right
187// ==> thumb points in direction of normal
188// assumes a parallelogram, so point_3 is determined by the other points
189BOOL linesegment_quadrangle(const LLVector3 &point_a, const LLVector3 &point_b,
190 const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2,
191 LLVector3 &intersection, LLVector3 &intersection_normal);
192
193
194BOOL linesegment_sphere(const LLVector3 &point_a, const LLVector3 &point_b,
195 const LLVector3 &sphere_center, F32 sphere_radius,
196 LLVector3 &intersection, LLVector3 &intersection_normal);
197
198
199// finite right cylinder is defined by end centers: "cyl_top", "cyl_bottom",
200// and by the cylinder radius "cyl_radius"
201BOOL linesegment_cylinder(const LLVector3 &point_a, const LLVector3 &point_b,
202 const LLVector3 &cyl_center, const LLVector3 &cyl_scale, const LLQuaternion &cyl_rotation,
203 LLVector3 &intersection, LLVector3 &intersection_normal);
204
205
206// this function doesn't just return a BOOL because the return is currently
207// used to decide how to break up boxes that have been hit by shots...
208// a hack that will probably be changed later
209//
210// returns a number representing the side of the box that was hit by the ray,
211// or NO_SIDE if intersection test failed.
212U32 linesegment_box(const LLVector3 &point_a, const LLVector3 &point_b,
213 const LLVector3 &box_center, const LLVector3 &box_scale, const LLQuaternion &box_rotation,
214 LLVector3 &intersection, LLVector3 &intersection_normal);
215
216
217BOOL linesegment_prism(const LLVector3 &point_a, const LLVector3 &point_b,
218 const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation,
219 LLVector3 &intersection, LLVector3 &intersection_normal);
220
221
222BOOL linesegment_tetrahedron(const LLVector3 &point_a, const LLVector3 &point_b,
223 const LLVector3 &t_center, const LLVector3 &t_scale, const LLQuaternion &t_rotation,
224 LLVector3 &intersection, LLVector3 &intersection_normal);
225
226
227BOOL linesegment_pyramid(const LLVector3 &point_a, const LLVector3 &point_b,
228 const LLVector3 &p_center, const LLVector3 &p_scale, const LLQuaternion &p_rotation,
229 LLVector3 &intersection, LLVector3 &intersection_normal);
230
231
232#endif
233