/src/ogre/PlugIns/OctreeSceneManager/src/OgreOctreeCamera.cpp
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | /*************************************************************************** |
29 | | octreecamera.cpp - description |
30 | | ------------------- |
31 | | begin : Fri Sep 27 2002 |
32 | | copyright : (C) 2002 by Jon Anderson |
33 | | email : janders@users.sf.net |
34 | | |
35 | | ***************************************************************************/ |
36 | | #include "OgreAxisAlignedBox.h" |
37 | | #include "OgreOctreeCamera.h" |
38 | | |
39 | | namespace Ogre |
40 | | { |
41 | 0 | OctreeCamera::OctreeCamera( const String& name, SceneManager* sm ) : Camera( name, sm ) |
42 | 0 | { |
43 | | |
44 | 0 | } |
45 | | |
46 | | OctreeCamera::~OctreeCamera() |
47 | 0 | { |
48 | 0 | } |
49 | | |
50 | | OctreeCamera::Visibility OctreeCamera::getVisibility( const AxisAlignedBox &bound ) |
51 | 0 | { |
52 | | |
53 | | // Null boxes always invisible |
54 | 0 | if ( bound.isNull() ) |
55 | 0 | return NONE; |
56 | | |
57 | | // Get centre of the box |
58 | 0 | Vector3 centre = bound.getCenter(); |
59 | | // Get the half-size of the box |
60 | 0 | Vector3 halfSize = bound.getHalfSize(); |
61 | |
|
62 | 0 | bool all_inside = true; |
63 | |
|
64 | 0 | for ( uchar plane = 0; plane < 6; ++plane ) |
65 | 0 | { |
66 | | |
67 | | // Skip far plane if infinite view frustum |
68 | 0 | if (plane == FRUSTUM_PLANE_FAR && mFarDist == 0) |
69 | 0 | continue; |
70 | | |
71 | | // This updates frustum planes and deals with cull frustum |
72 | 0 | Plane::Side side = getFrustumPlane(plane).getSide(centre, halfSize); |
73 | 0 | if(side == Plane::NEGATIVE_SIDE) return NONE; |
74 | | // We can't return now as the box could be later on the negative side of a plane. |
75 | 0 | if(side == Plane::BOTH_SIDE) |
76 | 0 | all_inside = false; |
77 | 0 | } |
78 | | |
79 | 0 | if ( all_inside ) |
80 | 0 | return FULL; |
81 | 0 | else |
82 | 0 | return PARTIAL; |
83 | |
|
84 | 0 | } |
85 | | |
86 | | } |
87 | | |
88 | | |
89 | | |
90 | | |