Ignore:
Timestamp:
01/15/08 23:02:37 (17 years ago)
Author:
bittner
Message:

Havran ray caster updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp

    r2592 r2599  
    1818 
    1919namespace GtpVisibilityPreprocessor { 
     20 
     21 
    2022 
    2123#define MUTATION_USE_CDF 0 
     
    9294                 
    9395                Intersectable *newObject = vssRays[i]->mTerminationObject; 
    94  
     96                 
    9597                Intersectable *oldObject = mRays[vssRays[i]->mGeneratorId].mRay->mTerminationObject; 
    9698                // the ray generated a contribution although it hits the same object 
     
    130132                Intersectable *oldObject = oldRay->mTerminationObject; 
    131133 
     134                   
    132135                // only allow one reverse mutation per generator ray 
    133136                if (!mRays[newRay->mGeneratorId].HasReverseMutation()) { 
     
    333336  // in search for unocclude reverse ray 
    334337  box.Scale(2.0f); 
     338  //box.Scale(200.0f); 
    335339   
    336340  const int packetSize = 4; 
     
    369373                // break on first passing ray 
    370374            break; 
    371           } 
     375          }  
    372376        } 
    373377        float rr = left + (i+1)*(right-left)/(packetSize+1); 
     
    377381  } 
    378382 
     383 
    379384  float t = right; 
    380385  if (right==1.0f) 
    381386        return false; 
    382    
     387 
     388 
    383389  if (i == packetSize) 
    384390        origin = newPivot + right*line; 
     
    464470  float left = 0.0f; 
    465471  float right = radius; 
     472   
     473  AxisAlignedBox3 _box = box; 
     474  _box.Scale(1.1f); 
    466475  // cast rays to find silhouette ray 
    467476  for (int j=0; j < mSilhouetteSearchSteps; j++) { 
     
    476485        // mlrtaTraverseGroupASEye4(&box.Min().x, &box.Max().x, hit_triangles, dist); 
    477486        assert(preprocessor->mRayCaster); 
    478         preprocessor->mRayCaster->CastRaysPacket4(box.Min(), box.Max(), 
    479                                                   origs, dirs, hit_triangles, dist);        
     487        preprocessor->mRayCaster->CastRaysPacket4(_box.Min(), 
     488                                                                                          _box.Max(), 
     489                                                                                          origs, 
     490                                                                                          dirs, 
     491                                                                                          hit_triangles, 
     492                                                                                          dist);        
    480493         
    481494        for (i=0; i < packetSize; i++) { 
     
    491504        right = rr; 
    492505  } 
     506 
     507  Vector3 shift; 
    493508   
    494509  if (i == packetSize) { 
     
    497512        //cout<<"W"<<i<<endl; 
    498513        //      return (RandomValue(1.0f, 1.5f)*radius)*line; 
    499         return right*line; 
    500   } 
    501    
    502   //  cout<<i<<endl; 
    503   return shifts[i]; 
    504  
     514        shift = right*line; 
     515  } else { 
     516        //  cout<<i<<endl; 
     517        shift = shifts[i]; 
     518  } 
     519   
     520 
     521  if (0) { 
     522         
     523        static VssRayContainer rRays; 
     524        static int counter = 0; 
     525        char filename[256]; 
     526 
     527        if (counter < 50) { 
     528          sprintf(filename, "sil_rays_%03d.x3d", counter++); 
     529           
     530          VssRay tRays[10]; 
     531          rRays.push_back((VssRay *)&ray); 
     532          for (int k=0; k < packetSize; k++) 
     533                if (k!=i) { 
     534                  tRays[k] = VssRay(origin, ray.mTermination + shifts[k], NULL, NULL); 
     535                  rRays.push_back(&tRays[k]); 
     536                } 
     537           
     538          Exporter *exporter = NULL; 
     539          exporter = Exporter::GetExporter(filename); 
     540           
     541          exporter->SetFilled(); 
     542           
     543          Intersectable *occluder =  
     544                ray.mTerminationObject; 
     545 
     546          // cout<<occluder->Type()<<endl; 
     547           
     548          exporter->SetForcedMaterial(RgbColor(0,0,1)); 
     549          exporter->ExportIntersectable(occluder); 
     550 
     551          exporter->SetWireframe(); 
     552           
     553          exporter->SetForcedMaterial(RgbColor(0,1,0)); 
     554          exporter->ExportBox(occluder->GetBox()); 
     555 
     556          exporter->SetForcedMaterial(RgbColor(0,1,1)); 
     557          exporter->ExportBox(_box); 
     558 
     559          exporter->ResetForcedMaterial(); 
     560 
     561          exporter->ExportRays(rRays, RgbColor(1, 0, 0)); 
     562 
     563          rRays.clear(); 
     564          tRays[0] = VssRay(origin, ray.mTermination+shift, NULL, NULL); 
     565          rRays.push_back((VssRay *)&tRays[0]); 
     566          exporter->ExportRays(rRays, RgbColor(1, 1, 0)); 
     567 
     568          delete exporter; 
     569          rRays.clear(); 
     570        } 
     571  } 
     572 
     573  return shift; 
     574 
     575   
    505576#else 
    506577  //cerr << "warning: shiluette mutation not supported" << endl; 
     
    540611#if !MUTATION_USE_CDF 
    541612#if SORT_RAY_ENTRIES 
     613  // RAYS are sorted -> find mitation candidate from the tail of the buffer 
    542614  index = mLastIndex - 1; 
    543615  if (index < 0 || index >= mRays.size()-1) { 
     
    574646#endif 
    575647#else 
     648 
    576649  static HaltonSequence iHalton; 
    577650  iHalton.GetNext(1, rr); 
     
    596669  //  cout<<index<<" "<<rr[0]<<" "<<mRays[index].mCdf<<" "<<mRays[(index+1)%mRays.size()].mCdf<<endl; 
    597670 
     671  // WE HAVE THE INDEX HERE 
     672 
    598673  mLastIndex = index; 
    599674  //  Debug<<index<<" "<<mRays[index].GetSamplingFactor()<<endl; 
Note: See TracChangeset for help on using the changeset viewer.