source: trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp @ 530

Revision 530, 17.8 KB checked in by mattausch, 18 years ago (diff)

started test function for beam

RevLine 
[372]1#include "SceneGraph.h"
2#include "KdTree.h"
3#include "VssPreprocessor.h"
4#include "X3dExporter.h"
5#include "Environment.h"
6#include "MutualVisibility.h"
7#include "Polygon3.h"
8#include "ViewCell.h"
[376]9#include "VssRay.h"
[382]10#include "VssTree.h"
[439]11#include "ViewCellsManager.h"
[452]12#include "RenderSimulator.h"
[372]13
[427]14bool use2dSampling = false;
[501]15bool useViewspacePlane = true;
[427]16
[372]17VssPreprocessor::VssPreprocessor():
[434]18  mPass(0),
19  mVssRays()
[372]20{
21  // this should increase coherence of the samples
[376]22  environment->GetIntValue("VssPreprocessor.samplesPerPass", mSamplesPerPass);
[403]23  environment->GetIntValue("VssPreprocessor.initialSamples", mInitialSamples);
24  environment->GetIntValue("VssPreprocessor.vssSamples", mVssSamples);
[427]25  environment->GetIntValue("VssPreprocessor.vssSamplesPerPass", mVssSamplesPerPass);
[429]26  environment->GetBoolValue("VssPreprocessor.useImportanceSampling", mUseImportanceSampling);
[517]27  environment->GetBoolValue("ViewCells.delayedConstruction", mDelayedViewCellsConstruction);
[468]28
[490]29  environment->GetBoolValue("VssPreprocessor.loadInitialSamples", mLoadInitialSamples);
30  environment->GetBoolValue("VssPreprocessor.storeInitialSamples", mStoreInitialSamples);
[501]31  environment->GetBoolValue("VssPreprocessor.useViewSpaceBox", mUseViewSpaceBox);
[508]32  useViewspacePlane = mUseViewSpaceBox; //hack
[490]33
[372]34  mStats.open("stats.log");
35}
36
37VssPreprocessor::~VssPreprocessor()
38{
[434]39  CLEAR_CONTAINER(mVssRays);
[372]40}
41
42void
[468]43VssPreprocessor::SetupRay(Ray &ray,
44                                                  const Vector3 &point,
[434]45                                                  const Vector3 &direction
46                                                  )
[372]47{
[466]48  ray.Clear();
[434]49  // do not store anything else then intersections at the ray
[374]50  ray.Init(point, direction, Ray::LOCAL_RAY);
[372]51}
52
[386]53int
[376]54VssPreprocessor::CastRay(
[434]55                                                 Vector3 &viewPoint,
56                                                 Vector3 &direction,
57                                                 VssRayContainer &vssRays
58                                                 )
[372]59{
[499]60
61    int hits = 0;
[434]62  static Ray ray;
63  AxisAlignedBox3 box = mKdTree->GetBox();
[427]64
[434]65  AxisAlignedBox3 sbox = box;
66  sbox.Enlarge(Vector3(-Limits::Small));
67  if (!sbox.IsInside(viewPoint))
68        return 0;
[499]69       
[434]70  SetupRay(ray, viewPoint, direction);
71  // cast ray to KD tree to find intersection with other objects
72  Intersectable *objectA, *objectB;
73  Vector3 pointA, pointB;
74  float bsize = Magnitude(box.Size());
[499]75
76 
[434]77  if (mKdTree->CastRay(ray)) {
78        objectA = ray.intersections[0].mObject;
79        pointA = ray.Extrap(ray.intersections[0].mT);
80  } else {
81        objectA = NULL;
82        // compute intersection with the scene bounding box
83        float tmin, tmax;
[499]84        if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)
85          pointA = ray.Extrap(tmax);
86        else
87          return 0;
[434]88  }
[386]89
[434]90  bool detectEmptyViewSpace = true;
[499]91       
[434]92  if (detectEmptyViewSpace) {
93        SetupRay(ray, pointA, -direction);
94  } else
95        SetupRay(ray, viewPoint, -direction);
[499]96       
97       
[434]98  if (mKdTree->CastRay(ray)) {
99        objectB = ray.intersections[0].mObject;
100        pointB = ray.Extrap(ray.intersections[0].mT);
101  } else {
102        objectB = NULL;
103        float tmin, tmax;
[499]104        if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)
105          pointB = ray.Extrap(tmax);
106        else
107          return 0;
108  }
109
110  //  if (objectA == NULL && objectB != NULL) {
111  if (1) {
112        // cast again to ensure that there is no objectA
113        SetupRay(ray, pointB, direction);
114        if (mKdTree->CastRay(ray)) {
115          objectA = ray.intersections[0].mObject;
116          pointA = ray.Extrap(ray.intersections[0].mT);
[434]117        }
118  }
[499]119 
120 
[434]121  VssRay *vssRay  = NULL;
[386]122
[499]123  bool validSample = (objectA != objectB);
124  if (0 && detectEmptyViewSpace) {   // consider all samples valid
125        // check if the viewpoint lies on the line segment AB
[434]126        if (Distance(pointA, pointB) <
127                Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) {
128          validSample = false;
[386]129        }
[434]130  }
[499]131       
[434]132  if (validSample) {
133        if (objectA) {
134          vssRay = new VssRay(pointB,
135                                                  pointA,
136                                                  objectB,
[499]137                                                  objectA,
138                                                  mPass
139                                                  );
[434]140          vssRays.push_back(vssRay);
141          hits ++;
142        }
[499]143       
[434]144        if (objectB) {
145          vssRay = new VssRay(pointA,
146                                                  pointB,
147                                                  objectA,
[499]148                                                  objectB,
149                                                  mPass
150                                                  );
[434]151          vssRays.push_back(vssRay);
152          hits ++;
[372]153        }
[434]154  }
[499]155       
[434]156  return hits;
[372]157}
158
159
[376]160Vector3
[382]161VssPreprocessor::GetViewpoint(AxisAlignedBox3 *viewSpaceBox)
[372]162{
[434]163  AxisAlignedBox3 box;
[468]164
[434]165  if (viewSpaceBox)
166        box =*viewSpaceBox;
[468]167  else
[434]168        box = mKdTree->GetBox();
[468]169
[434]170  // shrink the box in the y direction
171  return box.GetRandomPoint();
[372]172}
173
[376]174Vector3
[427]175VssPreprocessor::GetDirection(const Vector3 &viewpoint,
[434]176                                                          AxisAlignedBox3 *viewSpaceBox
177                                                          )
[372]178{
[434]179  Vector3 point;
180  if (!use2dSampling) {
181        Vector3 normal;
[474]182        int i = (int)RandomValue(0, (Real)((int)mObjects.size()-1));
[434]183        Intersectable *object = mObjects[i];
184        object->GetRandomSurfacePoint(point, normal);
185  } else {
186        AxisAlignedBox3 box;
[468]187
[434]188        if (viewSpaceBox)
189          box =*viewSpaceBox;
[468]190        else
[434]191          box = mKdTree->GetBox();
[468]192
[434]193        point = box.GetRandomPoint();
194        point.y = viewpoint.y;
195  }
[468]196
[434]197  return point - viewpoint;
[372]198}
199
[401]200int
[427]201VssPreprocessor::GenerateImportanceRays(VssTree *vssTree,
[434]202                                                                                const int desiredSamples,
203                                                                                SimpleRayContainer &rays
204                                                                                )
[401]205{
[434]206  int num;
207  if (0) {
208        float minRayContribution;
209        float maxRayContribution;
210        float avgRayContribution;
[468]211
[434]212        vssTree->GetRayContributionStatistics(minRayContribution,
213                                                                                  maxRayContribution,
214                                                                                  avgRayContribution);
[468]215
[434]216        cout<<
217          "#MIN_RAY_CONTRIB\n"<<minRayContribution<<endl<<
218          "#MAX_RAY_CONTRIB\n"<<maxRayContribution<<endl<<
219          "#AVG_RAY_CONTRIB\n"<<avgRayContribution<<endl;
[468]220
[434]221        float p = desiredSamples/(float)(avgRayContribution*vssTree->stat.Leaves());
222        num = vssTree->GenerateRays(p, rays);
223  } else {
224        int leaves = vssTree->stat.Leaves()/2;
225        num = vssTree->GenerateRays(desiredSamples, leaves, rays);
226  }
[468]227
[434]228  cout<<"Generated "<<num<<" rays."<<endl;
[468]229
[434]230  return num;
[427]231}
[376]232
233
[427]234bool
235VssPreprocessor::ExportRays(const char *filename,
[434]236                                                        const VssRayContainer &vssRays,
237                                                        const int number
238                                                        )
[427]239{
[434]240  cout<<"Exporting vss rays..."<<endl<<flush;
[468]241
[434]242  float prob = number/(float)vssRays.size();
[427]243
244
[434]245  Exporter *exporter = NULL;
246  exporter = Exporter::GetExporter(filename);
247  //    exporter->SetWireframe();
248  //    exporter->ExportKdTree(*mKdTree);
249  exporter->SetFilled();
250  exporter->ExportScene(mSceneGraph->mRoot);
251  exporter->SetWireframe();
[427]252
[434]253  if (mViewSpaceBox) {
[438]254        exporter->SetForcedMaterial(RgbColor(1,0,1));
[434]255        exporter->ExportBox(*mViewSpaceBox);
256        exporter->ResetForcedMaterial();
257  }
[468]258
[434]259  VssRayContainer rays; for (int i=0; i < vssRays.size(); i++)
260        if (RandomValue(0,1) < prob)
261          rays.push_back(vssRays[i]);
[427]262
[434]263  exporter->ExportRays(rays, RgbColor(1, 0, 0));
[468]264
[434]265  delete exporter;
[401]266
[434]267  cout<<"done."<<endl<<flush;
[427]268
[434]269  return true;
[401]270}
271
272
[372]273bool
[434]274VssPreprocessor::ExportVssTree(char *filename,
[438]275                                                           VssTree *tree,
276                                                           const Vector3 &dir
277                                                           )
[434]278{
279  Exporter *exporter = Exporter::GetExporter(filename);
280  exporter->SetFilled();
281  exporter->ExportScene(mSceneGraph->mRoot);
[438]282  //  exporter->SetWireframe();
283  bool result = exporter->ExportVssTree2( *tree, dir );
[434]284  delete exporter;
285  return result;
286}
287
288bool
[427]289VssPreprocessor::ExportVssTreeLeaf(char *filename,
[434]290                                                                   VssTree *tree,
291                                                                   VssTreeLeaf *leaf)
[427]292{
[434]293  Exporter *exporter = NULL;
294  exporter = Exporter::GetExporter(filename);
295  exporter->SetWireframe();
296  exporter->ExportKdTree(*mKdTree);
[468]297
[434]298  if (mViewSpaceBox) {
299        exporter->SetForcedMaterial(RgbColor(1,0,0));
300        exporter->ExportBox(*mViewSpaceBox);
[427]301        exporter->ResetForcedMaterial();
[434]302  }
[468]303
[434]304  exporter->SetForcedMaterial(RgbColor(0,0,1));
305  exporter->ExportBox(tree->GetBBox(leaf));
306  exporter->ResetForcedMaterial();
[468]307
[434]308  VssRayContainer rays[4];
309  for (int i=0; i < leaf->rays.size(); i++) {
310        int k = leaf->rays[i].GetRayClass();
311        rays[k].push_back(leaf->rays[i].mRay);
312  }
[468]313
[434]314  // SOURCE RAY
315  exporter->ExportRays(rays[0], RgbColor(1, 0, 0));
316  // TERMINATION RAY
317  exporter->ExportRays(rays[1], RgbColor(1, 1, 1));
318  // PASSING_RAY
319  exporter->ExportRays(rays[2], RgbColor(1, 1, 0));
320  // CONTAINED_RAY
321  exporter->ExportRays(rays[3], RgbColor(0, 0, 1));
[427]322
[434]323  delete exporter;
324  return true;
[427]325}
326
327void
328VssPreprocessor::ExportVssTreeLeaves(VssTree *tree, const int number)
329{
[434]330  vector<VssTreeLeaf *> leaves;
331  tree->CollectLeaves(leaves);
[427]332
[434]333  int num = 0;
334  int i;
335  float p = number / (float)leaves.size();
336  for (i=0; i < leaves.size(); i++) {
337        if (RandomValue(0,1) < p) {
338          char filename[64];
339          sprintf(filename, "vss-leaf-%04d.x3d", num);
340          ExportVssTreeLeaf(filename, tree, leaves[i]);
341          num++;
[427]342        }
[434]343        if (num >= number)
344          break;
345  }
[427]346}
347
[434]348
[530]349void VssPreprocess::VerifyBeamCasting()
350{
351
352        vector<VssLeaf *> leaves;
353        mVssTree->CollectLeaves(leaves);
354
355        for (int i = 0; i < 10; ++i)
356        {
357                const int index = (int)RandomValue(0, (Real)((int)leaf.size() - 1));
358                VssLeaf *leaf = leaves[index];
359
360                Beam beam;
361                AxisAlignedBox3 dirBox = mVssTree->GetDirBBox(leaf);
362                AxisAlignedBox3 box = mVssTree->GetBBox(leaf);
363                beam.Construct(dirBox, box);
364                Intersectable *sourceObj = mObjects[5];
365                BeamSampleStatistics stats;
366                mGlRenderer->SampleBeamContributions(sourceObj,
367                                                                                         beam,
368                                                                                         10000,
369                                                                                         stats);
370
371                Debug << "beam statistics: " << stats << endl;
372
373
374        }
375
376}
377
[434]378float
379VssPreprocessor::GetAvgPvsSize(VssTree *tree,
380                                                           const vector<AxisAlignedBox3> &viewcells
381                                                           )
382{
383  vector<AxisAlignedBox3>::const_iterator it, it_end = viewcells.end();
384
385  int sum = 0;
386  for (it = viewcells.begin(); it != it_end; ++ it)
387        sum += tree->GetPvsSize(*it);
[468]388
[434]389  return sum/(float)viewcells.size();
390}
391
[427]392bool
[372]393VssPreprocessor::ComputeVisibility()
394{
[468]395
396
[372]397  long startTime = GetTime();
[468]398
[372]399  int totalSamples = 0;
400
401
[434]402  AxisAlignedBox3 *box = new AxisAlignedBox3(mKdTree->GetBox());
[382]403
[434]404  if (!useViewspacePlane) {
[446]405        float size = 0.05f;
[434]406        float s = 0.5f - size;
407        float olds = Magnitude(box->Size());
408        box->Enlarge(box->Size()*Vector3(-s));
409        Vector3 translation = Vector3(-olds*0.1f, 0, 0);
410        box->SetMin(box->Min() + translation);
411        box->SetMax(box->Max() + translation);
412  } else {
[468]413
[434]414        // sample city like heights
[469]415        box->SetMin(1, box->Min(1) + box->Size(1)*0.2f);
416        box->SetMax(1, box->Min(1) + box->Size(1)*0.3f);
[434]417  }
[427]418
[434]419  if (use2dSampling)
420        box->SetMax(1, box->Min(1));
[468]421
[501]422  if (mUseViewSpaceBox)
[487]423  {
[434]424        mViewSpaceBox = box;
[487]425        mViewCellsManager->SetViewSpaceBox(*box);
426  }
[434]427  else
[487]428  {
[434]429        mViewSpaceBox = NULL;
[487]430        mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox());
431  }
[518]432
433  //-- load view cells from file if requested
434  if (mLoadViewCells)
[527]435  {     
436          // load now because otherwise bounding box not correct
[520]437          mViewCellsManager->LoadViewCells(mViewCellsFilename, &mObjects);
[518]438  }
439
440
[434]441  VssTree *vssTree = NULL;
[401]442
[490]443  mSceneGraph->CollectObjects(&mObjects);
[468]444
[490]445  long initialTime = GetTime();
[468]446
[490]447  if (mLoadInitialSamples)
448  {
449          cout << "Loading samples from file ... ";
450          LoadSamples(mVssRays, mObjects);
451          cout << "finished\n" << endl;
452          totalSamples = (int)mVssRays.size();
453  }
454  else
455  {
456          while (totalSamples < mInitialSamples) {
457                int passContributingSamples = 0;
458                int passSampleContributions = 0;
459                int passSamples = 0;
[468]460
[490]461                int index = 0;
[468]462
[490]463                int sampleContributions;
[468]464
[490]465                int s = Min(mSamplesPerPass, mInitialSamples);
466                for (int k=0; k < s; k++) {
467                        // changed by matt
468                        //Vector3 viewpoint = GetViewpoint(mViewSpaceBox);
469                        Vector3 viewpoint;
470                        mViewCellsManager->GetViewPoint(viewpoint);
471                        Vector3 direction = GetDirection(viewpoint, mViewSpaceBox);
472               
473                        sampleContributions = CastRay(viewpoint, direction, mVssRays);
[468]474
[490]475                        if (sampleContributions) {
476                                passContributingSamples ++;
477                                passSampleContributions += sampleContributions;
478                        }
479                        passSamples++;
480                        totalSamples++;
481                }
[468]482
[490]483                mPass++;
484                int pvsSize = 0;
485                float avgRayContrib = (passContributingSamples > 0) ?
486                        passSampleContributions/(float)passContributingSamples : 0;
[468]487
[490]488                cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl;
489                cout << "#TotalSamples=" << totalSamples/1000
490                        << "k   #SampleContributions=" << passSampleContributions << " ("
491                        << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS="
492                        << pvsSize/(float)mObjects.size() << endl
493                        << "avg ray contrib=" << avgRayContrib << endl;
[468]494
[490]495                mStats <<
496                        "#Pass\n" <<mPass<<endl<<
497                        "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl<<
498                        "#TotalSamples\n" << totalSamples<< endl<<
499                        "#SampleContributions\n" << passSampleContributions << endl <<
500                        "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl <<
501                        "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl <<
502                        "#AvgRayContrib\n" << avgRayContrib << endl;
503          }
504 
505          cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl;
506  }
507 
508  cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl << flush;
509  Debug << (int)mVssRays.size() << " rays generated in "
510            << TimeDiff(initialTime, GetTime()) * 1e-3 << " seconds" << endl;
[401]511
[490]512  if (mStoreInitialSamples)
513  {
514          cout << "Writing " << (int)mVssRays.size() << " samples to file ... ";
[508]515          ExportSamples(mVssRays);
[490]516          cout << "finished\n" << endl;
[491]517
518          /*VssRayContainer dummyRays;
519          LoadSamples(dummyRays, mObjects);
520          Debug << "rays " << (int)mVssRays.size() << " " << dummyRays.size() << endl;
521
522          for (int i = 0; i < (int)mVssRays.size(); ++ i)
523          {
524                  Debug << mVssRays[i]->GetOrigin() << " " << mVssRays[i]->GetTermination() << " " << mVssRays[i]->mOriginObject << " " << mVssRays[i]->mTerminationObject << endl;
525                  Debug << dummyRays[i]->GetOrigin() << " " << dummyRays[i]->GetTermination() << " " << dummyRays[i]->mOriginObject << " " << dummyRays[i]->mTerminationObject << endl << endl;
526          }*/
[434]527  }
[468]528
[452]529  //int numExportRays = 10000;
530  int numExportRays = 0;
[372]531
[434]532  if (numExportRays) {
533        char filename[64];
534        sprintf(filename, "vss-rays-initial.x3d");
535        ExportRays(filename, mVssRays, numExportRays);
536  }
[468]537
[518]538  /// compute view cell contribution of rays if view cells manager already constructed
539  mViewCellsManager->ComputeSampleContributions(mVssRays);
540
[448]541  // construct view cells
[517]542  if (!mDelayedViewCellsConstruction)
543        mViewCellsManager->Construct(mObjects, mVssRays);
544 
[434]545  vssTree = new VssTree;
546  // viewcells = Construct(mVssRays);
[468]547
[434]548  vssTree->Construct(mVssRays, mViewSpaceBox);
549  cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl;
[468]550
[465]551  if (0)
552  {
553          ExportVssTree("vss-tree-100.x3d", vssTree, Vector3(1,0,0));
554          ExportVssTree("vss-tree-001.x3d", vssTree, Vector3(0,0,1));
555          ExportVssTree("vss-tree-101.x3d", vssTree, Vector3(1,0,1));
556          ExportVssTree("vss-tree-101m.x3d", vssTree, Vector3(-1,0,-1));
557          ExportVssTreeLeaves(vssTree, 10);
558  }
[430]559
[434]560  // viewcells->UpdatePVS(newVssRays);
561  // get viewcells as kd tree boxes
562  vector<AxisAlignedBox3> kdViewcells;
563  if (0) {
564        vector<KdLeaf *> leaves;
565        mKdTree->CollectLeaves(leaves);
566        vector<KdLeaf *>::const_iterator it;
567        int targetLeaves = 50;
568        float prob = targetLeaves/(float)leaves.size();
569        for (it = leaves.begin(); it != leaves.end(); ++it)
570          if (RandomValue(0.0f,1.0f) < prob)
571                kdViewcells.push_back(mKdTree->GetBox(*it));
[468]572
[434]573        float avgPvs = GetAvgPvsSize(vssTree, kdViewcells);
574        cout<<"Initial average PVS size = "<<avgPvs<<endl;
575  }
576
[468]577
[434]578  int samples = 0;
579  int pass = 0;
[448]580
581  // cast view cell samples
[434]582  while (1) {
583        int num = mVssSamplesPerPass;
584        SimpleRayContainer rays;
585        VssRayContainer vssRays;
[468]586
[434]587        if (!mUseImportanceSampling) {
588          for (int j=0; j < num; j++) {
[487]589            // changed by matt
590                //Vector3 viewpoint = GetViewpoint(mViewSpaceBox);
591                Vector3 viewpoint;
592                mViewCellsManager->GetViewPoint(viewpoint);
[434]593                Vector3 direction = GetDirection(viewpoint, mViewSpaceBox);
594                rays.push_back(SimpleRay(viewpoint, direction));
595          }
596        } else {
597          num = GenerateImportanceRays(vssTree, num, rays);
598        }
[468]599
[434]600        for (int i=0; i < rays.size(); i++)
601          CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays);
[468]602
[434]603        vssTree->AddRays(vssRays);
[468]604
[434]605        if (0) {
606          int subdivided = vssTree->UpdateSubdivision();
607          cout<<"subdivided leafs = "<<subdivided<<endl;
608        }
[427]609
[434]610        float avgPvs = GetAvgPvsSize(vssTree, kdViewcells);
611        cout<<"Average PVS size = "<<avgPvs<<endl;
[430]612
[517]613        //Debug << "samples: " << samples << " construction samples " << mViewCellsManager->GetConstructionSamples() << endl;
614        // construct view cells after vss
615        if (!mViewCellsManager->ViewCellsConstructed() &&
616                (samples + mInitialSamples >  mViewCellsManager->GetConstructionSamples()))
617        {
618                VssRayContainer constructionRays;
619                vssTree->CollectRays(constructionRays,
620                                                         mViewCellsManager->GetConstructionSamples());
621                mViewCellsManager->Construct(mObjects, constructionRays);
622        }
623
624        /// compute view cell contribution of rays
625        mViewCellsManager->ComputeSampleContributions(vssRays);
626       
[434]627        if (numExportRays) {
628          char filename[64];
629          if (mUseImportanceSampling)
630                sprintf(filename, "vss-rays-i%04d.x3d", pass);
631          else
632                sprintf(filename, "vss-rays-%04d.x3d", pass);
[468]633
[434]634          ExportRays(filename, vssRays, numExportRays);
[401]635        }
[386]636
[434]637        samples+=num;
638        float pvs = vssTree->GetAvgPvsSize();
639        cout<<"*****************************\n";
640        cout<<samples<<" avgPVS ="<<pvs<<endl;
641        cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl;
642        cout<<"*****************************\n";
643        if (samples >= mVssSamples)
644          break;
645        pass++;
646  }
[448]647
[468]648
[517]649  VssRayContainer viewCellRays;
650 
651  // compute rays used for view cells construction
652  int numRays = Max(mViewCellsManager->GetPostProcessSamples(),
653                                        mViewCellsManager->GetVisualizationSamples());
[468]654
[517]655  vssTree->CollectRays(viewCellRays, numRays);
656 
657  //-- post process view cells
658  mViewCellsManager->PostProcess(mObjects, viewCellRays);
[468]659
[517]660  //-- several visualizations and statistics
661  Debug << "\nview cells after post processing: " << endl;
662  mViewCellsManager->PrintStatistics(Debug);
[452]663
[517]664  mViewCellsManager->Visualize(mObjects, viewCellRays);
665 
[452]666  //-- render simulation after merge
667  cout << "\nevaluating bsp view cells render time after merge ... ";
[468]668  mRenderSimulator->RenderScene();
669  SimulationStatistics ss;
670  mRenderSimulator->GetStatistics(ss);
[474]671 
[452]672  cout << " finished" << endl;
673  cout << ss << endl;
674  Debug << ss << endl;
[468]675
[434]676  delete vssTree;
[475]677 
[434]678  return true;
[466]679}
Note: See TracBrowser for help on using the repository browser.