csgeom/bsptree.h
00001 /* 00002 Copyright (C) 2004 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_BSPTREE_H__ 00020 #define __CS_BSPTREE_H__ 00021 00022 #include "csextern.h" 00023 #include "csutil/array.h" 00024 #include "csutil/garray.h" 00025 #include "csutil/hash.h" 00026 #include "csutil/blockallocator.h" 00027 00028 struct iGraphics3D; 00029 class csBSPTree; 00030 00036 class CS_CSGEOM_EXPORT csBSPTree 00037 { 00038 private: 00039 static csBlockAllocator<csBSPTree> tree_nodes; 00040 static csDirtyAccessArray<int> b2f_array; 00041 00042 csBSPTree* child1; // If child1 is not 0 then child2 will 00043 csBSPTree* child2; // also be not 0. 00044 00045 csPlane3 split_plane; 00046 csArray<int> splitters; 00047 00048 int FindBestSplitter (csTriangle* triangles, csPlane3* planes, 00049 int num_triangles, csVector3* vertices, 00050 const csArray<int>& triidx); 00051 void Build (csTriangle* triangles, csPlane3* planes, 00052 int num_triangles, csVector3* vertices, 00053 const csArray<int>& triidx); 00054 void Back2Front (const csVector3& pos, csDirtyAccessArray<int>& arr, 00055 csSet<int>& used_indices); 00056 public: 00058 csBSPTree (); 00060 ~csBSPTree (); 00061 00063 void Clear (); 00064 00068 void Build (csTriangle* triangles, int num_triangles, 00069 csVector3* vertices); 00070 00076 const csDirtyAccessArray<int>& Back2Front (const csVector3& pos); 00077 }; 00078 00079 #endif // __CS_BSPTREE_H__ 00080
Generated for Crystal Space by doxygen 1.2.18