csgeom/bsptree.h
Go to the documentation of this file.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_CSGEOM_BSPTREE_H__ 00020 #define __CS_CSGEOM_BSPTREE_H__ 00021 00022 #include "csextern.h" 00023 00024 #include "csgeom/plane3.h" 00025 #include "csutil/array.h" 00026 #include "csutil/blockallocator.h" 00027 #include "csutil/dirtyaccessarray.h" 00028 00035 struct iGraphics3D; 00036 00037 template<class T> 00038 class csSet; 00039 struct csTriangle; 00040 00046 class CS_CRYSTALSPACE_EXPORT csBSPTree 00047 { 00048 private: 00049 static csBlockAllocator<csBSPTree> tree_nodes; 00050 static csDirtyAccessArray<int> b2f_array; 00051 00052 csBSPTree* child1; // If child1 is not 0 then child2 will 00053 csBSPTree* child2; // also be not 0. 00054 00055 csPlane3 split_plane; 00056 csArray<int> splitters; 00057 00058 size_t FindBestSplitter (csTriangle* triangles, csPlane3* planes, 00059 int num_triangles, csVector3* vertices, 00060 const csArray<int>& triidx); 00061 void Build (csTriangle* triangles, csPlane3* planes, 00062 int num_triangles, csVector3* vertices, 00063 const csArray<int>& triidx); 00064 void Back2Front (const csVector3& pos, csDirtyAccessArray<int>& arr, 00065 csSet<int>& used_indices); 00066 public: 00068 csBSPTree (); 00070 ~csBSPTree (); 00071 00073 void Clear (); 00074 00078 void Build (csTriangle* triangles, int num_triangles, 00079 csVector3* vertices); 00080 00086 const csDirtyAccessArray<int>& Back2Front (const csVector3& pos); 00087 }; 00088 00091 #endif // __CS_CSGEOM_BSPTREE_H__ 00092
Generated for Crystal Space by doxygen 1.4.6