CrystalSpace

Public API Reference

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 #include "csutil/set.h"
00029 
00036 struct iGraphics3D;
00037 
00038 struct csTriangle;
00039 
00045 class CS_CRYSTALSPACE_EXPORT csBSPTree
00046 {
00047 private:
00048   CS_DECLARE_STATIC_CLASSVAR_REF(b2fArray, B2fArray, csDirtyAccessArray<int>)
00049 
00050   csBSPTree* child1;            // If child1 is not 0 then child2 will
00051   csBSPTree* child2;            // also be not 0.
00052 
00053   csPlane3 split_plane;
00054   csArray<int> splitters;
00055 
00056   size_t FindBestSplitter (csTriangle* triangles, csPlane3* planes,
00057         int num_triangles, csVector3* vertices,
00058         const csArray<int>& triidx);
00059   void Build (csTriangle* triangles, csPlane3* planes,
00060         int num_triangles, csVector3* vertices,
00061         const csArray<int>& triidx);
00062   void Back2Front (const csVector3& pos, csDirtyAccessArray<int>& arr,
00063         csSet<int>& used_indices);
00064 public:
00066   csBSPTree ();
00068   ~csBSPTree ();
00069 
00071   void Clear ();
00072 
00076   void Build (csTriangle* triangles, int num_triangles,
00077         csVector3* vertices);
00078 
00084   const csDirtyAccessArray<int>& Back2Front (const csVector3& pos);
00085 };
00086 
00089 #endif // __CS_CSGEOM_BSPTREE_H__
00090 

Generated for Crystal Space by doxygen 1.4.7