Ignore:
Timestamp:
12/16/06 14:51:13 (18 years ago)
Author:
mattausch
Message:

added kd pvs as option to view cells manager to avoid errors when updating the svn from jiri

File:
1 edited

Legend:

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

    r1900 r1902  
    2727 
    2828// $$JB HACK 
    29 #define USE_KD_PVS 1 
    30  
    3129#define KD_PVS_AREA (1e-5f) 
    3230 
     
    111109        Environment::GetSingleton()->GetBoolValue("ViewCells.exportBboxesForPvs", mExportBboxesForPvs); 
    112110        Environment::GetSingleton()->GetBoolValue("ViewCells.exportPvs", mExportPvs); 
    113          
     111 
     112        Environment::GetSingleton()->GetBoolValue("ViewCells.useKdPvs", mUseKdPvs); 
     113 
    114114        char buf[100]; 
    115115        Environment::GetSingleton()->GetStringValue("ViewCells.samplingType", buf); 
     
    260260        Debug << "export bounding boxes: " << mExportBboxesForPvs << endl; 
    261261        Debug << "export pvs for view cells: " << mExportPvs << endl; 
     262        Debug << "use kd pvs " << mUseKdPvs << endl; 
    262263        Debug << endl; 
    263264} 
     
    282283ViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 
    283284{ 
    284 #if USE_KD_PVS 
    285   float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 
    286   KdNode *node = GetPreprocessor()->mKdTree->GetNode(isTermination ? 
    287                                                                                                          ray.mTermination : ray.mOrigin, 
    288                                                                                                          area); 
    289   return  
    290         GetPreprocessor()->mKdTree-> 
    291         GetOrCreateKdIntersectable(node); 
    292 #else 
    293   return isTermination ? ray.mTerminationObject : ray.mOriginObject; 
    294 #endif 
    295 } 
     285        if (mUseKdPvs) 
     286        { 
     287                float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 
     288                KdNode *node = GetPreprocessor()->mKdTree->GetNode(isTermination ? 
     289                                                                                                                 ray.mTermination : ray.mOrigin, 
     290                                                                                                                 area); 
     291        return GetPreprocessor()->mKdTree->GetOrCreateKdIntersectable(node); 
     292        } 
     293        else 
     294        { 
     295                return isTermination ? ray.mTerminationObject : ray.mOriginObject; 
     296        } 
     297} 
     298 
    296299 
    297300void 
     
    785788                //-- export bounding boxes 
    786789                stream << "<BoundingBoxes>" << endl; 
    787 #if USE_KD_PVS  
    788                 vector<KdIntersectable *>::iterator kit, kit_end = GetPreprocessor()->mKdTree->mKdIntersectables.end(); 
    789  
    790                 int id = 0; 
    791                 for (kit = GetPreprocessor()->mKdTree->mKdIntersectables.begin(); kit != kit_end; ++ kit, ++ id) 
    792                 { 
    793                   Intersectable *obj = *kit; 
    794                   const AxisAlignedBox3 box = obj->GetBox(); 
     790 
     791                if (mUseKdPvs) 
     792                { 
     793                        vector<KdIntersectable *>::iterator kit, kit_end = GetPreprocessor()->mKdTree->mKdIntersectables.end(); 
     794 
     795                        int id = 0; 
     796                        for (kit = GetPreprocessor()->mKdTree->mKdIntersectables.begin(); kit != kit_end; ++ kit, ++ id) 
     797                        { 
     798                                Intersectable *obj = *kit; 
     799                                const AxisAlignedBox3 box = obj->GetBox(); 
    795800                   
    796                   obj->SetId(id); 
    797                    
    798                   stream << "<BoundingBox" << " id=\"" << id << "\"" 
    799                                  << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    800                                  << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
    801                 } 
    802 #else 
    803                 ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     801                                obj->SetId(id); 
     802         
     803                                stream << "<BoundingBox" << " id=\"" << id << "\"" 
     804                                           << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
     805                                           << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
     806                        } 
     807                } 
     808                else 
     809                { 
     810                        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    804811                 
    805                 for (oit = objects.begin(); oit != oit_end; ++ oit) 
    806                 { 
    807                         const AxisAlignedBox3 box = (*oit)->GetBox(); 
    808  
    809                         //////////// 
    810                         //-- the bounding boxes 
    811                         stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 
    812                                    << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    813                                    << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
    814                 } 
    815 #endif 
     812                        for (oit = objects.begin(); oit != oit_end; ++ oit) 
     813                        { 
     814                                const AxisAlignedBox3 box = (*oit)->GetBox(); 
     815 
     816                                //////////// 
     817                                //-- the bounding boxes 
     818 
     819                                stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 
     820                                           << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
     821                                           << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
     822                        } 
     823                } 
     824 
    816825                stream << "</BoundingBoxes>" << endl; 
    817826        } 
     
    26372646  pvs.Reserve(viewCell->GetFilteredPvsSize()); 
    26382647 
    2639 #if !USE_KD_PVS 
    2640   // first mark all objects from this pvs 
    2641   while (pit.HasMoreEntries()) {                 
    2642         ObjectPvsEntry entry = pit.Next(); 
    2643          
    2644         Intersectable *object = entry.mObject; 
    2645         object->Mail(); 
     2648  if (!mUseKdPvs) 
     2649  { 
     2650          // first mark all objects from this pvs 
     2651          while (pit.HasMoreEntries())   
     2652          { 
     2653                  ObjectPvsEntry entry = pit.Next(); 
     2654                  Intersectable *object = entry.mObject; 
     2655                  object->Mail(); 
     2656          } 
    26462657  } 
    2647 #endif 
    26482658   
    26492659  int pvsSize = 0; 
     
    27702780  Debug<<" nPvs size = "<<pvs.GetSize()<<endl; 
    27712781   
    2772 #if !USE_KD_PVS 
    2773   // copy the base pvs to the new pvs 
    2774   pit = basePvs.GetIterator(); 
    2775   while (pit.HasMoreEntries()) {                 
    2776         ObjectPvsEntry entry = pit.Next(); 
    2777         pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 
     2782  if (!mUseKdPvs) 
     2783  { 
     2784          // copy the base pvs to the new pvs 
     2785          pit = basePvs.GetIterator(); 
     2786          while (pit.HasMoreEntries())  
     2787          {              
     2788                  ObjectPvsEntry entry = pit.Next(); 
     2789                  pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 
     2790          } 
    27782791  } 
    2779 #endif 
    27802792   
    27812793  pvs.SimpleSort(); 
     
    51505162VspOspViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 
    51515163{ 
    5152 #if USE_KD_PVS 
    5153   return ViewCellsManager::GetIntersectable(ray, isTermination); 
    5154 #else 
    5155   return mHierarchyManager->GetIntersectable(ray, isTermination); 
    5156 #endif 
     5164        if (mUseKdPvs) 
     5165        { 
     5166                return ViewCellsManager::GetIntersectable(ray, isTermination); 
     5167        } 
     5168        else 
     5169        { 
     5170                return mHierarchyManager->GetIntersectable(ray, isTermination); 
     5171        } 
    51575172} 
    51585173 
Note: See TracChangeset for help on using the changeset viewer.