00001 /*************************************************************************** 00002 octree.h - description 00003 ------------------- 00004 begin : Mon Sep 30 2002 00005 copyright : (C) 2002 by Jon Anderson 00006 email : janders@users.sf.net 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU Lesser General Public License as * 00013 * published by the Free Software Foundation; either version 2 of the * 00014 * License, or (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef OCTREE_H 00019 #define OCTREE_H 00020 00021 #include <OgreAxisAlignedBox.h> 00022 00023 #include <list> 00024 00025 namespace Ogre 00026 { 00027 00028 class OctreeNode; 00029 00030 typedef std::list < OctreeNode * > NodeList; 00031 00032 00041 class Octree 00042 { 00043 public: 00044 Octree( Octree * p ); 00045 ~Octree(); 00046 00052 void _addNode( OctreeNode * ); 00053 00056 void _removeNode( OctreeNode * ); 00057 00060 int numNodes() 00061 { 00062 return mNumNodes; 00063 }; 00064 00069 AxisAlignedBox mBox; 00070 00073 Vector3 mHalfSize; 00074 00080 Octree * mChildren[ 2 ][ 2 ][ 2 ]; 00081 00087 bool _isTwiceSize( AxisAlignedBox &box ); 00088 00095 void _getChildIndexes( AxisAlignedBox &, int *x, int *y, int *z ); 00096 00101 void _getCullBounds( AxisAlignedBox * ); 00102 00103 00106 NodeList mNodes; 00107 00108 protected: 00109 00112 inline void _ref() 00113 { 00114 mNumNodes++; 00115 00116 if ( mParent != 0 ) mParent -> _ref(); 00117 }; 00118 00121 inline void _unref() 00122 { 00123 mNumNodes--; 00124 00125 if ( mParent != 0 ) mParent -> _unref(); 00126 }; 00127 00129 int mNumNodes; 00130 00132 Octree * mParent; 00133 00134 }; 00135 00136 } 00137 00138 #endif 00139 00140
Copyright © 2002 by The OGRE Team