Changeset 2599 for GTP/trunk/Lib


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

Havran ray caster updates

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
10 edited

Legend:

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

    r2575 r2599  
    8383void Exporter::ExportKdIntersectable(const KdIntersectable &kdObj) 
    8484{ 
    85         KdNode *node = kdObj.GetItem(); 
     85        KdNode *root = kdObj.GetItem(); 
    8686        Intersectable::NewMail(); 
    8787 
    88         // todo: traverse to leaves 
    89         if (node->IsLeaf()) 
    90         { 
    91                 // eyport leaf pvs 
    92                 KdLeaf *leaf = static_cast<KdLeaf *>(node); 
    93  
    94                 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
    95  
    96                 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 
    97                 {        
    98                         Intersectable *obj = *oit; 
    99          
    100                         if (!obj->Mailed()) 
    101                         { 
    102                                 ExportIntersectable(obj); 
    103                                 obj->Mail();                                     
    104                         }                                
    105                 } 
     88        stack<KdNode *> tStack; 
     89 
     90        tStack.push(root); 
     91 
     92        while (!tStack.empty()) { 
     93          KdNode *node = tStack.top(); 
     94          tStack.pop(); 
     95          // todo: traverse to leaves 
     96          if (node->IsLeaf()) 
     97                { 
     98                  // eyport leaf pvs 
     99                  KdLeaf *leaf = static_cast<KdLeaf *>(node); 
     100                   
     101                  ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
     102                   
     103                  for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 
     104                        {        
     105                          Intersectable *obj = *oit; 
     106                           
     107                          if (1 || !obj->Mailed()) 
     108                                { 
     109                                  ExportIntersectable(obj); 
     110                                  obj->Mail();                                   
     111                                }                        
     112                        } 
     113                } else { 
     114                  KdInterior *interior = (KdInterior *)node; 
     115                  tStack.push(interior->mBack); 
     116                  tStack.push(interior->mFront); 
     117                   
     118                } 
     119           
    106120        } 
    107121} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp

    r2592 r2599  
    9292// We give a box to which each ray is clipped to before the 
    9393// ray shooting is computed ! 
    94 void HavranRayCaster::CastRaysPacket4(Vector3 &boxmax, 
    95                                       Vector3 &boxmin, 
    96                                       Vector3 origin4[], 
    97                                       Vector3 direction4[], 
    98                                       int     result4[], 
    99                                       float   dist4[]) 
    100 { 
    101 #ifdef _USE_HAVRAN_SSE   
     94void HavranRayCaster::CastRaysPacket4(const Vector3 &boxmax, 
     95                                                                          const Vector3 &boxmin, 
     96                                                                          const Vector3 origin4[], 
     97                                                                          const Vector3 direction4[], 
     98                                                                          int     result4[], 
     99                                                                          float   dist4[]) 
     100{ 
     101#if defined(_USE_HAVRAN_SSE) 
    102102#ifdef USE_HAVRAN_RAYCASTER  
    103103  for (int i = 0; i < 4; i++) { 
    104104    result4[i] = -1; 
     105        //      raypack.SetObject(i, NULL); 
    105106    raypack.SetLoc(i, origin4[i]); 
    106107    raypack.SetDir(i, direction4[i]); 
     
    110111  // a particular ASDS, otherwise it is emulated by decomposition 
    111112  // of a packet to individual rays and traced individually. 
    112   mKtbtree->FindNearestI(raypack, boxmin, boxmax); 
     113  mKtbtree->FindNearestI(raypack, (Vector3&)boxmin, (Vector3&)boxmax); 
     114  //  mKtbtree->FindNearestI(raypack, bmin, bmax); 
    113115 
    114116  for (int i = 0; i < 4; i++) { 
     
    131133    sray.mOrigin = origin4[i]; 
    132134    sray.mDirection = direction4[i]; 
    133     mKtbtree->FindNearestI(sray, boxmin, boxmax); 
     135    mKtbtree->FindNearestI(sray, (Vector3&)boxmin, (Vector3&)boxmax); 
    134136    if (SimpleRay::IntersectionRes[0].intersectable) { 
    135137      // This is object ID - is this the triangle index ??? 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.h

    r2592 r2599  
    7575  // We give a box to which each ray is clipped to before the 
    7676  // ray shooting is computed ! 
    77   virtual void CastRaysPacket4(Vector3 &minBox, 
    78                               Vector3 &maxBox, 
    79                               Vector3 origin4[], 
    80                               Vector3 direction4[], 
    81                                int     result4[], 
    82                                float   dist4[]); 
     77  virtual void CastRaysPacket4(const Vector3 &minBox, 
     78                                                           const Vector3 &maxBox, 
     79                                                           const Vector3 origin4[], 
     80                                                           const Vector3 direction4[], 
     81                                                           int     result4[], 
     82                                                           float   dist4[]); 
    8383 
    8484#ifdef _USE_HAVRAN_SSE   
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r2575 r2599  
    152152} 
    153153   
     154 
     155 
    154156template<typename T> 
    155157std::ostream &IntersectableWrapper<T>::Describe(std::ostream &s) 
    156158{ 
    157         s << mItem; 
    158         return s; 
    159 } 
     159 s << mItem; 
     160   return s; 
     161         } 
    160162 
    161163 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r2592 r2599  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: po 14. I 15:10:11 2008 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: út 15. I 21:38:15 2008 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • 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; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2598 r2599  
    12671267 
    12681268        } 
    1269  
     1269         
    12701270        //      cerr<<"Determining PVS objects"<<endl; 
    12711271        DeterminePvsObjects(vssRays); 
    12721272        //      cerr<<"done."<<endl; 
    1273  
    1274  
     1273         
    12751274} 
    12761275 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2598 r2599  
    24832483                                                                          const bool useHitObjects) 
    24842484{ 
    2485         if (!useHitObjects)  
    2486         { 
    2487                 // store higher order object (e.g., bvh node) instead of object itself 
    2488                 VssRayContainer::const_iterator it, it_end = rays.end(); 
    2489          
    2490                 for (it = rays.begin(); it != it_end; ++ it)  
    2491                 { 
    2492                         VssRay *vssRay = *it; 
    2493  
    2494                         // set only the termination object 
    2495                         vssRay->mTerminationObject = GetIntersectable(*vssRay, true); 
     2485  if (!useHitObjects)  
     2486        { 
     2487          // store higher order object (e.g., bvh node) instead of object itself 
     2488          VssRayContainer::const_iterator it, it_end = rays.end(); 
     2489           
     2490          for (it = rays.begin(); it != it_end; ++ it)  
     2491                { 
     2492                  VssRay *vssRay = *it; 
     2493                   
     2494                  // set only the termination object 
     2495                  vssRay->mTerminationObject = GetIntersectable(*vssRay, true); 
    24962496                } 
    24972497        } 
     
    57235723{ 
    57245724        if (mUseKdPvs) 
    5725                 return ViewCellsManager::GetIntersectable(ray, isTermination); 
     5725          return ViewCellsManager::GetIntersectable(ray, isTermination); 
    57265726        else 
    5727                 return mHierarchyManager->GetIntersectable(ray, isTermination); 
     5727          return mHierarchyManager->GetIntersectable(ray, isTermination); 
    57285728} 
    57295729 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r2592 r2599  
    5353        useGlDebugger false 
    5454# 0 = INTERNAL  1 = MLRT 2 = HAVRAN 
    55         rayCastMethod 2 
     55        rayCastMethod 1 
    5656         
    5757#       type sampling 
  • GTP/trunk/Lib/Vis/Preprocessing/src/run_test2

    r2590 r2599  
    33 
    44#COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+" 
    5 COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish- -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter- -samples_per_evaluation=5000000 -samples_per_pass=500000 -total_samples=20000000 -mutation_use_pass_importance-" 
     5COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish- -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter- -samples_per_evaluation=5000000 -samples_per_pass=500000 -total_samples=20000000 -mutation_use_pass_importance- -mutation_silhouette_search_steps=3" 
    66 
    77#SCENE="../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d" 
Note: See TracChangeset for help on using the changeset viewer.