Ignore:
Timestamp:
11/09/05 01:54:05 (19 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r391 r392  
    253253} 
    254254 
    255 void BspLeaf::GenerateViewCell(const BoundedRayContainer &rays,  
    256                                                            int &sampleContributions, 
    257                                                            int &contributingSamples) 
     255void BspLeaf::AddToPvs(const BoundedRayContainer &rays,  
     256                                           int &sampleContributions, 
     257                                           int &contributingSamples) 
    258258{ 
    259259        sampleContributions = 0; 
    260260        contributingSamples = 0; 
    261  
    262         mViewCell = dynamic_cast<BspViewCell *>(ViewCell::Generate()); 
    263         mViewCell->mBspLeaves.push_back(this); 
    264261 
    265262    BoundedRayContainer::const_iterator it, it_end = rays.end(); 
     
    273270                if (!ray->intersections.empty()) 
    274271                {        
    275             contribution += mViewCell->GetPvs().AddSample(ray->intersections[0].mObject); 
    276                 } 
    277  
    278                 contribution += mViewCell->GetPvs().AddSample(ray->sourceObject.mObject); 
     272            //contribution += mViewCell->GetPvs().AddSample(ray->intersections[0].mObject); 
     273                } 
     274 
     275                //contribution += mViewCell->GetPvs().AddSample(ray->sourceObject.mObject); 
    279276 
    280277                if (contribution > 0) 
     
    294291/****************************************************************/ 
    295292 
    296 BspTree::BspTree(ViewCell *viewCell):  
     293BspTree::BspTree(BspViewCell *viewCell):  
    297294mRootCell(viewCell), mRoot(NULL), mGenerateViewCells(false), 
    298295mStorePiercingRays(true) 
     
    707704                BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
    708705         
     706                BspViewCell *viewCell; 
     707 
    709708                // generate new view cell for each leaf 
    710709                if (mGenerateViewCells) 
    711710                { 
    712                         int conSamp, sampCon; 
    713                         leaf->GenerateViewCell(*tData.mRays, conSamp, sampCon); 
     711                        viewCell = dynamic_cast<BspViewCell *>(ViewCell::Generate()); 
     712                } 
     713                else 
     714                { 
     715                        // add view cell to leaf 
     716                        viewCell = dynamic_cast<BspViewCell *>(tData.mViewCell); 
     717                } 
     718 
     719                leaf->SetViewCell(viewCell); 
     720                viewCell->mBspLeaves.push_back(leaf); 
     721 
     722                //-- add pvs 
     723                if (viewCell != mRootCell) 
     724                { 
     725                        int conSamp = 0, sampCon = 0; 
     726                        leaf->AddToPvs(*tData.mRays, conSamp, sampCon); 
    714727                         
    715728                        mStat.contributingSamples += conSamp; 
    716729                        mStat.sampleContributions += sampCon; 
    717                 } 
    718                 else 
    719                 { 
    720                         // add view cell to leaf 
    721                         leaf->SetViewCell(dynamic_cast<BspViewCell *>(tData.mViewCell)); 
    722                         leaf->mViewCell->mBspLeaves.push_back(leaf); 
    723730                } 
    724731 
     
    13341341 
    13351342                if (1) // use front and back cell areas to approximate volume 
    1336                 { 
    1337                         //-- compute area 
    1338                  
     1343                {        
    13391344                        // construct child geometry with regard to the candidate split plane 
    13401345                        frontData.mCell = cell.ConstructChild(*this, candidatePlane, true); 
    13411346                        backData.mCell = cell.ConstructChild(*this, candidatePlane, false); 
    13421347 
    1343                         frontData.mArea = frontData.mCell->GetArea(); 
    1344                         backData.mArea = backData.mCell->GetArea(); 
    1345  
    1346                         pFront = frontData.mArea; 
    1347                         pBack = backData.mArea; 
     1348                        pFront = frontData.mArea = frontData.mCell->GetArea(); 
     1349                        pBack = backData.mArea = backData.mCell->GetArea(); 
    13481350 
    13491351                        pOverall = area; 
     
    14091411 
    14101412        if ((sSplitPlaneStrategy & PVS) && area && pvs) 
    1411                 val += sPvsFactor * (frontData.mPvs * pFront + (backData.mPvs * pBack)) /       (pOverall * (float)pvs * 2); 
    1412  
    1413         Debug << "pvs: " << pvs << " totalArea: " << area  
     1413                val += sPvsFactor * (frontData.mPvs * pFront + (backData.mPvs * pBack)) / 
     1414                           (pOverall * (float)pvs * 2); 
     1415 
     1416        Debug << "totalpvs: " << pvs << " ptotal: " << pOverall 
    14141417                  << " frontpvs: " << frontData.mPvs << " pFront: " << pFront  
    14151418                  << " backpvs: " << backData.mPvs << " pBack: " << pBack  
     
    24862489        if (!planePoly) 
    24872490        { 
    2488                 Debug << "returning 'same' geometry " << mPolys.size(); 
    24892491                //geometry is not changed at all, hence just copy polygons 
    24902492                PolygonContainer::const_iterator it, it_end = mPolys.end(); 
     2493 
    24912494                for (it = mPolys.begin(); it != it_end; ++ it) 
    24922495                        childCell->mPolys.push_back(new Polygon3((*it)->mVertices)); 
     
    25132516                                                 
    25142517                                        poly->Split(splitPlane, *frontPoly, *backPoly, splitPts); 
     2518 
    25152519                                        DEL_PTR(poly); 
    25162520 
     
    25542558        childCell->mSides.push_back(side); 
    25552559 
    2556         Debug << "returning new geometry " << mPolys.size(); 
    2557  
     2560        Debug << "returning new geometry " << mPolys.size() << " CHILD: " << childCell->mPolys.size() << endl; 
     2561 
     2562        Debug << "old area " << this->GetArea() << " new: " << childCell->GetArea() << endl; 
    25582563        return childCell; 
    25592564} 
Note: See TracChangeset for help on using the changeset viewer.