Ignore:
Timestamp:
09/08/05 01:52:52 (19 years ago)
Author:
mattausch
Message:

added viewcell stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r242 r260  
    1313class Polygon3; 
    1414class AxisAlignedBox3; 
    15  
     15class Ray; 
    1616 
    1717//namespace GtpVisibilityPreprocessor { 
     
    1919/** Container storing a soup of polygons used during BSP tree construction 
    2020*/ 
    21 typedef std::vector<Polygon3 *> PolygonContainer; 
     21typedef vector<Polygon3 *> PolygonContainer; 
     22typedef vector<Ray *> RayContainer; 
    2223 
    2324struct BspRayTraversalData  
     
    125126        void SetParent(BspInterior *parent); 
    126127 
     128        PolygonContainer *GetPolygons(); 
     129 
    127130protected: 
    128131 
    129132        /// parent of this node 
    130133        BspInterior *mParent; 
     134 
     135        PolygonContainer mPolygons; 
    131136}; 
    132137 
     
    158163        */ 
    159164        void SplitPolygons(PolygonContainer *polys, PolygonContainer *frontPolys,  
    160                                            PolygonContainer *backPolys, int &splits); 
     165                                           PolygonContainer *backPolys, int &splits, bool storePolys = false); 
    161166 
    162167        friend ostream &operator<<(ostream &s, const BspInterior &A) 
     
    180185class BspLeaf : public BspNode  
    181186{ 
     187        friend BspTree; 
     188 
    182189public: 
    183190        BspLeaf(ViewCell *viewCell = NULL); 
    184191 
    185         /** @return true since it is an interior node */ 
     192        /** @return true since it is an interior node  
     193        */ 
    186194        bool IsLeaf() const; 
     195        /** Returns pointer from view cell. 
     196        */ 
    187197        ViewCell *GetViewCell(); 
     198        /** Sets pointer to view cell. 
     199        */ 
     200        void SetViewCell(ViewCell *viewCell); 
    188201 
    189202protected: 
     203 
     204        /** Helper function used to add remaining polygons to leaf. 
     205        */ 
     206        void AddPolygons(PolygonContainer *polys); 
    190207 
    191208        /// polygonal representation of this viewcell 
     
    222239 
    223240        /// BSP tree construction type 
    224         enum {VIEWCELLS, SCENE_GEOMETRY}; 
     241        enum {VIEWCELLS, SCENE_GEOMETRY, RAYS}; 
    225242 
    226243        /** Default constructor creating an empty tree. 
     
    232249        const BspTreeStatistics &GetStatistics() const;  
    233250   
    234         /** Constructs tree using the given list of viewcells. 
    235             A pointer to the appropriate viewcell is stored within each leaf.  
     251        /** Constructs tree using the given list of view cells. 
     252            A pointer to the appropriate view cell is stored within each leaf.  
    236253                Many leafs can point to the same viewcell. 
    237254        */ 
    238255        void Construct(const ViewCellContainer &viewCells); 
    239         /** Constructs tree using the given list of objects. Each leaf is taken as viewcell. 
    240             No objects are treated as viewcells explicitly. 
     256 
     257        /** Constructs tree using the given list of objects.  
     258            Note that the objects are not taken as view cells, but the view cells are 
     259                constructed from the subdivision: Each leaf is taken as one viewcell; 
    241260 
    242261                @param objects list of objects 
    243         */ 
    244         void Construct(const ObjectContainer &objects); 
     262                @returns list of view cells. 
     263        */ 
     264        ViewCellContainer *Construct(const ObjectContainer &objects); 
     265 
     266        /** Constructs tree using the given number of rays 
     267            @param objects list of objects 
     268                @returns list of view cells. 
     269        */ 
     270        ViewCellContainer *Construct(const RayContainer &rays); 
    245271 
    246272        int CollectLeafPvs(); 
     
    255281        */ 
    256282        BspNode *GetRoot() const; 
     283 
     284        /** If the view cell polygons are stored in the nodes. 
     285        */ 
     286        bool StorePolys() const; 
    257287 
    258288protected: 
    259289         
     290        /** Initialises BSP tree. 
     291                @param maxPolygons the maximal polygon count before termination of  
     292                subdivision 
     293                @param maxDepth the maximal depth before termination of  
     294                subdivision 
     295        */ 
     296        void InitTree(int maxPolygons, int maxDepth); 
     297 
     298        /** Constructs the tree from the given list of polygons. 
     299        */ 
     300        void Construct(PolygonContainer *polys); 
     301 
    260302        /** Evaluates plane classification with respect to the plane's  
    261303                contribution for a balanced tree. 
     
    301343                @param backPolys the polygons of the back child node as a result from splitting 
    302344        */ 
    303         BspNode *SubdivideNode(BspLeaf *leaf, BspInterior *parent,  
    304                                                         PolygonContainer *polys, const int depth,  
    305                                                         ViewCell *viewCell, 
    306                                                         PolygonContainer *frontPolys, PolygonContainer *backPolys); 
     345        BspNode *SubdivideNode(BspLeaf *leaf,  
     346                                                   BspInterior *parent,  
     347                                                   PolygonContainer *polys,  
     348                                                   const int depth,  
     349                                                   PolygonContainer *frontPolys,  
     350                                                   PolygonContainer *backPolys); 
    307351 
    308352        /** Filters polygons down the tree. 
     
    321365        Plane3 SelectPlaneHeuristics(PolygonContainer *polygons, int maxTests) const; 
    322366 
    323         /** Extracts the meshes of the objects and copies them into the mesh. Also calculcates the bounding box of the tree. 
     367        /** Extracts the meshes of the objects and copies them into the mesh.  
     368                Adds object aabb to the aabb of the tree. 
    324369                @param maxPolys the maximal number of objects to be stored as polygons 
    325370        */ 
    326371        void Copy2PolygonSoup(const ObjectContainer &objects, PolygonContainer &polys, int maxObjects); 
     372        /** Extracts the meshes of the view cells and copies them into the mesh.  
     373                Adds view cell aabb to the aabb of the tree. 
     374                @param maxPolys the maximal number of objects to be stored as polygons 
     375        */ 
     376        void Copy2PolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects); 
    327377 
    328378        /** Add this mesh as polygons to polygon container. 
     
    353403        /// box around the whole view domain 
    354404        AxisAlignedBox3 mBox; 
     405 
     406                /// if view cell calculation is incremential 
     407        bool mIsIncremential; 
     408 
     409        /// if polygons should be stored in the tree 
     410        bool mStorePolys; 
    355411 
    356412public: 
Note: See TracChangeset for help on using the changeset viewer.