00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2005 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 /*************************************************************************** 00026 octree.h - description 00027 ------------------- 00028 begin : Mon Sep 30 2002 00029 copyright : (C) 2002 by Jon Anderson 00030 email : janders@users.sf.net 00031 00032 Enhancements 2003 - 2004 (C) The OGRE Team 00033 ***************************************************************************/ 00034 00035 #ifndef OCTREE_H 00036 #define OCTREE_H 00037 00038 #include <OgreAxisAlignedBox.h> 00039 #include <OgreWireBoundingBox.h> 00040 00041 #include <list> 00042 00043 namespace Ogre 00044 { 00045 00046 class OctreeNode; 00047 00048 typedef std::list < OctreeNode * > NodeList; 00049 00050 00059 class Octree 00060 { 00061 public: 00062 Octree( Octree * p ); 00063 ~Octree(); 00064 00070 void _addNode( OctreeNode * ); 00071 00074 void _removeNode( OctreeNode * ); 00075 00078 int numNodes() 00079 { 00080 return mNumNodes; 00081 }; 00082 00087 AxisAlignedBox mBox; 00088 WireBoundingBox* mWireBoundingBox; 00089 00092 WireBoundingBox* getWireBoundingBox(); 00093 00096 Vector3 mHalfSize; 00097 00103 Octree * mChildren[ 2 ][ 2 ][ 2 ]; 00104 00110 bool _isTwiceSize( AxisAlignedBox &box ); 00111 00118 void _getChildIndexes( AxisAlignedBox &, int *x, int *y, int *z ); 00119 00124 void _getCullBounds( AxisAlignedBox * ); 00125 00126 00129 NodeList mNodes; 00130 00131 protected: 00132 00135 inline void _ref() 00136 { 00137 mNumNodes++; 00138 00139 if ( mParent != 0 ) mParent -> _ref(); 00140 }; 00141 00144 inline void _unref() 00145 { 00146 mNumNodes--; 00147 00148 if ( mParent != 0 ) mParent -> _unref(); 00149 }; 00150 00152 int mNumNodes; 00153 00155 Octree * mParent; 00156 00157 }; 00158 00159 } 00160 00161 #endif 00162 00163
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:44 2006