aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9\/ode/src/collision_space_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ode-0.9\/ode/src/collision_space_internal.h')
-rwxr-xr-xlibraries/ode-0.9\/ode/src/collision_space_internal.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/libraries/ode-0.9\/ode/src/collision_space_internal.h b/libraries/ode-0.9\/ode/src/collision_space_internal.h
new file mode 100755
index 0000000..004276a
--- /dev/null
+++ b/libraries/ode-0.9\/ode/src/collision_space_internal.h
@@ -0,0 +1,84 @@
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
25stuff 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#define CHECK_NOT_LOCKED(space) \
35 dUASSERT ((space)==0 || (space)->lock_count==0, \
36 "invalid operation for locked space");
37
38
39// collide two geoms together. for the hash table space, this is
40// called if the two AABBs inhabit the same hash table cells.
41// this only calls the callback function if the AABBs actually
42// intersect. if a geom has an AABB test function, that is called to
43// provide a further refinement of the intersection.
44//
45// NOTE: this assumes that the geom AABBs are valid on entry
46// and that both geoms are enabled.
47
48static void collideAABBs (dxGeom *g1, dxGeom *g2,
49 void *data, dNearCallback *callback)
50{
51 dIASSERT((g1->gflags & GEOM_AABB_BAD)==0);
52 dIASSERT((g2->gflags & GEOM_AABB_BAD)==0);
53
54 // no contacts if both geoms on the same body, and the body is not 0
55 if (g1->body == g2->body && g1->body) return;
56
57 // test if the category and collide bitfields match
58 if ( ((g1->category_bits & g2->collide_bits) ||
59 (g2->category_bits & g1->collide_bits)) == 0) {
60 return;
61 }
62
63 // if the bounding boxes are disjoint then don't do anything
64 dReal *bounds1 = g1->aabb;
65 dReal *bounds2 = g2->aabb;
66 if (bounds1[0] > bounds2[1] ||
67 bounds1[1] < bounds2[0] ||
68 bounds1[2] > bounds2[3] ||
69 bounds1[3] < bounds2[2] ||
70 bounds1[4] > bounds2[5] ||
71 bounds1[5] < bounds2[4]) {
72 return;
73 }
74
75 // check if either object is able to prove that it doesn't intersect the
76 // AABB of the other
77 if (g1->AABBTest (g2,bounds2) == 0) return;
78 if (g2->AABBTest (g1,bounds1) == 0) return;
79
80 // the objects might actually intersect - call the space callback function
81 callback (data,g1,g2);
82}
83
84#endif