]> Dogcows Code - chaz/yoink/blob - src/moof/plane.cc
the massive refactoring effort
[chaz/yoink] / src / moof / plane.cc
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #include "aabb.hh"
13 #include "plane.hh"
14 #include "sphere.hh"
15
16
17 namespace moof {
18
19
20 plane::halfspace plane::intersects(const aabb<3>& aabb) const
21 {
22 vector3 corners[8];
23 int nPositive = 8;
24
25 aabb.get_corners(corners);
26
27 for (int i = 0; i < 8; ++i)
28 {
29 if (intersects(corners[i]) == negative)
30 {
31 --nPositive;
32 }
33 }
34
35 if (nPositive == 0) return negative;
36 else if (nPositive == 8) return positive;
37 else return intersecting;
38 }
39
40 plane::halfspace plane::intersects(const sphere<3>& sphere) const
41 {
42 scalar distance = distance_to_point(sphere.point);
43
44 if (distance < -sphere.radius) return negative;
45 else if (distance < sphere.radius) return intersecting;
46 else return positive;
47 }
48
49
50 } // namespace moof
51
This page took 0.031132 seconds and 4 git commands to generate.