Changeset 1715


Ignore:
Timestamp:
11/06/06 20:47:06 (18 years ago)
Author:
bittner
Message:

new visibility filter support

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

Legend:

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

    r1581 r1715  
    88#include "Polygon3.h" 
    99#include "Mesh.h" 
     10#include "Halton.h" 
    1011 
    1112namespace GtpVisibilityPreprocessor { 
     
    22592260} 
    22602261 
    2261 } 
     2262Vector3 
     2263AxisAlignedBox3::GetRandomPoint() const 
     2264{ 
     2265  Vector3 size = Size(); 
     2266 
     2267#if 0 
     2268  static HaltonSequence halton; 
     2269   
     2270  halton.GenerateNext(); 
     2271   
     2272  return mMin + size*Vector3(halton.GetNumber(1), 
     2273                                                         halton.GetNumber(2), 
     2274                                                         halton.GetNumber(3)); 
     2275 
     2276#else 
     2277  return mMin + Vector3(RandomValue(0.0f, size.x), 
     2278                                                RandomValue(0.0f, size.y), 
     2279                                                RandomValue(0.0f, size.z)); 
     2280#endif 
     2281} 
     2282 
     2283} 
     2284 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r1486 r1715  
    181181 
    182182 
    183   Vector3 GetRandomPoint() const { 
    184     Vector3 size = Size(); 
    185     return mMin + Vector3(RandomValue(0.0f, size.x), 
    186                                                   RandomValue(0.0f, size.y), 
    187                                                   RandomValue(0.0f, size.z));  
    188   } 
     183  Vector3 GetRandomPoint() const; 
    189184 
    190185 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1713 r1715  
    565565        splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr); 
    566566 
    567 #ifdef _DEBUG 
     567#ifdef GTP_DEBUG 
    568568        Debug << "old render cost: " << oldRenderCost << endl; 
    569569        Debug << "new render cost: " << newRenderCost << endl; 
     
    642642                ); 
    643643 
    644 #ifdef _DEBUG 
     644#ifdef GTP_DEBUG 
    645645        if (terminationCriteriaMet) 
    646646        { 
     
    11191119        float ratio = newCost / totalRenderCost; 
    11201120   
    1121 #ifdef _DEBUG 
     1121#ifdef GTP_DEBUG 
    11221122//      if (objectsBack.empty() ||objectsFront.empty()) 
    11231123        cout << "\n\nobjects=(" << (int)objectsBack.size() << "," << (int)objectsFront.size() << " of "  
     
    12091209        float newRenderCost = nTotalObjects * totalVol; 
    12101210 
    1211 #ifdef _DEBUG 
     1211#ifdef GTP_DEBUG 
    12121212        ofstream sumStats; 
    12131213        ofstream vollStats; 
     
    12451245                        1e25 : volLeft * (float)nObjectsLeft + volRight * (float)nObjectsRight; 
    12461246 
    1247 #ifdef _DEBUG 
     1247#ifdef GTP_DEBUG 
    12481248                if (printStats) 
    12491249                { 
     
    12841284        const float ratio = newRenderCost / oldRenderCost; 
    12851285 
    1286 #ifdef _DEBUG 
     1286#ifdef GTP_DEBUG 
    12871287        Debug << "\n§§§§ bvh eval const decrease §§§§" << endl 
    12881288                  << "back pvs: " << (int)objectsBack.size() << " front pvs: "  
  • GTP/trunk/Lib/Vis/Preprocessing/src/FromPointVisibilityTree.cpp

    r1006 r1715  
    11151115        BspInterior *interior = new BspInterior(splitPlane); 
    11161116 
    1117 #ifdef _DEBUG 
     1117#ifdef GTP_DEBUG 
    11181118        Debug << interior << endl; 
    11191119#endif 
     
    18081808        } 
    18091809     
    1810 #ifdef _DEBUG 
     1810#ifdef GTP_DEBUG 
    18111811        Debug << "plane lowest cost: " << lowestCost << endl; 
    18121812#endif 
     
    21142114                 
    21152115 
    2116 #ifdef _DEBUG 
     2116#ifdef GTP_DEBUG 
    21172117        Debug << "totalpvs: " << data.mPvs << " ptotal: " << pOverall 
    21182118                  << " frontpvs: " << pvsFront << " pFront: " << pFront 
     
    22632263        } 
    22642264 
    2265 #ifdef _DEBUG 
     2265#ifdef GTP_DEBUG 
    22662266        Debug << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 
    22672267        Debug << pFront << " " << pBack << " " << pOverall << endl; 
     
    24192419        ++ mCreatedViewCells; 
    24202420 
    2421 #ifdef _DEBUG 
     2421#ifdef GTP_DEBUG 
    24222422        Debug << "BSP stats: " 
    24232423                  << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1713 r1715  
    314314                ); 
    315315 
    316 #if _DEBUG 
     316#if GTP_DEBUG 
    317317        if (terminationCriteriaMet) 
    318318        { 
     
    13261326                cout << "."; 
    13271327 
    1328 #ifdef _DEBUG 
     1328#ifdef GTP_DEBUG 
    13291329                Debug << "candidate " << sc << " reevaluated\n"  
    13301330                          << "render cost decrease diff " <<  rcd - sc->GetRenderCostDecrease() 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r1694 r1715  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: so 28. X 21:20:40 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: st 1. XI 14:21:30 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp

    r1694 r1715  
    584584                mOspStats.maxObjectRefs = (int)leaf->mObjects.size(); 
    585585 
    586 #ifdef _DEBUG 
     586#ifdef GTP_DEBUG 
    587587        Debug << "BSP stats: " 
    588588                  << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 
     
    715715                ratio = minRenderCost / totalRenderCost; 
    716716        } 
    717 #if _DEBUG 
     717#if GTP_DEBUG 
    718718        Debug << "\n§§§§ eval local cost §§§§" << endl 
    719719                  << "old rc: " << totalRenderCost / viewSpaceVol << " new rc: " << minRenderCost / viewSpaceVol << endl 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1713 r1715  
    640640        {        
    641641          Environment::GetSingleton()->GetStringValue("ViewCells.filename", buf); 
    642           cout << "loading view cells from " << buf << endl; 
     642          cout << "loading view cells from " << buf << endl<<flush; 
    643643           
    644644         mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true, NULL); 
    645            
     645 
     646         cout << "view cells loaded." << endl<<flush; 
     647          
    646648          if (!mViewCellsManager) 
    647649          { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1707 r1715  
    9797{ 
    9898public: 
    99         Pvs(): /*mSamples(0), */mEntries() {} 
     99  Pvs(): mSamples(0), mEntries() {} 
     100   
    100101 
    101102        //virtual ~Pvs(); 
     
    199200        /// Map of PVS entries 
    200201        std::map<T, S, LtSample<T> > mEntries; 
     202 
     203  /// Number of samples used to create the PVS 
     204  int mSamples; 
    201205}; 
    202206 
     
    340344Pvs<T, S>::AddSample(T sample, const float pdf) 
    341345{ 
    342         S *data = Find(sample); 
    343    
    344         if (data)   
    345         { 
    346                 data->mSumPdf += pdf; 
    347                 return data->mSumPdf; 
    348         } 
    349         else  
    350         { 
    351                 mEntries[sample] = S(pdf); 
    352                 return pdf; 
     346  mSamples++; 
     347  S *data = Find(sample); 
     348   
     349  if (data)   
     350        { 
     351          data->mSumPdf += pdf; 
     352          return data->mSumPdf; 
     353        } 
     354  else  
     355        { 
     356          mEntries[sample] = S(pdf); 
     357          return pdf; 
    353358        } 
    354359} 
     
    358363S * Pvs<T, S>::AddSample2(T sample, const float pdf) 
    359364{ 
    360         S *data = Find(sample); 
    361    
    362         if (data)   
    363         { 
    364                 data->mSumPdf += pdf; 
    365         } 
    366         else  
    367         { 
    368                 mEntries[sample] = S(pdf); 
    369                 data = Find(sample); 
    370         } 
    371  
    372         return data; 
     365  mSamples++; 
     366  S *data = Find(sample); 
     367   
     368  if (data)   
     369        { 
     370          data->mSumPdf += pdf; 
     371        } 
     372  else  
     373        { 
     374          mEntries[sample] = S(pdf); 
     375          data = Find(sample); 
     376        } 
     377   
     378  return data; 
    373379} 
    374380 
     
    378384                                  float &contribution) 
    379385{ 
     386  mSamples++; 
    380387  S *data = Find(sample); 
    381388   
     
    415422                                                  const float pdf) 
    416423{ 
     424  mSamples--; 
     425   
    417426  std::map<T, S, LtSample<T> >:: 
    418427        iterator it = mEntries.find(sample); 
     
    436445int Pvs<T, S>::AddPvs(const Pvs<T, S> &pvs) 
    437446{ 
     447  mSamples += pvs.mSamples; 
    438448  std::map<T, S, LtSample<T> >:: 
    439449        const_iterator it, it_end = pvs.mEntries.end(); 
     
    452462int Pvs<T, S>::SubtractPvs(const Pvs<T, S> &pvs) 
    453463{ 
     464  mSamples -= pvs.mSamples; 
    454465  std::map<T, S, LtSample<T> >:: 
    455466        const_iterator it, it_end = pvs.mEntries.end(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp

    r1694 r1715  
    779779                Normalize(CrossProd(beam.mPlanes[0].mNormal, beam.mPlanes[4].mNormal)); 
    780780 
    781 #ifdef _DEBUG 
     781#ifdef GTP_DEBUG 
    782782        Debug << "view point: " << viewPoint << endl; 
    783783        Debug << "eye: " << center << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtPreprocessorThread.cpp

    r1520 r1715  
    1717{ 
    1818  if (p->mQuitOnFinish) 
    19   { 
     19        { 
    2020          connect(this, SIGNAL(finished()), qApp, SLOT(closeAllWindows(void))); 
    21   } 
     21        } 
    2222} 
    2323 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1694 r1715  
    1515 
    1616 
     17#define USE_RSS_TREE 1 
     18 
    1719namespace GtpVisibilityPreprocessor { 
    1820 
     
    6264{ 
    6365  bool result = false; 
     66   
     67  Debug<<"Generate rays...\n"<<flush; 
    6468 
    6569  switch (sampleType) { 
     
    7781 
    7882  //  rays.NormalizePdf(); 
    79    
     83  Debug<<"done.\n"<<flush; 
     84 
    8085  return result; 
    8186} 
     87 
    8288 
    8389 
     
    372378  for (i=0 ; i < 3; i++) 
    373379        ratios[i]/=sumRatios; 
    374 #define MIN_RATIO 0.03f 
    375   for (i=0 ; i < 3; i++) 
     380 
     381#define MIN_RATIO 0.1f 
     382 
     383#if USE_RSS_TREE 
     384  i = 0; 
     385#else 
     386  i = 1; 
     387#endif 
     388   
     389  for (; i < 3; i++) 
    376390        if (ratios[i] < MIN_RATIO) 
    377391          ratios[i] = MIN_RATIO; 
     
    525539 
    526540  if (mUseImportanceSampling) { 
    527          
     541 
     542#if USE_RSS_TREE         
    528543        mRssTree->Construct(mObjects, mVssRays); 
     544#endif 
    529545         
    530546        mRssTree->stat.Print(mStats); 
     
    545561   
    546562   
     563 
    547564  while (1) { 
     565 
    548566        static SimpleRayContainer rays; 
    549567        static VssRayContainer vssRays; 
    550568        static VssRayContainer tmpVssRays; 
     569 
     570        rays.reserve((int)(1.1f*mRssSamplesPerPass)); 
     571 
    551572        rays.clear(); 
    552573        vssRays.clear(); 
    553574        tmpVssRays.clear(); 
     575 
    554576        int castRays = 0; 
    555577        if (mUseImportanceSampling) { 
    556578 
     579#if USE_RSS_TREE         
    557580          static float ratios[] = {0.9f,0.05f,0.05f}; 
     581#else 
     582          static float ratios[] = {0.0f,0.05f,0.05f}; 
     583#endif 
     584          NormalizeRatios(ratios); 
     585                   
     586          cout<<"New ratios: "<<ratios[0]<<" "<<ratios[1]<<" "<<ratios[2]<<endl; 
     587 
    558588          //float ratios[] = {1.0f,0.0f,0.0f}; 
    559589           
     
    566596          t1 = GetTime(); 
    567597           
    568           GenerateRays(int(mRssSamplesPerPass*ratios[0]), SamplingStrategy::RSS_BASED_DISTRIBUTION, rays); 
    569  
     598          GenerateRays(int(mRssSamplesPerPass*ratios[0]), 
     599                                   SamplingStrategy::RSS_BASED_DISTRIBUTION, 
     600                                   rays); 
     601           
    570602          rays.NormalizePdf((float)rays.size()); 
    571603           
     
    632664#define TIME_WEIGHT 0.5f 
    633665 
     666#if 1 
    634667          ratios[0] = sqr(contributions[0]/(TIME_WEIGHT*times[0] + (1 - TIME_WEIGHT)*nrays[0])); 
    635668          ratios[1] = sqr(contributions[1]/(TIME_WEIGHT*times[1] + (1 - TIME_WEIGHT)*nrays[1])); 
    636669          ratios[2] = sqr(contributions[2]/(TIME_WEIGHT*times[2] + (1 - TIME_WEIGHT)*nrays[2])); 
    637  
    638                                           NormalizeRatios(ratios); 
    639  
    640           cout<<"New ratios: "<<ratios[0]<<" "<<ratios[1]<<" "<<ratios[2]<<endl; 
     670#else 
     671          ratios[0] = contributions[0]/(TIME_WEIGHT*times[0] + (1 - TIME_WEIGHT)*nrays[0]); 
     672          ratios[1] = contributions[1]/(TIME_WEIGHT*times[1] + (1 - TIME_WEIGHT)*nrays[1]); 
     673          ratios[2] = contributions[2]/(TIME_WEIGHT*times[2] + (1 - TIME_WEIGHT)*nrays[2]); 
     674#endif     
     675 
     676#if !USE_RSS_TREE 
     677          ratios[0] = 0; 
     678#endif 
    641679           
    642680          // add contributions of all rays at once... 
     
    658696          cout<<"done."<<endl; 
    659697 
    660           cout<<"Casting rays..."<<endl; 
    661           CastRays(rays, vssRays, true); 
     698          cout<<"Casting rays..."<<endl;          CastRays(rays, vssRays, true); 
    662699          cout<<"done."<<endl; 
    663700          castRays += (int)rays.size(); 
     
    691728 
    692729        if (mUseViewcells) { 
     730          Debug<<"Print statistics...\n"<<flush; 
    693731          vssRays.PrintStatistics(mStats); 
    694732          mViewCellsManager->PrintPvsStatistics(mStats); 
     733          Debug<<"done.\n"<<flush; 
    695734        } 
    696735 
     
    744783        // already when adding into the tree 
    745784        // do not add those rays which have too low or no contribution.... 
    746          
     785 
     786#if USE_RSS_TREE         
    747787        if (mUseImportanceSampling) { 
     788          Debug<<"Adding rays...\n"<<flush; 
    748789          mRssTree->AddRays(vssRays); 
    749            
     790          Debug<<"done.\n"<<flush; 
    750791          if (mUpdateSubdivision) { 
    751792                int updatePasses = 1; 
    752793                if (mPass % updatePasses == 0) { 
     794                  Debug<<"Updating rss tree...\n"<<flush; 
    753795                  int subdivided = mRssTree->UpdateSubdivision(); 
     796                  Debug<<"done.\n"<<flush; 
    754797                  cout<<"subdivided leafs = "<<subdivided<<endl; 
    755798                  cout<<"#total leaves = "<<mRssTree->stat.Leaves()<<endl; 
     
    757800          } 
    758801        } 
     802#endif 
    759803         
    760804        if (mExportPvs) { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp

    r1632 r1715  
    18881888                rays.push_back(SimpleRay(origin, direction)); 
    18891889          } 
    1890                          
    18911890        } else { 
    18921891          RssTreeInterior *in = (RssTreeInterior *)node; 
     
    21682167} 
    21692168 
     2169 
     2170void 
     2171RssTree::GenerateLeafRaysSimple(RssTreeLeaf *leaf, 
     2172                                                                const int numberOfRays, 
     2173                                                                SimpleRayContainer &rays) 
     2174{ 
     2175   
     2176  if (numberOfRays == 0) 
     2177        return; 
     2178   
     2179  int startIndex = (int)rays.size(); 
     2180 
     2181  Debug<<"B"<<flush; 
     2182 
     2183  AxisAlignedBox3 box = GetBBox(leaf); 
     2184  AxisAlignedBox3 dirBox = GetDirBBox(leaf); 
     2185 
     2186  float boxSize = Magnitude(box.Diagonal()); 
     2187   
     2188  const float smoothRange = 0.1f; 
     2189  if (smoothRange != 0.0f) { 
     2190        box.Scale(1.0f + smoothRange); 
     2191        dirBox.Scale(1.0f + smoothRange); 
     2192  } 
     2193 
     2194  Debug<<"R"<<flush; 
     2195   
     2196  for (int i=0; i < numberOfRays; i++) { 
     2197        //      Debug<<i<<flush; 
     2198 
     2199        Vector3 origin, direction; 
     2200        Vector3 dirVector; 
     2201         
     2202        Vector3 pVector; 
     2203        Vector3 dVector; 
     2204         
     2205        bool useHalton = false; 
     2206         
     2207         
     2208        if (useHalton) { 
     2209          // generate a random 5D vector 
     2210          pVector = Vector3(leaf->halton.GetNumber(1), 
     2211                                                leaf->halton.GetNumber(2), 
     2212                                                leaf->halton.GetNumber(3)); 
     2213           
     2214          dVector = Vector3(leaf->halton.GetNumber(4), 
     2215                                                leaf->halton.GetNumber(5), 
     2216                                                0.0f); 
     2217           
     2218          leaf->halton.GenerateNext(); 
     2219        } else { 
     2220          pVector = Vector3(RandomValue(0.0f, 1.0f), 
     2221                                                RandomValue(0.0f, 1.0f), 
     2222                                                RandomValue(0.0f, 1.0f)); 
     2223           
     2224          dVector = Vector3(RandomValue(0.0f, 1.0f), 
     2225                                                RandomValue(0.0f, 1.0f), 
     2226                                                0.0f); 
     2227        } 
     2228         
     2229        origin = box.GetPoint(pVector); 
     2230        dirVector = dirBox.GetPoint(dVector); 
     2231 
     2232        direction = Vector3(sin(dirVector.x), sin(dirVector.y), cos(dirVector.x)); 
     2233 
     2234         
     2235         
     2236        // shift the origin a little bit 
     2237        direction.Normalize(); 
     2238         
     2239        //      float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); 
     2240        float dist = 0.0f; 
     2241        float minT, maxT; 
     2242 
     2243        // compute interection of the ray with the box 
     2244#if 1 
     2245        if (box.ComputeMinMaxT(origin, direction, &minT, &maxT) && minT < maxT) 
     2246          dist = maxT; 
     2247#else 
     2248        dist = 0.5f*boxSize; 
     2249#endif 
     2250 
     2251        origin += direction*dist; 
     2252         
     2253#if 0 
     2254        static int counter = 0; 
     2255        Debug<<counter++<<flush; 
     2256 
     2257        if (counter > 10374968) { 
     2258          Debug<<"size="<<rays.size()<<endl; 
     2259          Debug<<"capacity="<<rays.capacity()<<endl; 
     2260          Debug<<"o="<<origin<<endl; 
     2261          Debug<<"d="<<direction<<endl; 
     2262        } 
     2263#endif   
     2264        //Debug<<"dir vector.x="<<dirVector.x<<"direction'.x="<<atan2(direction.x, direction.y)<<endl; 
     2265        rays.push_back(SimpleRay(origin, direction)); 
     2266        //      Debug<<endl; 
     2267         
     2268  } 
     2269 
     2270  Debug<<"D"<<flush; 
     2271   
     2272  float density = 1.0f; 
     2273  float p = 1.0f/density; //(box.GetVolume()*dirBox.GetVolume())/i; 
     2274  for (i=startIndex; i < rays.size(); i++) { 
     2275        rays[i].mPdf = p; 
     2276  } 
     2277} 
     2278 
    21702279void 
    21712280RssTree::GenerateLeafRays(RssTreeLeaf *leaf, 
     
    21902299        dirBox.Scale(1.0f + smoothRange); 
    21912300  } 
    2192    
    21932301   
    21942302  Exporter *exporter = NULL; 
     
    23772485        if (leaf->rays[i].mRay->mWeightedPvsContribution > contributionThreshold) { 
    23782486          // copy a valid sample 
    2379           if (i!=j)  
    2380                 leaf->rays[j] = leaf->rays[i]; 
     2487          leaf->rays[j] = leaf->rays[i]; 
    23812488          j++; 
    23822489        } else { 
     
    25522659 
    25532660  vector<RssTreeLeaf *> leaves; 
    2554          
     2661 
     2662  Debug<<"Collecting leaves..."<<endl<<flush; 
    25552663  CollectLeaves(leaves); 
    2556          
    2557   if (numberOfLeaves != leaves.size()) 
     2664  Debug<<"done."<<endl<<flush; 
     2665   
     2666   
     2667  if (numberOfLeaves != leaves.size()) { 
     2668        Debug<<"sorting leaves..."<<endl<<flush; 
    25582669        sort(leaves.begin(), 
    25592670                 leaves.end(), 
    25602671                 GreaterContribution); 
     2672        Debug<<"done."<<endl<<flush; 
     2673  } 
    25612674                          
     2675   
     2676  Debug<<"Evaluating leaf importance..."<<endl<<flush; 
    25622677 
    25632678  float sumContrib = 0.0; 
     
    25712686          k++; 
    25722687        } 
    2573                                  
     2688 
     2689  Debug<<"done."<<endl<<flush; 
     2690   
    25742691  float avgContrib = sumContrib/numberOfLeaves; 
    25752692   
     
    25822699 
    25832700  k = 0; 
     2701 
     2702  Debug<<"generating leaf rays..."<<endl<<flush; 
     2703 
    25842704  for (i=0; i < leaves.size() && k < numberOfLeaves; i++) 
    25852705        if (ValidLeaf(leaves[i])) { 
    2586           k++; 
    25872706          RssTreeLeaf *leaf = leaves[i]; 
    25882707          float c = leaf->GetImportance(); 
    2589  
     2708           
    25902709          int num = fixedPerLeaf + (int)(c*ratioPerLeaf + 0.5f); 
    2591           GenerateLeafRays(leaf, num, rays); 
    2592         } 
     2710          GenerateLeafRaysSimple(leaf, num, rays); 
     2711 
     2712          k++; 
     2713        } 
     2714 
     2715  Debug<<"done."<<endl<<flush; 
    25932716 
    25942717  return (int)rays.size(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.h

    r1581 r1715  
    10061006                                   SimpleRayContainer &rays); 
    10071007 
     1008  void 
     1009  GenerateLeafRaysSimple(RssTreeLeaf *leaf, 
     1010                                                 const int numberOfRays, 
     1011                                                 SimpleRayContainer &rays); 
     1012         
    10081013 
    10091014  void 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp

    r1579 r1715  
    124124 
    125125  // if not already loaded, construct view cells from file 
    126   if (!mLoadViewCells) 
    127   { 
    128           ConstructViewCells(); 
     126  if (!mLoadViewCells) { 
     127        ConstructViewCells(); 
    129128  } 
    130129     
     
    181180  } 
    182181   
    183   //  HoleSamplingPass(); 
    184         if (0) { 
    185           Exporter *exporter = Exporter::GetExporter("ray-density.x3d");  
    186           exporter->SetExportRayDensity(true); 
    187           exporter->ExportKdTree(*mKdTree); 
    188           delete exporter; 
    189         } 
    190          
    191          
    192         // $$JB temporary removed 
    193         //      mViewCellsManager->PostProcess(objects, mSampleRays); 
    194          
    195         //-- several visualizations and statistics 
    196         Debug << "view cells after post processing: " << endl; 
    197         mViewCellsManager->PrintStatistics(Debug); 
    198          
    199         //-- render simulation after merge 
    200         cout << "\nevaluating bsp view cells render time after merge ... "; 
    201          
    202         mRenderSimulator->RenderScene(); 
    203         SimulationStatistics ss; 
    204         mRenderSimulator->GetStatistics(ss); 
    205          
    206         cout << " finished" << endl; 
    207         cout << ss << endl; 
    208         Debug << ss << endl; 
    209          
    210         // $$JB temporary removed 
     182  if (0) { 
     183        Exporter *exporter = Exporter::GetExporter("ray-density.x3d");  
     184        exporter->SetExportRayDensity(true); 
     185        exporter->ExportKdTree(*mKdTree); 
     186        delete exporter; 
     187  } 
     188   
     189   
     190  // $$JB temporary removed 
     191  //    mViewCellsManager->PostProcess(objects, mSampleRays); 
     192   
     193  //-- several visualizations and statistics 
     194  Debug << "view cells after post processing: " << endl; 
     195  mViewCellsManager->PrintStatistics(Debug); 
     196   
     197  //-- render simulation after merge 
     198  cout << "\nevaluating bsp view cells render time after merge ... "; 
     199   
     200  mRenderSimulator->RenderScene(); 
     201  SimulationStatistics ss; 
     202  mRenderSimulator->GetStatistics(ss); 
     203   
     204  cout << " finished" << endl; 
     205  cout << ss << endl; 
     206  Debug << ss << endl; 
     207   
     208  // $$JB temporary removed 
    211209        //mViewCellsManager->Visualize(objects, mSampleRays);    
    212          
    213         return true; 
    214 } 
    215  
    216  
    217 } 
     210   
     211  return true; 
     212} 
     213 
     214 
     215} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.cpp

    r1586 r1715  
    9898   
    9999        const Vector3 pt = ray.GetLoc() + t * dir;  
    100 #if _DEBUG 
     100#if GTP_DEBUG 
    101101        if (!pt.CheckValidity()) 
    102102        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.cpp

    r1420 r1715  
    126126  ViewV = V; // upwards 
    127127  ViewN = -N; // forwards 
    128 #ifdef _DEBUG 
     128#ifdef GTP_DEBUG 
    129129  const float eps = 1e-3f; 
    130130  if (fabs(Magnitude(ViewU) - 1.0) > eps) { 
     
    137137    Debug << "ViewU magnitude error= " << Magnitude(ViewN) << "\n"; 
    138138  } 
    139 #endif // _DEBUG 
     139#endif // GTP_DEBUG 
    140140 
    141141  return; 
     
    154154               const Vector3 &dirIncoming) 
    155155{ 
    156 #ifdef _DEBUG 
     156#ifdef GTP_DEBUG 
    157157  float d = Magnitude(normal);  
    158158  if ( (d < 0.99) || 
     
    184184 
    185185  U = CrossProd(normal, V); 
    186 #ifdef _DEBUG 
     186#ifdef GTP_DEBUG 
    187187  d = SqrMagnitude(U); 
    188188  if ( (d < 0.99) || 
     
    194194} 
    195195 
     196#define USE_HALTON 0 
     197 
    196198Vector3 
    197199UniformRandomVector() 
     
    200202  //  float r2 = RandomValue(0.0f, 1.0f); 
    201203  float r1, r2; 
    202          
     204 
     205#if USE_HALTON  
    203206  halton2.GetNext(r1, r2); 
    204          
    205          
    206   float cosTheta = 1.0f - 2*r1; 
     207#else 
     208   r1 = RandomValue(0.0f, 1.0f); 
     209   r2 = RandomValue(0.0f, 1.0f); 
     210#endif 
     211    
     212   float cosTheta = 1.0f - 2*r1; 
    207213  float sinTheta = sqrt(1 - sqr(cosTheta)); 
    208214  float fi = 2.0f*M_PI*r2; 
     
    222228  float r1, r2; 
    223229   
     230#if USE_HALTON  
    224231  halton2.GetNext(r1, r2); 
     232#else 
     233   r1 = RandomValue(0.0f, 1.0f); 
     234   r2 = RandomValue(0.0f, 1.0f); 
     235#endif 
    225236   
    226237   
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1707 r1715  
    355355                                                DEL_PTR(back_piece); 
    356356                                 
    357 #ifdef _DEBUG 
     357#ifdef GTP_DEBUG 
    358358                                        Debug << "split " << *poly << endl << *front_piece << endl << *back_piece << endl; 
    359359#endif 
     
    11771177        BspInterior *interior = new BspInterior(SelectPlane(leaf, tData));  
    11781178         
    1179 #ifdef _DEBUG 
     1179#ifdef GTP_DEBUG 
    11801180        Debug << interior << endl; 
    11811181#endif 
     
    13411341        const float ratio = newCost / oldCost; 
    13421342 
    1343 #ifdef _DEBUG 
     1343#ifdef GTP_DEBUG 
    13441344  Debug << "====================" << endl; 
    13451345  Debug << "costRatio=" << ratio << " pos=" << position<<" t=" << (position - minBox)/(maxBox - minBox) 
     
    15771577        } 
    15781578 
    1579 #ifdef _DEBUG 
     1579#ifdef GTP_DEBUG 
    15801580        Debug << "plane lowest cost: " << lowestCost << endl; 
    15811581#endif 
     
    18621862 
    18631863         
    1864 #ifdef _DEBUG 
     1864#ifdef GTP_DEBUG 
    18651865        Debug << "totalpvs: " << pvs << " ptotal: " << pOverall 
    18661866                  << " frontpvs: " << frontPvs << " pFront: " << pFront  
     
    20182018                ++ mStat.minProbabilityNodes; 
    20192019 
    2020 #ifdef _DEBUG 
     2020#ifdef GTP_DEBUG 
    20212021        Debug << "BSP stats: " 
    20222022                  << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1713 r1715  
    2626 
    2727 
     28#define ABS_CONTRIBUTION_WEIGHT 1.0f 
     29 
    2830// warning: Should not count origin object for sampling because it disturbs heuristics 
    29 #define SAMPLE_ORIGIN_OBJECTS 1  // matt temp 
     31#define SAMPLE_ORIGIN_OBJECTS 0  // matt temp 
    3032 
    3133// $$JB HACK 
     
    666668        bool success = parser.ParseViewCellsFile(filename, &vm, objects, bconverter); 
    667669 
     670        cout<<"viewcells parsed "<<endl<<flush; 
     671         
    668672        if (success) 
    669673        { 
     
    20282032        } 
    20292033 
    2030         return ray.mRelativePvsContribution; 
     2034        return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 
     2035          (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 
    20312036} 
    20322037 
     
    24152420        float viewSpaceFilterSize = Magnitude(mViewSpaceBox.Size())*relViewSpaceFilterSize; 
    24162421        float spatialFilterSize = Magnitude(kdTree->GetBox().Size())*relSpatialFilterSize; 
    2417  
     2422         
    24182423        int i; 
    24192424        for (i=0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 
    2420                 ApplyFilter(*it, 
    2421                         kdTree, 
    2422                         viewSpaceFilterSize, 
    2423                         spatialFilterSize, 
    2424                         newPvs[i] 
    2425                         ); 
    2426         } 
    2427  
     2425          ApplyFilter(*it, 
     2426                                  kdTree, 
     2427                                  viewSpaceFilterSize, 
     2428                                  spatialFilterSize, 
     2429                                  newPvs[i] 
     2430                                  ); 
     2431        } 
     2432         
    24282433        // now replace all pvss 
    24292434        for (i = 0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 
    2430  
    2431                 ObjectPvs &pvs = (*it)->GetPvs(); 
    2432                 pvs.Clear(); 
    2433                 pvs = newPvs[i]; 
    2434                 newPvs[i].Clear(); 
     2435           
     2436          ObjectPvs &pvs = (*it)->GetPvs(); 
     2437          pvs.Clear(); 
     2438          pvs = newPvs[i]; 
     2439          newPvs[i].Clear(); 
    24352440        } 
    24362441 
     
    24892494} 
    24902495 
     2496 
     2497void 
     2498ViewCellsManager::ApplyFilter2(ViewCell *viewCell, 
     2499                                                           KdTree *kdTree, 
     2500                                                           const float filterSize, 
     2501                                                           ObjectPvs &pvs 
     2502                                                           ) 
     2503{ 
     2504  // first determine the average 
     2505 
     2506 
     2507 
     2508} 
     2509   
    24912510 
    24922511void ViewCellsManager::ExportColor(Exporter *exporter,  
     
    56225641        } 
    56235642 
    5624         return ray.mRelativePvsContribution; 
     5643         
     5644 
     5645        return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 
     5646          (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 
    56255647} 
    56265648 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1709 r1715  
    461461                                         const float spatialFilterSize); 
    462462 
     463  // new adaptive version of the filter 
     464  void 
     465  ApplyFilter2(ViewCell *viewCell, 
     466                           KdTree *kdTree, 
     467                           const float filterSize, 
     468                           ObjectPvs &pvs 
     469                           ); 
     470 
    463471        void ApplySpatialFilter(KdTree *kdTree, 
    464472                                                        const float spatialFilterSize, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r1705 r1715  
    417417        if (element == "ViewCells") 
    418418        { 
    419                 Debug << "\nparsing view cells" << endl; 
     419          Debug << "\nparsing view cells" << endl; 
    420420                 
    421421                mCurrentState = PARSE_VIEWCELLS; 
     
    13651365      return false; 
    13661366    } 
    1367    
     1367 
     1368  cout<<"parsing started"<<endl<<flush; 
     1369 
    13681370  // 
    13691371  //  Create a SAX parser object. Then, according to what we were told on 
     
    14391441    } 
    14401442  } 
    1441    
     1443 
     1444  cout<<"parsed - will delete the parser"<<endl<<flush; 
    14421445  // 
    14431446  //  Delete the parser itself.  Must be done prior to calling Terminate, below. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp

    r1707 r1715  
    126126                const Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir()); 
    127127 
    128 #if _DEBUG 
     128#if GTP_DEBUG 
    129129                bool isnan = false; 
    130130                if (!a.CheckValidity()) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1707 r1715  
    11971197        BspInterior *interior = new BspInterior(splitPlane); 
    11981198 
    1199 #ifdef _DEBUG 
     1199#ifdef GTP_DEBUG 
    12001200        Debug << interior << endl; 
    12011201#endif 
     
    18451845        } 
    18461846     
    1847 #ifdef _DEBUG 
     1847#ifdef GTP_DEBUG 
    18481848        Debug << "plane lowest cost: " << lowestCost << endl; 
    18491849#endif 
     
    21562156                 
    21572157 
    2158 #ifdef _DEBUG 
     2158#ifdef GTP_DEBUG 
    21592159        Debug << "totalpvs: " << data.mPvs << " ptotal: " << pOverall 
    21602160                  << " frontpvs: " << pvsFront << " pFront: " << pFront 
     
    23052305        } 
    23062306 
    2307 #ifdef _DEBUG 
     2307#ifdef GTP_DEBUG 
    23082308        Debug << "axis: " << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 
    23092309        Debug << "p: " << pFront << " " << pBack << " " << pOverall << endl; 
     
    24632463        ++ mCreatedViewCells; 
    24642464 
    2465 #ifdef _DEBUG 
     2465#ifdef GTP_DEBUG 
    24662466        Debug << "BSP stats: " 
    24672467                  << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1707 r1715  
    595595                ); 
    596596 
    597 #if _DEBUG 
     597#if GTP_DEBUG 
    598598        if (localTerminationCriteriaMet) 
    599599        { 
     
    621621                ); 
    622622 
    623 #if _DEBUG 
     623#if GTP_DEBUG 
    624624        if (terminationCriteriaMet) 
    625625        { 
     
    13061306        vector<SortableEntry>::const_iterator ci, ci_end = mLocalSubdivisionCandidates->end(); 
    13071307 
    1308 #ifdef _DEBUG 
     1308#ifdef GTPGTP_DEBUG 
    13091309        const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 
    13101310        const int leaves = mVspStats.Leaves(); 
     
    13461346                        sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
    13471347                         
    1348 #ifdef _DEBUG 
     1348#ifdef GTPGTP_DEBUG 
    13491349                        if (printStats) 
    13501350                        { 
     
    13991399        } 
    14001400         
    1401 #ifdef _DEBUG 
     1401#ifdef GTPGTP_DEBUG 
    14021402        Debug << "\n§§§§ eval local cost §§§§" << endl 
    14031403                  << "back pvs: " << penaltyBack << " front pvs: " << penaltyFront << " total pvs: " << penaltyOld << endl  
     
    15661566        const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 
    15671567 
    1568 #ifdef _DEBUG 
     1568#ifdef GTPGTP_DEBUG 
    15691569        Debug << "\nvsp render cost decrease" << endl 
    15701570                  << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl  
     
    16211621        const float oldCost = (float)pvsSize * pOverall + Limits::Small; 
    16221622         
    1623 #ifdef _DEBUG 
     1623#ifdef GTPGTP_DEBUG 
    16241624        Debug << "axis: " << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 
    16251625        Debug << "p: " << pFront << " " << pBack << " " << pOverall << endl; 
     
    18751875        ++ mCreatedViewCells; 
    18761876 
    1877 #ifdef _DEBUG 
     1877#ifdef GTPGTP_DEBUG 
    18781878        Debug << "BSP stats: " 
    18791879                  << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h

    r1571 r1715  
    313313}; 
    314314 
     315/* 
     316struct VssRayDistribution { 
     317  VssRayDistribution() { mContribution = -1.0f; } 
     318  SimpleRayContainer mRays; 
     319  vector<VssRayContainer> mVssRays; 
     320  float mContribution; 
     321  float mTime; 
     322}; 
     323 
     324struct VssRayDistributionMixture { 
     325  VssRayDistributionMixture() {} 
     326   
     327  vector<VssRayDistribution> distributions; 
     328}; 
     329*/ 
     330 
    315331}; 
    316332 
  • GTP/trunk/Lib/Vis/Preprocessing/src/common.h

    r1634 r1715  
    485485FileExists(char *filename); 
    486486 
     487#define GTP_DEBUG 0 
     488 
    487489#define DEBUG_LEVEL 5 
    488490//#define DEBUG_LEVEL 1000 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r1694 r1715  
    1717#filename ../data/vienna/city1500_flat_1.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d 
    1818#filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-plane.x3d 
    19 filename ../data/vienna/vienna.obj 
     19#filename ../data/vienna/vienna.obj 
     20 
     21filename ../data/vienna/vienna-buildings_vienna-roofs_vienna-roads_vienna-plane_cropped.obj 
    2022 
    2123# filename ../data/vienna/viewcells-25-sel.x3d 
     
    5658        applyVisibilitySpatialFilter false 
    5759        visibilityFilterWidth   0.01 
    58         exportVisibility true 
     60        exportVisibility false 
    5961        visibilityFile visibility.xml 
    6062        loadMeshes false 
     
    7981RssPreprocessor { 
    8082        samplesPerPass 1000 
    81         initialSamples 1000000 
     83        initialSamples 2000000 
    8284        vssSamples 50000000 
    8385#       vssSamples 1000000 
    84         vssSamplesPerPass 1000000 
     86        vssSamplesPerPass 2000000 
    8587        useImportanceSampling true 
    8688 
     
    116118        maxCostRatio 1.0 
    117119        maxRayContribution 1.0 
    118         maxRays         4000000 
     120        maxRays         3000000 
    119121        maxTotalMemory  200 
    120122        maxStaticMemory 100 
     
    282284#       filename ../data/vienna/viewcells_vienna2.xml 
    283285#       filename ../data/vienna/vienna_simple-21-04-avs2-viewCells.xml 
     286#       filename ../data/vienna/vienna-viewcells-20000.xml.gz 
    284287#       filename ../data/vienna/vienna-viewcells-5000.xml.gz 
    285         filename ../data/vienna/vienna-viewcells-1000.xml.zip 
     288#       filename ../data/vienna/vienna-viewcells-1000.xml.zip 
    286289#       filename ../data/vienna/vsposp-seq-viewCells.xml.gz 
     290 
     291        filename ../data/vienna/vienna_cropped-2-sequential-30000-viewcells.xml.gz 
     292#       filename ../data/vienna/vienna_cropped-sequential-400000-viewcells.xml.gz 
     293 
    287294 
    288295#       filename ../data/vienna/city1500_flat_viewcells-1000.xml 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1713 r1715  
    274274        PreprocessorThread *pt; 
    275275 
     276 
    276277#if USE_QT 
     278        // create a qt application first (must be created before any opengl widget ...) 
     279        QApplication *app = new QApplication(argc, NULL); 
     280         
    277281        pt = new QtPreprocessorThread(preprocessor); 
    278282#else 
     
    300304                if (!rendererWidget)  
    301305                { 
    302                   // create a qt application first (must be created before any opengl widget ...) 
    303                   QApplication *app = new QApplication(argc, NULL); 
    304306                   
    305307                  if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro

    r1694 r1715  
    1717NONGTP = ../../../../../../NonGTP 
    1818 
    19 #win32:INCLUDEPATH += c:/STLport-4.6.2/stlport 
     19#win32:INCLUDEPATH += d:/STLport-4.6.2/stlport 
    2020 
    2121CONFIG(qt) { 
     
    4444unix:LIBPATH += ../support/src/xerces-c-src_2_7_0/lib ../support/devil/lib /usr/lib/qt3/lib64 
    4545 
    46 #win32:LIBPATH += c:/STLport-4.6.2/lib 
     46#win32:LIBPATH += d:/STLport-4.6.2/lib 
    4747 
    4848 
Note: See TracChangeset for help on using the changeset viewer.