Ignore:
Timestamp:
11/15/05 01:32:10 (19 years ago)
Author:
mattausch
Message:

worked on view space partition kd tree

File:
1 edited

Legend:

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

    r410 r411  
    99#include "RenderSimulator.h" 
    1010 
    11 SamplingPreprocessor::SamplingPreprocessor(): mPass(0), mSampleRays(NULL) 
     11SamplingPreprocessor::SamplingPreprocessor(): mPass(0) 
    1212{ 
    1313  // this should increase coherence of the samples 
     
    1515  environment->GetIntValue("Sampling.totalSamples", mTotalSamples); 
    1616  environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 
     17  environment->GetIntValue("VspTree.Construction.samples", mVspConstructionSamples); 
     18 
    1719  environment->GetIntValue("ViewCells.PostProcessing.samples", mPostProcessSamples); 
    1820  environment->GetIntValue("BspTree.Visualization.samples", mVisualizationSamples); 
     
    2527{ 
    2628        CLEAR_CONTAINER(mSampleRays); 
     29        CLEAR_CONTAINER(mVspSampleRays); 
    2730} 
    2831 
     
    198201                } 
    199202        } 
    200         else 
    201                 { 
    202                         if (ray.kdLeaves.size()) { 
    203                                 Intersectable *terminator = 
    204                                         ray.intersections.size() ? ray.intersections[0].mObject: NULL; 
    205  
    206                                 sampleContributions += AddNodeSamples(ray, 
    207                                                                                                                                                                                         object, 
    208                                                                                                                                                                                         terminator); 
    209                         } 
    210                 } 
     203        else { 
     204                if (ray.kdLeaves.size()) { 
     205                        Intersectable *terminator = 
     206                                ray.intersections.size() ? ray.intersections[0].mObject: NULL; 
     207 
     208                        sampleContributions += AddNodeSamples(ray, 
     209                                                                                                                                                                                object, 
     210                                                                                                                                                                                terminator); 
     211                } 
     212        } 
    211213         
    212214        return sampleContributions; 
     
    482484                                                //mVspKdTree->Construct(mSampleRays, mBoundingBox); 
    483485                                        } 
    484                                         /*else if (ViewCell::sHierarchy == ViewCell::VSPKD) 
     486                                        else if (ViewCell::sHierarchy == ViewCell::VSP) 
    485487                                        { 
    486                                                 ProcessVspKdViewCells(ray, 
    487                                                                                           reverseSample ? NULL : object, 
    488                                                                                           faceIndex, 
    489                                                                                           passContributingSamples, 
    490                                                                                           passSampleContributions); 
    491                                         }*/ 
     488                                                ProcessVspViewCells(ray, 
     489                                                                                        reverseSample ? NULL : object, 
     490                                                                                        faceIndex, 
     491                                                                                        passContributingSamples, 
     492                                                                                        passSampleContributions); 
     493                                        } 
    492494                                } 
    493495                        } else { 
     
    709711} 
    710712 
     713 
     714void SamplingPreprocessor::ProcessVspViewCells(const Ray &ray, 
     715                                               Intersectable *object, 
     716                                                                                           const int faceIndex, 
     717                                                                                           int &contributingSamples, 
     718                                                                                           int &sampleContributions) 
     719{ 
     720        // save rays for bsp tree construction 
     721        if (!mVspKdTree) 
     722        { 
     723                if ((int)mVspSampleRays.size() < mVspConstructionSamples) 
     724                { 
     725                        MeshInstance *mi = dynamic_cast<MeshInstance *>(object); 
     726                         
     727                        VssRay *sRay = new VssRay(ray); 
     728                        mVspSampleRays.push_back(sRay); 
     729                 
     730                        // also add origin to sample 
     731                        sRay->mOriginObject = object; 
     732                } 
     733                else 
     734                { 
     735                        // construct VSP tree using the collected samples 
     736                        cout << "building VSP tree from " << (int)mVspSampleRays.size() << " samples " << endl; 
     737                        mVspKdTree->Construct(mVspSampleRays); 
     738                 
     739                        // add contributions of saved samples to PVS 
     740                        //contributingSamples += mBspTree->GetStat().contributingSamples; 
     741                        //sampleContributions += mBspTree->GetStat().sampleContributions; 
     742 
     743                        // throw away samples because BSP leaves not stored in order  
     744                        // Need ordered rays for post processing => collect new rays 
     745                        //CLEAR_CONTAINER(mVspSampleRays); 
     746                } 
     747        } 
     748        // save rays for post processing 
     749        /*else if (((int)mVspSampleRays.size() < mPostProcessSamples) || 
     750                         ((int)mVspSampleRays.size() < mVisualizationSamples)) 
     751        { 
     752                mVspSampleRays.push_back(new Ray(ray)); 
     753        }*/ 
     754} 
     755 
    711756void SamplingPreprocessor::ProcessBspViewCells(const Ray &ray, 
    712757                                               Intersectable *object, 
Note: See TracChangeset for help on using the changeset viewer.