Ignore:
Timestamp:
01/08/06 05:56:40 (19 years ago)
Author:
mattausch
Message:

implemented view cells exporting / loading
improved vsp bsp tree (only axis aligbed until a level), reuse results from Plane
testing, collectmergeneighbors
implemented view cell meshes

File:
1 edited

Legend:

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

    r503 r508  
    3434class VspBspTree  
    3535{ 
     36        friend class ViewCellsParseHandlers; 
     37 
    3638public: 
    3739         
     
    180182        BspNode *GetRoot() const; 
    181183 
    182         /** Exports VspBsp tree to file. 
    183         */ 
    184         bool Export(const string filename); 
    185  
    186184        /** Collects the leaf view cells of the tree 
    187185                @param viewCells returns the view cells  
     
    279277        bool ViewPointValid(const Vector3 &viewPoint) const; 
    280278 
    281         /** Returns the view cell corresponding to  
    282                 the space outside the valid view space. 
    283         */ 
    284         BspViewCell *GetOutOfBoundsCell() const; 
    285  
    286         /** Writes tree to disc. 
    287         */ 
    288         bool WriteVspBspTree(); 
    289  
    290         /** Loads tree from disc. 
    291         */ 
    292         bool LoadVspBspTree(); 
     279        /** Returns view cell corresponding to  
     280                the invalid view space. 
     281        */ 
     282        BspViewCell *GetOutOfBoundsCell(); 
     283 
     284        /** Writes tree to output stream 
     285        */ 
     286        bool Export(ofstream &stream); 
    293287 
    294288protected: 
     
    321315        }; 
    322316 
     317        /** Returns view cell corresponding to  
     318                the invalid view space. If it does not exist, it is created. 
     319        */ 
     320        BspViewCell *GetOrCreateOutOfBoundsCell(); 
     321 
    323322        /** Collapses the tree with respect to the view cell partition, 
    324323                i.e. leaves having the same view cell are collapsed. 
     
    329328        */ 
    330329        BspNode *CollapseTree(BspNode *node, int &collapsed); 
     330 
    331331        /** Shuffles the leaves, i.e., tests if exchanging 
    332332                the leaves helps in improving the view cells. 
     
    367367        bool SelectPlane(Plane3 &plane,  
    368368                                         BspLeaf *leaf,  
    369                                          VspBspTraversalData &data); 
     369                                         VspBspTraversalData &data, 
     370                                         VspBspTraversalData &frontData, 
     371                                         VspBspTraversalData &backData); 
    370372         
    371373        /** Strategies where the effect of the split plane is tested 
     
    375377        */ 
    376378        float SplitPlaneCost(const Plane3 &candidatePlane,  
    377                                                  const VspBspTraversalData &data) const; 
    378  
     379                                                 const VspBspTraversalData &data, 
     380                                                 BspNodeGeometry &geomFront, 
     381                                                 BspNodeGeometry &geomBack, 
     382                                                 float &areaFront, 
     383                                                 float &areaBack) const; 
    379384 
    380385        /** Subdivide leaf. 
     
    397402                                                   PolygonContainer &coincident); 
    398403 
    399         /** Selects the split plane in order to construct a tree with 
    400                 certain characteristics (e.g., balanced tree, least splits,  
    401                 2.5d aligned) 
    402                 @param bestPlane returns the split plane 
    403                 @param polygons container of polygons 
    404                 @param rays bundle of rays on which the split can be based 
    405  
    406                 @returns true if the overall cost is under maxCostRatio 
    407         */ 
    408         bool SelectPlaneHeuristics(Plane3 &bestPlane,  
    409                                                            BspLeaf *leaf,  
    410                                                            VspBspTraversalData &data); 
    411  
    412404        /** Extracts the meshes of the objects and adds them to polygons.  
    413405                Adds object aabb to the aabb of the tree. 
     
    441433                                                                 const VspBspTraversalData &tData, 
    442434                                                                 int &axis, 
    443                                                                  float &position, 
    444                                                                  int &raysBack, 
    445                                                                  int &raysFront, 
    446                                                                  int &pvsBack, 
    447                                                                  int &pvsFront); 
     435                                                                 BspNodeGeometry **frontGeom, 
     436                                                                 BspNodeGeometry **backGeom, 
     437                                                                 float &frontArea, 
     438                                                                 float &backArea); 
    448439 
    449440        /** Sorts split candidates for surface area heuristics for axis aligned splits. 
     
    506497         
    507498        */ 
    508         void AddObjToPvs(Intersectable *obj, const int cf, int &frontPvs, int &backPvs) const; 
     499        void AddObjToPvs(Intersectable *obj,  
     500                                         const int cf,  
     501                                         int &frontPvs,  
     502                                         int &backPvs,  
     503                                         int &totalPvs) const; 
    509504         
    510505        /** Computes PVS size induced by the rays. 
     
    591586        void PropagateUpValidity(BspNode *node); 
    592587 
    593         /** Creates or returns view cell corresponding to  
    594                 the space outside the valid view space. 
    595         */ 
    596         BspViewCell *GetOrCreateOutOfBoundsCell(); 
     588        /** Writes the node to disk 
     589                @note: should be implemented as visitor 
     590        */ 
     591        void ExportNode(BspNode *node, ofstream &stream); 
     592 
     593        /** Returns memory usage of tree. 
     594        */ 
     595        float GetMemUsage() const; 
    597596 
    598597        /// Pointer to the root of the tree 
     
    621620        /// mininum PVS 
    622621        int mTermMinPvs; 
    623  
    624         /// minimal number of rays for axis aligned split 
    625         int mTermMinRaysForAxisAligned; 
    626         /// minimal number of objects for axis aligned split 
    627         int mTermMinObjectsForAxisAligned; 
    628622        /// maximal contribution per ray 
    629623        float mTermMaxRayContribution; 
    630624        /// minimal accumulated ray length 
    631625        float mTermMinAccRayLength; 
     626 
     627        //-- termination criteria for axis aligned split 
     628 
     629        /// minimal number of rays for axis aligned split 
     630        int mTermMinRaysForAxisAligned; 
     631        // max ray contribution 
     632        float mTermMaxRayContriForAxisAligned; 
    632633 
    633634        /// strategy to get the best split plane 
     
    684685 
    685686        MergeQueue mMergeQueue; 
     687 
    686688        /// if rays should be used to collect merge candidates 
    687689        bool mUseRaysForMerge; 
     690         
    688691        /// maximal allowed pvs so that view cell is valid 
    689692        int mMaxPvs; 
     
    695698        bool mShowInvalidSpace; 
    696699 
     700        int mCurrentViewCellsId; 
     701 
     702        /// maximal tree memory 
     703        float mMaxMemory; 
     704 
     705        bool mOutOfMemory; 
    697706private: 
    698707         
Note: See TracChangeset for help on using the changeset viewer.