OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreOctreeZoneOctree.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-2013 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 OgreOctree.h - description
28 -----------------------------------------------------------------------------
29 begin : Mon Sep 30 2002
30 copyright : (C) 2002 by Jon Anderson
31 email : janders@users.sf.net
32 
33 Enhancements 2003 - 2004 (C) The OGRE Team
34 
35 Modified slightly for use with PCZSceneManager Octree Zones by Eric Cha
36 
37 -----------------------------------------------------------------------------
38 */
39 
40 #ifndef OCTREE_H
41 #define OCTREE_H
42 
43 #include <OgreAxisAlignedBox.h>
44 #include <OgreWireBoundingBox.h>
45 
46 #include <list>
47 
48 namespace Ogre
49 {
50 
51 class PCZSceneNode;
52 class PCZone;
53 
55 
56 
65 class Octree : public SceneCtlAllocatedObject
66 {
67 public:
68  Octree( PCZone * zone, Octree * p );
69  ~Octree();
70 
76  void _addNode( PCZSceneNode * );
77 
80  void _removeNode( PCZSceneNode * );
81 
84  int numNodes()
85  {
86  return mNumNodes;
87  };
88 
95 
99 
103 
109  Octree * mChildren[ 2 ][ 2 ][ 2 ];
110 
116  bool _isTwiceSize( const AxisAlignedBox &box ) const;
117 
124  void _getChildIndexes( const AxisAlignedBox &, int *x, int *y, int *z ) const;
125 
130  void _getCullBounds( AxisAlignedBox * ) const;
131 
132  /* Recurse through the Octree to find the scene nodes which intersect an aab
133  */
134  void _findNodes(const AxisAlignedBox &t,
136  PCZSceneNode *exclude,
137  bool includeVisitors,
138  bool full );
139 
140  /* Recurse through the Octree to find the scene nodes which intersect a ray
141  */
142  void _findNodes(const Ray &t,
144  PCZSceneNode *exclude,
145  bool includeVisitors,
146  bool full );
147 
148  /* Recurse through the Octree to find the scene nodes which intersect a sphere
149  */
150  void _findNodes(const Sphere &t,
152  PCZSceneNode *exclude,
153  bool includeVisitors,
154  bool full );
155 
156  /* Recurse through the Octree to find the scene nodes which intersect a PBV
157  */
158  void _findNodes(const PlaneBoundedVolume &t,
160  PCZSceneNode *exclude,
161  bool includeVisitors,
162  bool full );
163 
167 
168  /* Zone that this octree is in */
170 
171 protected:
172 
175  inline void _ref()
176  {
177  mNumNodes++;
178 
179  if ( mParent != 0 ) mParent -> _ref();
180  };
181 
184  inline void _unref()
185  {
186  mNumNodes--;
187 
188  if ( mParent != 0 ) mParent -> _unref();
189  };
190 
192  int mNumNodes;
193 
195  Octree * mParent;
196 
197 };
198 
199 }
200 
201 #endif
202 
203 
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
set< PCZSceneNode * >::type PCZSceneNodeList
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.
void _unref()
Decrements the overall node count of this octree and all its parents.
bool _isTwiceSize(const AxisAlignedBox &box) const
Determines if this octree is twice as big as the given box.
void _findNodes(const AxisAlignedBox &t, PCZSceneNodeList &list, PCZSceneNode *exclude, bool includeVisitors, bool full)
int numNodes()
Returns the number of scene nodes attached to this octree.
AxisAlignedBox mBox
The bounding box of the octree.
Definition: OgreOctree.h:81
Octree * mParent
parent octree
Definition: OgreOctree.h:156
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
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...
PCZSceneNodeList mNodes
Public list of SceneNodes attached to this particular octree.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
WireBoundingBox * mWireBoundingBox
Definition: OgreOctree.h:88
Represents a convex volume bounded by planes.
Allows the rendering of a wireframe bounding box.
void _ref()
Increments the overall node count of this octree and all its parents.
WireBoundingBox * getWireBoundingBox()
Creates the wire frame bounding box for this octant.
Portal-Connected Zone datastructure for managing scene nodes.
Definition: OgrePCZone.h:82
void _getCullBounds(AxisAlignedBox *) const
Creates the AxisAlignedBox used for culling this octree.
Octree(Octree *p)