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 #include <OgreWireBoundingBox.h> 00023 00024 #include <list> 00025 00026 namespace Ogre 00027 { 00028 00029 class OctreeNode; 00030 00031 typedef std::list < OctreeNode * > NodeList; 00032 00033 00042 class Octree 00043 { 00044 public: 00045 Octree( Octree * p ); 00046 ~Octree(); 00047 00053 void _addNode( OctreeNode * ); 00054 00057 void _removeNode( OctreeNode * ); 00058 00061 int numNodes() 00062 { 00063 return mNumNodes; 00064 }; 00065 00070 AxisAlignedBox mBox; 00071 WireBoundingBox* mWireBoundingBox; 00072 00075 WireBoundingBox* getWireBoundingBox(); 00076 00079 Vector3 mHalfSize; 00080 00086 Octree * mChildren[ 2 ][ 2 ][ 2 ]; 00087 00093 bool _isTwiceSize( AxisAlignedBox &box ); 00094 00101 void _getChildIndexes( AxisAlignedBox &, int *x, int *y, int *z ); 00102 00107 void _getCullBounds( AxisAlignedBox * ); 00108 00109 00112 NodeList mNodes; 00113 00114 protected: 00115 00118 inline void _ref() 00119 { 00120 mNumNodes++; 00121 00122 if ( mParent != 0 ) mParent -> _ref(); 00123 }; 00124 00127 inline void _unref() 00128 { 00129 mNumNodes--; 00130 00131 if ( mParent != 0 ) mParent -> _unref(); 00132 }; 00133 00135 int mNumNodes; 00136 00138 Octree * mParent; 00139 00140 }; 00141 00142 } 00143 00144 #endif 00145 00146
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:28 2004