Ignore:
Timestamp:
11/13/05 22:38:46 (19 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.cpp

    r406 r407  
    2727        Real renderTime = 0; 
    2828 
    29         // render time for 1 object of PVS 
    30         const float objRt = mObjRenderCost;  
    31          // const overhead for crossing a view cell border 
    32         const float vcOverhead = mVcOverhead; 
    33          
    3429        // total area of view cells 
    3530        float totalArea = 0;//= mKdTree->GetBox().SurfaceArea(); 
     
    4035 
    4136        ViewCellContainer::const_iterator it, it_end = viewCells.end(); 
    42          
     37 
     38        // surface area substitute for probability 
     39        PolygonContainer cell; 
     40 
    4341        for (it = viewCells.begin(); it != it_end; ++ it) 
    4442        { 
    45                 // surface area substitute for probability 
    46                 PolygonContainer cell; 
    47                 float area = 0; 
    48  
    4943                mBspTree->ConstructGeometry(dynamic_cast<BspViewCell *>(*it), cell); 
    50  
    51                 area = Polygon3::GetArea(cell); 
     44                CLEAR_CONTAINER(cell); 
     45                float area = Polygon3::GetArea(cell); 
    5246                 
    53                 renderTime += area * RenderPvs(*(*it), objRt) + vcOverhead; 
     47                renderTime += area * (RenderPvs(*(*it), mObjRenderCost) + mVcOverhead); 
    5448                totalArea += area; 
    55                 CLEAR_CONTAINER(cell); 
    5649        } 
    5750 
     
    6457} 
    6558 
    66 Real BspTreeRenderSimulator::RenderPvs(ViewCell &viewCell, float objRenderTime) const 
     59Real BspTreeRenderSimulator::RenderPvs(ViewCell &viewCell,  
     60                                                                           float objRenderTime) const 
    6761{ 
    6862        return viewCell.GetPvs().GetSize() * objRenderTime; 
    6963} 
    7064 
    71 /***************************************************** 
    72  *     class KdLeafRenderSimulator implementation    * 
    73  *****************************************************/ 
     65/******************************************************** 
     66 *     class KdLeafRenderSimulator implementation       * 
     67 *******************************************************/ 
    7468 
    7569KdTreeRenderSimulator::KdTreeRenderSimulator(float objRenderCost,  
     
    8276Real KdTreeRenderSimulator::SimulateRendering() 
    8377{ 
     78        //mKdTree->CollectLeavesPvs(); 
     79 
     80        // total render time 
    8481        Real renderTime = 0; 
     82        // overhead for loading a view cell 
     83        float loadOverhead = 0; 
    8584 
    86         // total area of view cells 
    87         float totalArea = 0;//= mKdTree->GetBox().SurfaceArea(); 
     85        // probability that view point lies in a view cell 
     86        float pInVcTotal = 0;//mKdTree->GetBox().GetVolume(); 
    8887 
    89         return renderTime; 
     88        // total probability that a view cell border is crossed 
     89        float pCrossVcTotal = 0; 
     90 
     91        vector<KdLeaf *> leaves; 
     92        mKdTree->CollectLeaves(leaves); 
     93         
     94        AxisAlignedBox3 box; 
     95 
     96        vector<KdLeaf *>::const_iterator it, it_end = leaves.end(); 
     97         
     98        for (it = leaves.begin(); it != it_end; ++ it) 
     99        { 
     100                box = mKdTree->GetBox(*it); 
     101                         
     102                // volume substitute for view point probability 
     103                float pInVc = 0; 
     104                 
     105                if (0) 
     106                        pInVc = box.GetVolume();  
     107                else 
     108                        pInVc = box.SurfaceArea(); 
     109                 
     110                // probability that a view cell border is crossed 
     111                const float pCrossVc = box.SurfaceArea(); 
     112 
     113                renderTime += pInVc * RenderPvs(*it, mObjRenderCost); 
     114                loadOverhead += pCrossVc * mVcOverhead; 
     115 
     116                pInVcTotal += pInVc; 
     117                pCrossVcTotal += pCrossVc; 
     118        } 
     119 
     120        renderTime /= pInVcTotal; 
     121        loadOverhead /= pCrossVcTotal; 
     122 
     123        return renderTime + loadOverhead; 
    90124} 
     125 
     126Real KdTreeRenderSimulator::RenderPvs(KdLeaf *leaf,  
     127                                                                                   float objRenderTime) const 
     128{ 
     129        return leaf->mKdPvs.GetSize() * objRenderTime; 
     130} 
Note: See TracChangeset for help on using the changeset viewer.