Ignore:
Timestamp:
01/13/06 14:17:46 (18 years ago)
Author:
bittner
Message:

vss preprocessor void space identification fixed - by default it is off

File:
1 edited

Legend:

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

    r532 r534  
    1515 
    1616bool use2dSampling = false; 
    17 bool useViewspacePlane = true; 
     17bool useViewspacePlane = false; 
    1818 
    1919VssPreprocessor::VssPreprocessor(): 
     
    7878  float bsize = Magnitude(box.Size()); 
    7979 
     80 
     81  if (!mDetectEmptyViewSpace) 
     82        ray.mFlags &= ~Ray::CULL_BACKFACES; 
    8083   
    8184  if (mKdTree->CastRay(ray)) { 
     
    9295  } 
    9396 
    94   bool detectEmptyViewSpace = true; 
    9597         
    96   if (detectEmptyViewSpace) { 
     98  if (mDetectEmptyViewSpace) { 
    9799        SetupRay(ray, pointA, -direction); 
    98100  } else 
    99101        SetupRay(ray, viewPoint, -direction); 
    100          
    101          
     102   
     103  if (!mDetectEmptyViewSpace) 
     104        ray.mFlags &= ~Ray::CULL_BACKFACES; 
     105 
    102106  if (mKdTree->CastRay(ray)) { 
    103107        objectB = ray.intersections[0].mObject; 
     
    111115          return 0; 
    112116  } 
    113  
     117   
    114118  //  if (objectA == NULL && objectB != NULL) { 
    115   if (1) { 
     119  if (mDetectEmptyViewSpace) { 
    116120        // cast again to ensure that there is no objectA 
    117121        SetupRay(ray, pointB, direction); 
     
    121125        } 
    122126  } 
    123    
     127 
    124128   
    125129  VssRay *vssRay  = NULL; 
    126130 
    127131  bool validSample = (objectA != objectB); 
    128   if (0 && detectEmptyViewSpace) {   // consider all samples valid 
     132  if (0 && mDetectEmptyViewSpace) {   // consider all samples valid 
    129133        // check if the viewpoint lies on the line segment AB 
    130134        if (Distance(pointA, pointB) < 
     
    183187  Vector3 point; 
    184188  if (!use2dSampling) { 
    185         Vector3 normal; 
    186         int i = (int)RandomValue(0, (Real)((int)mObjects.size()-1)); 
    187         Intersectable *object = mObjects[i]; 
    188         object->GetRandomSurfacePoint(point, normal); 
     189        if (0) { 
     190          Vector3 normal; 
     191          int i = Random((int)mObjects.size()); 
     192          Intersectable *object = mObjects[i]; 
     193          object->GetRandomSurfacePoint(point, normal); 
     194        } else 
     195          point = mKdTree->GetBox().GetRandomPoint(); 
     196        //        point = viewpoint + UniformRandomVector(); 
     197 
    189198  } else { 
    190199        AxisAlignedBox3 box; 
     
    226235        num = vssTree->GenerateRays(p, rays); 
    227236  } else { 
    228         int leaves = vssTree->stat.Leaves()/2; 
     237        int leaves = vssTree->stat.Leaves(); 
    229238        num = vssTree->GenerateRays(desiredSamples, leaves, rays); 
    230239  } 
     
    243252{ 
    244253  cout<<"Exporting vss rays..."<<endl<<flush; 
    245  
    246   float prob = number/(float)vssRays.size(); 
    247  
    248254 
    249255  Exporter *exporter = NULL; 
     
    261267  } 
    262268 
    263   VssRayContainer rays; for (int i=0; i < vssRays.size(); i++) 
    264         if (RandomValue(0,1) < prob) 
    265           rays.push_back(vssRays[i]); 
    266  
     269  VssRayContainer rays; 
     270  vssRays.SelectRays(number, rays); 
     271   
    267272  exporter->ExportRays(rays, RgbColor(1, 0, 0)); 
    268273 
     
    411416 
    412417  AxisAlignedBox3 *box = new AxisAlignedBox3(mKdTree->GetBox()); 
    413  
     418   
    414419  if (!useViewspacePlane) { 
    415420        float size = 0.05f; 
     
    430435        box->SetMax(1, box->Min(1)); 
    431436 
     437  cout<<"mUseViewSpaceBox="<<mUseViewSpaceBox<<endl; 
    432438  if (mUseViewSpaceBox) 
    433439  { 
     
    440446        mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 
    441447  } 
    442  
     448   
    443449  //-- load view cells from file if requested 
    444450  if (mLoadViewCells) 
     
    464470  else 
    465471  { 
    466           while (totalSamples < mInitialSamples) { 
     472         
     473        while (totalSamples < mInitialSamples) { 
    467474                int passContributingSamples = 0; 
    468475                int passSampleContributions = 0; 
     
    476483                for (int k=0; k < s; k++) { 
    477484                        // changed by matt 
    478                         //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 
    479485                        Vector3 viewpoint;  
     486                        //                      viewpoint = GetViewpoint(mViewSpaceBox); 
    480487                        mViewCellsManager->GetViewPoint(viewpoint); 
    481488                        Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 
    482                  
     489 
    483490                        sampleContributions = CastRay(viewpoint, direction, mVssRays); 
    484491 
     
    514521  
    515522          cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
     523 
     524 
     525           
    516526  } 
    517527   
     
    537547  } 
    538548 
    539   //int numExportRays = 10000; 
    540   int numExportRays = 0; 
     549   
     550  int numExportRays = 5000; 
     551  //int numExportRays = 0; 
    541552 
    542553  if (numExportRays) { 
Note: See TracChangeset for help on using the changeset viewer.