OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreOctree.h
Go to the documentation of this file.
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-2011 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 octree.h - description
30 -------------------
31 begin : Mon Sep 30 2002
32 copyright : (C) 2002 by Jon Anderson
33 email : janders@users.sf.net
34 
35 Enhancements 2003 - 2004 (C) The OGRE Team
36 ***************************************************************************/
37 
38 #ifndef OCTREE_H
39 #define OCTREE_H
40 
41 #include <OgreAxisAlignedBox.h>
42 #include <OgreWireBoundingBox.h>
43 
44 #include <list>
45 
46 namespace Ogre
47 {
48 
49 class OctreeNode;
50 
59 class Octree : public NodeAlloc
60 {
61 public:
62  Octree( Octree * p );
63  ~Octree();
64 
70  void _addNode( OctreeNode * );
71 
74  void _removeNode( OctreeNode * );
75 
78  int numNodes()
79  {
80  return mNumNodes;
81  };
82 
89 
93 
97 
103  Octree * mChildren[ 2 ][ 2 ][ 2 ];
104 
110  bool _isTwiceSize( const AxisAlignedBox &box ) const;
111 
118  void _getChildIndexes( const AxisAlignedBox &, int *x, int *y, int *z ) const;
119 
124  void _getCullBounds( AxisAlignedBox * ) const;
125 
126 
131 
132 protected:
133 
136  inline void _ref()
137  {
138  mNumNodes++;
139 
140  if ( mParent != 0 ) mParent -> _ref();
141  };
142 
145  inline void _unref()
146  {
147  mNumNodes--;
148 
149  if ( mParent != 0 ) mParent -> _unref();
150  };
151 
153  int mNumNodes;
154 
157 
158 };
159 
160 }
161 
162 #endif
163 
164 
Vector3 mHalfSize
Vector containing the dimensions of this octree / 2.
Definition: OgreOctree.h:96
int mNumNodes
number of SceneNodes in this octree and all its children.
Definition: OgreOctree.h:150
void _removeNode(OctreeNode *)
Removes an Octree scene node to this octree level.
void _addNode(OctreeNode *)
Adds an Octree scene node to this octree level.
Octree * mChildren[2][2][2]
3D array of children of this octree.
Definition: OgreOctree.h:103
A 3D box aligned with the x/y/z axes.
NodeList mNodes
Public list of SceneNodes attached to this particular octree.
Definition: OgreOctree.h:130
void _unref()
Decrements the overall node count of this octree and all its parents.
Definition: OgreOctree.h:145
bool _isTwiceSize(const AxisAlignedBox &box) const
Determines if this octree is twice as big as the given box.
list< OctreeNode * >::type NodeList
Definition: OgreOctree.h:127
int numNodes()
Returns the number of scene nodes attached to this octree.
Definition: OgreOctree.h:78
AxisAlignedBox mBox
The bounding box of the octree.
Definition: OgreOctree.h:81
Octree * mParent
parent octree
Definition: OgreOctree.h:156
Octree datastructure for managing scene nodes.
Definition: OgreOctree.h:59
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
void _getChildIndexes(const AxisAlignedBox &, int *x, int *y, int *z) const
Returns the appropriate indexes for the child of this octree into which the box will fit...
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
WireBoundingBox * mWireBoundingBox
Definition: OgreOctree.h:88
Allows the rendering of a wireframe bounding box.
void _ref()
Increments the overall node count of this octree and all its parents.
Definition: OgreOctree.h:136
WireBoundingBox * getWireBoundingBox()
Creates the wire frame bounding box for this octant.
void _getCullBounds(AxisAlignedBox *) const
Creates the AxisAlignedBox used for culling this octree.
Octree(Octree *p)
Specialized SceneNode that is customized for working within an Octree.