Ignore:
Timestamp:
11/24/05 03:42:19 (19 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r427 r429  
    2424  environment->GetIntValue("VssPreprocessor.vssSamples", mVssSamples); 
    2525  environment->GetIntValue("VssPreprocessor.vssSamplesPerPass", mVssSamplesPerPass); 
    26         environment->GetBoolValue("VssPreprocessor.useImportanceSampling", mUseImportanceSampling); 
     26  environment->GetBoolValue("VssPreprocessor.useImportanceSampling", mUseImportanceSampling); 
     27  environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 
    2728         
    2829  mStats.open("stats.log"); 
     
    353354        VssTree *vssTree = NULL; 
    354355 
     356        RayContainer bspRays; 
     357 
    355358  while (totalSamples < mInitialSamples) { 
    356359                int passContributingSamples = 0; 
     
    422425 
    423426 
    424  
    425427        vssTree = new VssTree; 
    426428         
     429        const int bspSamples = min((int)mVssRays.size(), mBspConstructionSamples); 
     430         
     431        for (int i = 0; i < bspSamples; ++ i) 
     432                bspRays.push_back(new Ray(*mVssRays[i])); 
     433 
     434        mBspTree = new BspTree(&mUnbounded);     
     435 
     436        mBspTree->SetGenerateViewCells(true); 
     437        mBspTree->Construct(bspRays); 
     438 
     439        for (int i = bspSamples; i < (int)mVssRays.size(); ++ i) 
     440        { 
     441                CastRay(*mBspTree, *mVssRays[i]); 
     442        } 
     443 
    427444        vssTree->Construct(mVssRays, mViewSpaceBox); 
    428445 
     
    469486                } 
    470487 
     488                 
     489                for (int i = 0; i < (int)vssRays.size(); ++ i) 
     490                { 
     491                        CastRay(*mBspTree, *mVssRays[i]); 
     492                } 
    471493                 
    472494                samples+=num; 
     
    482504 
    483505        delete vssTree; 
    484          
    485   return true; 
    486 } 
    487  
     506 
     507        ObjectContainer objects; 
     508        ExportSplits(objects, bspRays, 10000); 
     509        ExportBspPvs(objects, bspRays, 10000); 
     510 
     511        CLEAR_CONTAINER(bspRays); 
     512 
     513        return true; 
     514} 
     515 
     516void VssPreprocessor::CastRay(const BspTree &tree, const VssRay & vssRay) 
     517{ 
     518        //-- cast ray to BSP tree to get intersection with view cells 
     519        Ray ray(vssRay); 
     520 
     521        mBspTree->CastRay(ray); 
     522                                 
     523        if (ray.sourceObject.mObject) 
     524                //sampleContributions +=  
     525                AddObjectSamples(ray.sourceObject.mObject, ray); 
     526                         
     527                if (!ray.intersections.empty()) // second intersection found 
     528                { 
     529                        //sampleContributions +=  
     530                                AddObjectSamples(ray.intersections[0].mObject, ray); 
     531                } 
     532} 
     533 
     534int VssPreprocessor::AddObjectSamples(Intersectable *obj, const Ray &ray) 
     535{ 
     536        int contributingSamples = 0; 
     537        int j; 
     538  
     539        // object can be seen from the view cell => add to view cell pvs 
     540        for (j=0; j < ray.bspIntersections.size(); ++ j) 
     541        {        
     542                BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 
     543                // if ray not in unbounded space 
     544                if (leaf->GetViewCell() != &mUnbounded) 
     545                        contributingSamples +=  
     546                                leaf->GetViewCell()->GetPvs().AddSample(obj); 
     547        } 
     548  
     549        // rays passing through this viewcell 
     550        if (mPass > 1) 
     551                for (j=1; j < ((int)ray.bspIntersections.size() - 1); ++ j)  
     552                { 
     553                        BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 
     554 
     555                        if (leaf->GetViewCell() != &mUnbounded) 
     556                                leaf->GetViewCell()-> 
     557                                        AddPassingRay(ray, contributingSamples ? 1 : 0); 
     558                } 
     559  
     560        return contributingSamples; 
     561} 
Note: See TracChangeset for help on using the changeset viewer.