|
1 /************************************************************************* |
|
2 * * |
|
3 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * |
|
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org * |
|
5 * * |
|
6 * This library is free software; you can redistribute it and/or * |
|
7 * modify it under the terms of EITHER: * |
|
8 * (1) The GNU Lesser General Public License as published by the Free * |
|
9 * Software Foundation; either version 2.1 of the License, or (at * |
|
10 * your option) any later version. The text of the GNU Lesser * |
|
11 * General Public License is included with this library in the * |
|
12 * file LICENSE.TXT. * |
|
13 * (2) The BSD-style license that is included with this library in * |
|
14 * the file LICENSE-BSD.TXT. * |
|
15 * * |
|
16 * This library is distributed in the hope that it will be useful, * |
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * |
|
19 * LICENSE.TXT and LICENSE-BSD.TXT for more details. * |
|
20 * * |
|
21 *************************************************************************/ |
|
22 |
|
23 /* |
|
24 |
|
25 stuff common to all spaces |
|
26 |
|
27 */ |
|
28 |
|
29 #ifndef _ODE_COLLISION_SPACE_INTERNAL_H_ |
|
30 #define _ODE_COLLISION_SPACE_INTERNAL_H_ |
|
31 |
|
32 #define ALLOCA(x) dALLOCA16(x) |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 // collide two geoms together. for the hash table space, this is |
|
38 // called if the two AABBs inhabit the same hash table cells. |
|
39 // this only calls the callback function if the AABBs actually |
|
40 // intersect. if a geom has an AABB test function, that is called to |
|
41 // provide a further refinement of the intersection. |
|
42 // |
|
43 // NOTE: this assumes that the geom AABBs are valid on entry |
|
44 // and that both geoms are enabled. |
|
45 |
|
46 static void collideAABBs (dxGeom *g1, dxGeom *g2, |
|
47 void *data, dNearCallback *callback) |
|
48 { |
|
49 |
|
50 |
|
51 // no contacts if both geoms on the same body, and the body is not 0 |
|
52 if (g1->body == g2->body && g1->body) return; |
|
53 |
|
54 // test if the category and collide bitfields match |
|
55 if ( ((g1->category_bits & g2->collide_bits) || |
|
56 (g2->category_bits & g1->collide_bits)) == 0) { |
|
57 return; |
|
58 } |
|
59 |
|
60 // if the bounding boxes are disjoint then don't do anything |
|
61 dReal *bounds1 = g1->aabb; |
|
62 dReal *bounds2 = g2->aabb; |
|
63 if (bounds1[0] > bounds2[1] || |
|
64 bounds1[1] < bounds2[0] || |
|
65 bounds1[2] > bounds2[3] || |
|
66 bounds1[3] < bounds2[2] || |
|
67 bounds1[4] > bounds2[5] || |
|
68 bounds1[5] < bounds2[4]) { |
|
69 return; |
|
70 } |
|
71 |
|
72 // check if either object is able to prove that it doesn't intersect the |
|
73 // AABB of the other |
|
74 if (g1->AABBTest (g2,bounds2) == 0) return; |
|
75 if (g2->AABBTest (g1,bounds1) == 0) return; |
|
76 |
|
77 // the objects might actually intersect - call the space callback function |
|
78 callback (data,g1,g2); |
|
79 } |
|
80 |
|
81 #endif |