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 "csgfx/trianglestream.h"
00026 #include "csutil/array.h"
00027 #include "csutil/blockallocator.h"
00028 #include "csutil/dirtyaccessarray.h"
00029 #include "csutil/set.h"
00030 
00037 struct iGraphics3D;
00038 
00039 struct csTriangle;
00040 
00046 class CS_CRYSTALSPACE_EXPORT csBSPTree : public CS::Memory::CustomAllocated
00047 {
00048 private:
00049   CS_DECLARE_STATIC_CLASSVAR_REF(b2fArray, B2fArray, csDirtyAccessArray<int>)
00050 
00051   csBSPTree* child1;            // If child1 is not 0 then child2 will
00052   csBSPTree* child2;            // also be not 0.
00053 
00054   csPlane3 split_plane;
00055   csArray<int> splitters;
00056 
00057   size_t FindBestSplitter (csTriangle* triangles, csPlane3* planes,
00058         size_t num_triangles, const csVector3* vertices,
00059         const csArray<int>& triidx);
00060   void Build (csTriangle* triangles, csPlane3* planes,
00061         size_t num_triangles, const csVector3* vertices,
00062         const csArray<int>& triidx);
00063   void Back2Front (const csVector3& pos, csDirtyAccessArray<int>& arr,
00064         csSet<int>& used_indices);
00065 public:
00067   csBSPTree ();
00069   ~csBSPTree ();
00070 
00072   void Clear ();
00073 
00075 
00078   void Build (csTriangle* triangles, size_t num_triangles,
00079     const csVector3* vertices);
00080   void Build (CS::TriangleIndicesStream<int>& triangles, const csVector3* vertices);
00082 
00088   const csDirtyAccessArray<int>& Back2Front (const csVector3& pos);
00089 };
00090 
00093 #endif // __CS_CSGEOM_BSPTREE_H__
00094 

Generated for Crystal Space 2.0 by doxygen 1.7.6.1