Ignore:
Timestamp:
11/05/05 20:03:25 (19 years ago)
Author:
bittner
Message:

vsspreprocessor update

File:
1 edited

Legend:

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

    r372 r382  
    4343  // totals number of rays 
    4444  int rays; 
    45   // total number of query domains 
     45        // initial size of the pvs 
     46  int initialPvsSize; 
     47        // total number of query domains 
    4648  int queryDomains; 
    4749  // total number of ray references 
    4850  int rayRefs; 
    49   // refs in non empty leafs 
    50   int rayRefsNonZeroQuery; 
    51   // total number of query references 
    52   int queryDomainRefs; 
    53   // nodes with zero queries 
    54   int zeroQueryNodes; 
    55   // max depth nodes 
     51 
     52        // max depth nodes 
    5653  int maxDepthNodes; 
    5754  // max depth nodes 
    5855  int minCostNodes; 
     56        // max ray contribution nodes 
     57  int maxRayContribNodes; 
     58        // max depth nodes 
     59  int minSizeNodes; 
     60         
    5961  // max number of rays per node 
    6062  int maxRayRefs; 
     
    7880      splits[i] = 0; 
    7981    rays = queryDomains = 0; 
    80     rayRefs = rayRefsNonZeroQuery = queryDomainRefs = 0; 
    81     zeroQueryNodes = 0; 
     82    rayRefs = 0; 
    8283    maxDepthNodes = 0; 
    8384    minCostNodes = 0; 
    8485    maxRayRefs = 0; 
    8586    addedRayRefs = removedRayRefs = 0; 
     87                initialPvsSize = 0; 
     88                maxRayContribNodes = 0; 
     89                minSizeNodes = 0; 
    8690  } 
    8791 
     
    101105// For sorting rays 
    102106// -------------------------------------------------------------- 
    103 struct  SSortableEntry 
     107struct  SortableEntry 
    104108{ 
    105109  enum EType { 
     
    112116  void *data; 
    113117   
    114   SSortableEntry() {} 
    115   SSortableEntry(const int t, const float v, void *d):type(t), 
    116                                                                                                                                                                                                                         value(v), 
    117                                                       data(d) {} 
    118          
    119   friend bool operator<(const SSortableEntry &a, const SSortableEntry &b) { 
     118  SortableEntry() {} 
     119  SortableEntry(const int t, const float v, void *d):type(t), 
     120                                                                                                                                                                                                                 value(v), 
     121                                                                                                                                                                                                                data(d) {} 
     122         
     123  friend bool operator<(const SortableEntry &a, const SortableEntry &b) { 
    120124    return a.value < b.value; 
    121125  } 
     
    215219        void SetMaxT (const float t) { mMaxT = t; } 
    216220#endif  
     221 
     222 
     223  int ComputeRayIntersection(const float axis, 
     224                                                                                                                 const float position, 
     225                                                                                                                 float &t 
     226                                                                                                                 ) const { 
     227                 
     228                // intersect the ray with the plane 
     229    float denom = mRay->GetDir(axis); 
     230     
     231    if (fabs(denom) < 1e-20) 
     232      //if (denom == 0.0f) 
     233      return (mRay->GetOrigin(axis) > position) ? 1 : -1; 
     234     
     235    t = (position - mRay->GetOrigin(axis))/denom; 
     236 
     237    if (t < GetMinT()) 
     238      return (denom > 0) ? 1 : -1; 
     239 
     240    if (t > GetMaxT()) 
     241      return (denom > 0) ? -1 : 1; 
     242 
     243                return 0; 
     244        } 
     245 
     246 
    217247}; 
    218248 
     
    329359 
    330360   
     361         
    331362  int ComputeRayIntersection(const RayInfo &rayData, 
    332363                                                                                                                 float &t 
    333364                                                                                                                 ) { 
    334                  
    335     // intersect the ray with the plane 
    336     float denom = rayData.mRay->GetDir(axis); 
    337      
    338     if (fabs(denom) < 1e-20) 
    339       //if (denom == 0.0f) 
    340       return (rayData.mRay->GetOrigin(axis) > position) ? 1 : -1; 
    341      
    342     t = (position - rayData.mRay->GetOrigin(axis))/denom; 
    343  
    344     if (t < rayData.GetMinT()) 
    345       return (denom > 0) ? 1 : -1; 
    346  
    347     if (t > rayData.GetMaxT()) 
    348       return (denom > 0) ? -1 : 1; 
    349      
    350     return 0; 
     365                return rayData.ComputeRayIntersection(axis, position, t); 
    351366  } 
    352367 
     
    365380   
    366381  RayInfoContainer rays; 
    367  
    368    
    369   VssTreeLeaf(VssTreeInterior *p, const int n):VssTreeNode(p), rays() { 
    370     rays.reserve(n); 
     382        int mPvsSize; 
     383   
     384  VssTreeLeaf(VssTreeInterior *p, 
     385                                                        const int nRays 
     386                                                        ):VssTreeNode(p), rays(), mPvsSize(0) { 
     387    rays.reserve(nRays); 
    371388  } 
    372389   
     
    392409  } 
    393410 
     411        float GetAvgRayContribution() const { 
     412                return mPvsSize/(float)rays.size(); 
     413        } 
    394414}; 
    395415 
     
    490510  // max depth of the tree 
    491511  int termMaxDepth; 
    492   // minimal cost of the node to still get subdivided 
    493   int termMinCost; 
    494512  // minimal ratio of the volume of the cell and the query volume 
    495513  float termMinSize; 
    496514 
    497   // minimal cost imporvement to subdivide a node 
    498   float maxCostRatio; 
    499    
     515        // minimal pvs per node to still get subdivided 
     516  int termMinPvs; 
     517 
     518  // maximal cost ration to subdivide a node 
     519  float termMaxCostRatio; 
     520         
     521        // maximal contribution per ray to subdivide the node 
     522        float termMaxRayContribution; 
     523 
     524         
    500525  // randomized construction 
    501526  bool randomize; 
    502527 
    503528  // type of the splitting to use fo rthe tree construction 
    504   enum {ESplitRegular, ESplitVolume, ESplitQueries }; 
     529  enum {ESplitRegular, ESplitVolume }; 
    505530  int splitType; 
    506531         
     
    528553   
    529554  // reusable array of split candidates 
    530   vector<SSortableEntry> *splitCandidates; 
     555  vector<SortableEntry> *splitCandidates; 
    531556  ///////////////////////////// 
    532557 
     
    540565  Construct( 
    541566                                                VssRayContainer &rays, 
    542                                                 const bool onlyStaticPart 
     567                                                AxisAlignedBox3 *forcedBoundingBox = NULL 
    543568                                                ); 
    544569         
     
    565590  int 
    566591  SelectPlane(VssTreeLeaf *leaf, 
    567               const AxisAlignedBox3 &box, 
    568               float &position 
    569               ); 
     592                                                        const AxisAlignedBox3 &box, 
     593                                                        float &position, 
     594                                                        int &raysBack, 
     595                                                        int &raysFront, 
     596                                                        int &pvsBack, 
     597                                                        int &pvsFront 
     598                                                        ); 
    570599 
    571600  void 
     
    590619  } 
    591620   
     621        float 
     622        BestCostRatio( 
     623                                                                VssTreeLeaf *node, 
     624                                                                int &axis, 
     625                                                                float &position, 
     626                                                                int &raysBack, 
     627                                                                int &raysFront 
     628                                                                ); 
     629         
     630        float 
     631        EvalCostRatio( 
     632                                                                VssTreeLeaf *node, 
     633                                                                const int axis, 
     634                                                                const float position, 
     635                                                                int &raysBack, 
     636                                                                int &raysFront, 
     637                                                                int &pvsBack, 
     638                                                                int &pvsFront 
     639                                                                ); 
    592640 
    593641  AxisAlignedBox3 GetBBox(const VssTreeNode *node) { 
     
    664712  EvaluateLeafStats(const TraversalData &data); 
    665713 
     714        void 
     715        EvalLeafPvs(VssTreeLeaf *leaf); 
     716 
     717         
    666718}; 
    667719 
Note: See TracChangeset for help on using the changeset viewer.