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/VssPreprocessor.cpp

    r376 r382  
    88#include "ViewCell.h" 
    99#include "VssRay.h" 
     10#include "VssTree.h" 
    1011 
    1112VssPreprocessor::VssPreprocessor(): 
     
    4849        Intersectable *objectA, *objectB; 
    4950        Vector3 pointA, pointB; 
    50  
     51        float bsize = Magnitude(box.Size()); 
    5152        if (mKdTree->CastRay(ray)) { 
    5253                objectA = ray.intersections[0].mObject; 
     
    5758                float tmin, tmax; 
    5859                box.ComputeMinMaxT(ray, &tmin, &tmax); 
     60                if (tmax > bsize) { 
     61                        cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 
     62                        cerr<<"ray"<<ray<<endl; 
     63                } 
    5964                pointA = ray.Extrap(tmax); 
     65                 
    6066        } 
    6167         
     
    6975                float tmin, tmax; 
    7076                box.ComputeMinMaxT(ray, &tmin, &tmax); 
     77                if (tmax > bsize) { 
     78                        cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 
     79                        cerr<<"ray"<<ray<<endl; 
     80                } 
     81                 
    7182                pointB = ray.Extrap(tmax); 
    7283        } 
     
    8697 
    8798Vector3 
    88 VssPreprocessor::GetViewpoint() 
    89 { 
    90         AxisAlignedBox3 box = mKdTree->GetBox(); 
    91  
     99VssPreprocessor::GetViewpoint(AxisAlignedBox3 *viewSpaceBox) 
     100{ 
     101        AxisAlignedBox3 box; 
     102         
     103        if (viewSpaceBox) 
     104                box =*viewSpaceBox; 
     105        else 
     106                box = mKdTree->GetBox(); 
     107         
    92108        // shrink the box in the y direction 
    93         Vector3 diff(0, -box.Size().y*0.4f, 0); 
    94         box.Enlarge(diff); 
    95          
    96109        return box.GetRandomPoint(); 
    97110} 
     
    100113VssPreprocessor::GetDirection(const Vector3 &viewpoint) 
    101114{ 
    102         int i = RandomValue(0, mObjects.size()); 
     115        int i = RandomValue(0, mObjects.size()-1); 
    103116        Intersectable *object = mObjects[i]; 
    104117        Vector3 point, normal; 
     
    114127   
    115128  mSceneGraph->CollectObjects(&mObjects); 
    116          
    117  
     129        cout<<"#NUM_OBJECTS (Total numner of objects)\n"<<mObjects.size()<<endl; 
     130         
    118131  long startTime = GetTime(); 
    119132   
     
    121134  int totalSamples = 0; 
    122135 
    123  
     136        AxisAlignedBox3 *viewSpaceBox = NULL; 
     137 
     138        AxisAlignedBox3 box = mKdTree->GetBox(); 
     139        box.Enlarge(box.Size()*-Vector3(0.45, 0.45, 0.45)); 
     140 
     141        bool useViewSpaceBox = false; 
     142        if (useViewSpaceBox) 
     143                viewSpaceBox = &box; 
     144         
    124145  while (totalSamples < mTotalSamples) { 
    125146                int passContributingSamples = 0; 
     
    132153                 
    133154                for (int k=0; k < mSamplesPerPass; k++) { 
    134  
    135                         Vector3 viewpoint = GetViewpoint(); 
     155                         
     156                        Vector3 viewpoint = GetViewpoint(viewSpaceBox); 
    136157                        Vector3 direction = GetDirection(viewpoint); 
    137  
     158                         
    138159                        VssRay *vssRay = CastRay(viewpoint, direction); 
    139160                         
     
    153174     
    154175                mPass++; 
    155  
     176                 
    156177                int pvsSize = 0; 
    157178                float avgRayContrib = (passContributingSamples > 0) ?  
     
    176197         
    177198        cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    178         cout << "#totalRayStackSize=" << mVssRays.size() << endl; 
    179  
     199        cout << "#totalRayStackSize=" << mVssRays.size() << endl <<flush; 
     200 
     201        VssTree *vssTree = new VssTree; 
     202 
     203        vssTree->Construct(mVssRays, viewSpaceBox); 
     204         
    180205  return true; 
    181206} 
Note: See TracChangeset for help on using the changeset viewer.