Changeset 2707


Ignore:
Timestamp:
05/24/08 22:40:42 (16 years ago)
Author:
bittner
Message:

shaft culling for dynamic updates

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r2701 r2707  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: pá 23. V 15:20:40 2008 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: so 24. V 22:09:30 2008 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    6363        $(MAKE) -f $(MAKEFILE).Debug uninstall 
    6464 
    65 Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 
     65Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 
    6666                C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 
    6767                C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2703 r2707  
    2525#include "GlobalLinesRenderer.h" 
    2626#include "ObjectsParser.h" 
     27#include "SepPlanesBox3.h" 
    2728 
    2829 
     
    16581659/** Object has moved - must dynamically update all affected PVSs */ 
    16591660void 
    1660 Preprocessor::ObjectMoved(SceneGraphLeaf *object) 
     1661Preprocessor::ObjectMoved(SceneGraphLeaf *leaf) 
    16611662{ 
    16621663  // first invalidate all PVS from which this object is visible 
    16631664  ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end(); 
    1664  
    1665   AxisAlignedBox3 box = object->GetBox(); 
    1666  
    1667   ObjectContainer objects; 
    1668  
    1669   if (0)  
    1670         { 
    1671           // simplified computation taking only the objects intersecting the box 
    1672                 KdNode::NewMail(); 
    1673  
    1674                 // first mail all kDObjects which are intersected by the object 
    1675                 preprocessor->mKdTree->CollectKdObjects(box, objects); 
    1676  
    1677         }  
    1678         else  
    1679         { 
    1680                 ViewCellContainer viewCells; 
    1681                 mViewCellsManager->ComputeBoxIntersections(box, viewCells); 
    1682  
    1683                 // add object to all viewcells that intersect the bounding box 
    1684                 ObjectPvs pvs; 
    1685  
    1686                 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 
    1687  
    1688                 for (int i = 0; it != it_end; ++ it, ++ i)  
    1689                 { 
    1690                         //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
    1691                         pvs.MergeInPlace((*it)->GetPvs()); 
    1692                 } 
    1693  
    1694                 ObjectPvsIterator pit = pvs.GetIterator(); 
    1695                 while (pit.HasMoreEntries())   
    1696                 {                
    1697                         PvsData pvsData; 
    1698                         Intersectable *object = pit.Next(pvsData); 
    1699                         objects.push_back(object); 
    1700                 } 
    1701         } 
    1702  
    1703         int pvsCounter = 0; 
    1704  
    1705         // now search for pvss which contained any mailed node 
    1706         for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit)  
    1707         { 
    1708                 ObjectPvs &pvs = (*vit)->GetPvs(); 
    1709  
    1710                 for (int i=0; i < objects.size(); i++)  
    1711                 { 
    1712                         vector<PvsEntry<Intersectable *,PvsData> >::iterator v; 
     1665   
     1666  AxisAlignedBox3 box = leaf->GetBox(); 
     1667  Intersectable *inter = leaf->GetIntersectable(); 
     1668  int removedEntries = 0; 
     1669   
     1670  // now search for pvss which contained any mailed node 
     1671  for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) { 
     1672        ObjectPvs &pvs = (*vit)->GetPvs(); 
     1673        if (Overlap(box, (*vit)->GetBox())) { 
     1674          pvs.Clear(); 
     1675          removedEntries += pvs.GetSize(); 
     1676        } else { 
     1677          CSeparatingAxisTester shadowVolume; 
     1678           
     1679          //    cout<<(*vit)->GetBox()<<" "<<box<<endl; 
     1680          shadowVolume.Init((*vit)->GetBox(), box); 
     1681           
     1682          int j = 0; 
     1683          for (int i=0; i < pvs.mEntries.size(); i++) { 
     1684                Intersectable *o = pvs.mEntries[i].mObject; 
    17131685                 
    1714                         if (pvs.Find(objects[i], v)) { 
    1715                                 // clear the pvs 
    1716                                 pvs.Clear(); 
    1717                                 pvsCounter++; 
    1718                                 break; 
    1719                         } 
    1720                 } 
    1721         } 
    1722  
    1723         cout<<"Number of affected objects "<<objects.size()<<endl; 
    1724         cout<<"Cleared "<<pvsCounter<<" PVSs ("<<mViewCellsManager->GetViewCells().size()/ 
    1725                 (float)pvsCounter*100.0f<<"%) "<<endl; 
    1726  
     1686                if (!shadowVolume.TestIsInsideShaft(o->GetBox())) { 
     1687                  if (j != i) 
     1688                        pvs.mEntries[j] = pvs.mEntries[i]; 
     1689                  j++; 
     1690                } else { 
     1691                  removedEntries++; 
     1692                } 
     1693          } 
     1694          pvs.mLastSorted = 0; 
     1695          if (j==0) 
     1696                pvs.mEntries.clear(); 
     1697          else { 
     1698                pvs.mEntries.resize(j); 
     1699                pvs.SimpleSort(); 
     1700          } 
     1701        } 
     1702  } 
     1703   
     1704  cerr<<"Number of removed pvs entries = "<<removedEntries<<endl; 
     1705  //    cout<<"Cleared "<<pvsCounter<<" PVSs ("<<mViewCellsManager->GetViewCells().size()/ 
     1706  //      (float)pvsCounter*100.0f<<"%) "<<endl; 
     1707   
    17271708} 
    17281709 
     
    17451726                        cout<<"done."<<endl; 
    17461727                         
    1747                         cout<<"Updating affected PVSs..."<<endl; 
     1728                        cerr<<"Updating affected PVSs..."<<endl; 
    17481729                        preprocessor->ObjectMoved(l); 
    1749                         cout<<"done."<<endl;       
     1730                        cerr<<"done."<<endl;       
    17501731                } 
    17511732         
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r2636 r2707  
    442442} 
    443443 
     444template <typename T, typename S> 
     445void VerbosePvs<T, S>::Remove(typename vector<PvsEntry<T, S> >::iterator &it) 
     446{ 
     447 
     448  mEntries.erase(it); 
     449  -- mLastSorted; // wrong if sample was in tail!! 
     450  // $$JB decrement only if the sample found 
     451  -- mSamples; 
     452   
     453} 
    444454 
    445455template <typename T, typename S> 
  • GTP/trunk/Lib/Vis/Preprocessing/src/PvsBase.h

    r2696 r2707  
    44#include "common.h" 
    55#include "Containers.h" 
    6  
     6#include <vector> 
    77 
    88namespace GtpVisibilityPreprocessor { 
     
    145145        } 
    146146 
     147   
    147148        inline T Next() { return (*(mItCurrent ++)).mObject; } 
    148149 
    149  
    150 private: 
    151          
    152         typename vector<PvsEntry<T, S> >::const_iterator mItCurrent; 
    153         typename vector<PvsEntry<T, S> >::const_iterator mItEnd; 
     150  inline T Current(S &pdf) { 
     151        pdf = (*mItCurrent).mData; 
     152        return (*(mItCurrent)).mObject; 
     153  } 
     154 
     155  //private: 
     156         
     157  typename vector<PvsEntry<T, S> >::const_iterator mItCurrent; 
     158  typename vector<PvsEntry<T, S> >::const_iterator mItEnd; 
    154159}; 
    155160 
     
    261266        @param visibleSamples number of references to be removed 
    262267        */ 
    263         bool RemoveSample(T sample, const float pdf); 
     268  bool RemoveSample(T sample, const float pdf); 
     269 
     270  void Remove(typename vector<PvsEntry<T, S> >::iterator &it); 
    264271 
    265272        /** Compute continuous PVS difference  
     
    334341        VerbosePvsStats mStats; 
    335342 
    336 protected: 
     343  //protected: 
    337344 
    338345        /** Merge pvs 1 from begin iterator to end iterator with 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2706 r2707  
    333333                        char filename[256]; 
    334334                        //sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
    335                         sprintf_s(filename, "error-frame-%04d-%04d-%08d.png", mFrame, viewcell->GetId(), pixelCount); 
     335                        sprintf(filename, "error-frame-%04d-%04d-%08d.png", mFrame, viewcell->GetId(), pixelCount); 
    336336                        QImage im = toImage(); 
    337337                        string str = mSnapPrefix + filename; 
     
    367367 
    368368                                im = toImage(); 
    369                                 sprintf_s(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 
     369                                sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 
    370370                                str = mSnapPrefix + filename; 
    371371                                qstr = str.c_str(); 
     
    10431043                        break; 
    10441044 
    1045                 if (sscanf_s(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) { 
     1045                if (sscanf(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) { 
    10461046                        text.sprintf("%f %f %f", mViewDirection.x, mViewDirection.y, mViewDirection.z); 
    10471047                        text = QInputDialog::getText(this, 
     
    10531053                        if (!ok) 
    10541054                                break; 
    1055                         if (sscanf_s(text.toAscii(), "%f %f %f", &mViewDirection.x, 
     1055                        if (sscanf(text.toAscii(), "%f %f %f", &mViewDirection.x, 
    10561056                                &mViewDirection.y, &mViewDirection.z) == 3) { 
    10571057                                        updateGL(); 
     
    21942194#endif 
    21952195 
    2196 #if 0 
     2196#if 1 
    21972197        QGroupBox *groupBox4 = CreateTrafoPanel(hbox); 
    21982198        vh->addWidget(groupBox4, 0, 0); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r2706 r2707  
    2727#include "RayCaster.h" 
    2828#include "ViewCellsManager.h" 
     29#include "SepPlanesBox3.h" 
    2930 
    3031 
     
    169170        Debug.open("debug.log"); 
    170171 
     172         
     173        TestSepAxis(); 
     174         
    171175        Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH); 
    172176        MeshKdTree::ParseEnvironment(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro

    r2701 r2707  
    125125Intersectable.cpp TraversalTree.cpp ObjectPvs.cpp ObjectsParser.cpp \ 
    126126FilterBasedDistribution.cpp DifferenceSampling.cpp HavranRayCaster.cpp \ 
    127 HavranDynRayCaster.cpp OcclusionQuery.cpp RandomViewCellsHandler.cpp 
     127HavranDynRayCaster.cpp OcclusionQuery.cpp RandomViewCellsHandler.cpp \ 
     128SepPlanesBox3.cpp 
    128129 
    129130 
Note: See TracChangeset for help on using the changeset viewer.