source: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp @ 2696

Revision 2696, 36.4 KB checked in by mattausch, 16 years ago (diff)
  • Property svn:executable set to *
Line 
1#include "Environment.h"
2#include "GvsPreprocessor.h"
3#include "GlRenderer.h"
4#include "VssRay.h"
5#include "ViewCellsManager.h"
6#include "Triangle3.h"
7#include "IntersectableWrapper.h"
8#include "Plane3.h"
9#include "RayCaster.h"
10#include "Exporter.h"
11#include "SamplingStrategy.h"
12#include "BvHierarchy.h"
13#include "Polygon3.h"
14#include "IntersectableWrapper.h"
15
16
17
18namespace GtpVisibilityPreprocessor
19{
20 
21#define GVS_DEBUG 0
22#define NOT_ACCOUNTED_OBJECT 0
23#define ACCOUNTED_OBJECT 2
24#define SHOW_QT_VISUALIZATION 0
25
26static const float MIN_DIST = 0.001f;
27
28static ObjectContainer myobjects;
29
30
31/** Visualization structure for the GVS algorithm.
32*/
33struct VizStruct
34{
35        Polygon3 *enlargedTriangle;
36        Triangle3 originalTriangle;
37        VssRay *ray;
38};
39
40static vector<VizStruct> vizContainer;
41
42
43
44
45GvsPreprocessor::GvsPreprocessor():
46Preprocessor(),
47mProcessedViewCells(0),
48mCurrentViewCell(NULL),
49mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)),
50mOnlyRandomSampling(false)
51//mOnlyRandomSampling(true)
52{
53        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples);
54        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.initialSamples", mInitialSamples);
55        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.gvsSamplesPerPass", mGvsSamplesPerPass);
56        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.minContribution", mMinContribution);
57        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.epsilon", mEps);
58        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.threshold", mThreshold);   
59        Environment::GetSingleton()->GetBoolValue("GvsPreprocessor.perViewCell", mPerViewCell);
60        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.maxViewCells", mMaxViewCells);
61
62        Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError", mEvaluatePixelError);
63
64        Environment::GetSingleton()->GetBoolValue("ViewCells.useKdPvs", mUseKdPvs);
65
66
67        char gvsStatsLog[100];
68        Environment::GetSingleton()->GetStringValue("GvsPreprocessor.stats", gvsStatsLog);
69        mGvsStatsStream.open(gvsStatsLog);
70
71        cout << "number of gvs samples per pass: " << mGvsSamplesPerPass << endl;
72        cout << "number of samples per pass: " << mSamplesPerPass << endl;
73        cout << "only random sampling: " << mOnlyRandomSampling << endl;
74
75        Debug << "Gvs preprocessor options" << endl;
76        Debug << "number of total samples: " << mTotalSamples << endl;
77        Debug << "number of initial samples: " << mInitialSamples << endl;
78        Debug << "threshold: " << mThreshold << endl;
79        Debug << "epsilon: " << mEps << endl;
80        Debug << "stats: " << gvsStatsLog << endl;
81        Debug << "per view cell: " << mPerViewCell << endl;
82        Debug << "max view cells: " << mMaxViewCells << endl;
83        Debug << "min contribution: " << mMinContribution << endl;
84
85        mDistribution = new ViewCellBasedDistribution(*this, NULL);
86
87        mGvsStats.Reset();
88
89        // hack: some generic statistical values that can be used
90        // by an application using the preprocessor
91        for (int i = 0; i < 2; ++ i)
92                mGenericStats[i] = 0;
93}
94
95
96GvsPreprocessor::~GvsPreprocessor()
97{
98        delete mDistribution;
99        ClearRayQueue();
100}
101
102
103void GvsPreprocessor::ClearRayQueue()
104{
105        // clean ray queue
106        while (!mRayQueue.empty())
107        {
108                // handle next ray
109                VssRay *ray = mRayQueue.top();
110                mRayQueue.pop();
111
112                // note: deletion of the ray is handled by ray pool
113        }
114}
115
116
117ViewCell *GvsPreprocessor::NextViewCell()
118{
119        if (mProcessedViewCells == (int)mViewCells.size())
120                return NULL; // no more view cells
121
122        ViewCell *vc = mViewCells[mProcessedViewCells];
123
124   if (!vc->GetMesh())
125                mViewCellsManager->CreateMesh(vc);
126
127        mGvsStats.mViewCellId = vc->GetId();
128
129        Debug << "vc: " << vc->GetId() << endl;
130
131        ++ mProcessedViewCells;
132   
133        return vc;
134}
135
136
137int GvsPreprocessor::CheckDiscontinuity(const VssRay &currentRay,
138                                                                                const Triangle3 &hitTriangle,
139                                                                                const VssRay &oldRay)
140{
141        // the predicted hitpoint: we expect to hit the same mesh again
142        const Vector3 predictedHit = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay);
143
144        const float predictedLen = Magnitude(predictedHit - currentRay.mOrigin);
145        const float len = Magnitude(currentRay.mTermination - currentRay.mOrigin);
146       
147#if 1
148        // distance large => this is likely to be a discontinuity
149        if ((predictedLen - len) > mThreshold)
150#else
151        // q: rather use relative distance?
152        if ((predictedLen / len) > mThreshold)
153#endif
154        {
155                // apply reverse sampling to find the gap
156                VssRay *newRay = ReverseSampling(currentRay, hitTriangle, oldRay);
157
158                // check if reverse sampling was successful
159                if (newRay)
160                {
161                        // set flag for visualization
162                        if (0) newRay->mFlags |= VssRay::ReverseSample;
163               
164                        // check if ray can be processed further
165                        // note: ray deletion handled by ray pool)
166                        HandleRay(newRay);
167
168                        return 1;
169                }
170        }
171
172        return 0;
173}
174
175
176void GvsPreprocessor::CountObject(Intersectable *triObj)
177{
178        if ((triObj->mCounter != (NOT_ACCOUNTED_OBJECT + 1)) &&
179                (triObj->mCounter != (ACCOUNTED_OBJECT + 1)))
180        {
181                ++ triObj->mCounter;
182                ++ mGenericStats[1];
183        }
184}
185
186
187void GvsPreprocessor::UpdateStatsForVisualization(KdIntersectable *kdInt)
188{
189        //mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt);
190
191        // count new objects in pvs due to kd node conversion   
192        myobjects.clear();
193        mKdTree->CollectObjects(kdInt->GetItem(), myobjects);
194
195        ObjectContainer::const_iterator oit, oit_end = myobjects.end();
196
197        for (oit = myobjects.begin(); oit != oit_end; ++ oit)
198                CountObject(*oit);
199}       
200
201
202bool GvsPreprocessor::HasContribution(VssRay &ray)
203{
204        if (!ray.mTerminationObject)
205                return false;
206
207        bool result;
208
209        if (!mPerViewCell)
210        {
211                // store the rays + the intersected view cells
212                const bool storeViewCells = false; //GVS_DEBUG;
213
214                mViewCellsManager->ComputeSampleContribution(ray,
215                                                                                                         true,
216                                                                                                         storeViewCells,
217                                                                                                         true);
218
219                result = ray.mPvsContribution > 0;
220        }
221        else // original per view cell gvs
222        {
223                Intersectable *obj = ray.mTerminationObject;
224
225                // test if triangle was accounted for yet
226                result = AddTriangleObject(obj);
227               
228                if (mUseKdPvs && (1 || result))
229                {
230                        // exchange the triangle with the node in the pvs for kd pvs
231                        KdNode *node = mKdTree->GetPvsNode(ray.mTermination);
232
233                        //KdNode *node = mKdTree->GetPvsNodeCheck(ray.mTermination, obj);
234                        //if (!node) cerr << "e " << obj->GetBox() << " " << ray.mTermination << endl; else
235                        if (!node->Mailed())
236                        {//cout<<"o ";
237                                // add to pvs
238                                node->Mail();
239                                KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node);
240                                mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f);
241
242                                if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt); 
243                        }
244                }
245        }
246
247        return result;
248}
249
250
251bool GvsPreprocessor::HandleRay(VssRay *vssRay)
252{
253        if (!HasContribution(*vssRay))
254                return false;
255
256        if (0 && GVS_DEBUG)
257                mVssRays.push_back(new VssRay(*vssRay));
258
259        // add new ray to ray queue
260        mRayQueue.push(vssRay);
261
262        ++ mGvsStats.mTotalContribution;
263
264        return true;
265}
266
267
268/** Creates 3 new vertices for triangle vertex with specified index.
269*/
270void GvsPreprocessor::CreateDisplacedVertices(VertexContainer &vertices,
271                                                                                          const Triangle3 &hitTriangle,
272                                                                                          const VssRay &ray,
273                                                                                          const int index) const
274{
275        const int indexU = (index + 1) % 3;
276        const int indexL = (index == 0) ? 2 : index - 1;
277
278        const Vector3 a = hitTriangle.mVertices[index] - ray.GetOrigin();
279        const Vector3 b = hitTriangle.mVertices[indexU] - hitTriangle.mVertices[index];
280        const Vector3 c = hitTriangle.mVertices[index] - hitTriangle.mVertices[indexL];
281       
282        const float len = Magnitude(a);
283       
284        const Vector3 dir1 = Normalize(CrossProd(a, b)); //N((pi-xp)×(pi+1- pi));
285        const Vector3 dir2 = Normalize(CrossProd(a, c)); // N((pi-xp)×(pi- pi-1))
286        const Vector3 dir3 = DotProd(dir2, dir1) > 0 ? // N((pi-xp)×di,i-1+di,i+1×(pi-xp))
287                Normalize(dir2 + dir1) : Normalize(CrossProd(a, dir1) + CrossProd(dir2, a));
288
289        // compute the new three hit points
290        // pi, i + 1:  pi+ e·|pi-xp|·di, j
291        const Vector3 pt1 = hitTriangle.mVertices[index] + mEps * len * dir1;
292        // pi, i - 1:  pi+ e·|pi-xp|·di, j
293    const Vector3 pt2 = hitTriangle.mVertices[index] + mEps * len * dir2;
294        // pi, i:  pi+ e·|pi-xp|·di, j
295        const Vector3 pt3 = hitTriangle.mVertices[index] + mEps * len * dir3;
296       
297        vertices.push_back(pt2);
298        vertices.push_back(pt3);
299        vertices.push_back(pt1);
300}
301
302
303void GvsPreprocessor::EnlargeTriangle(VertexContainer &vertices,
304                                                                          const Triangle3 &hitTriangle,
305                                                                          const VssRay &ray) const
306{
307        CreateDisplacedVertices(vertices, hitTriangle, ray, 0);
308        CreateDisplacedVertices(vertices, hitTriangle, ray, 1);
309        CreateDisplacedVertices(vertices, hitTriangle, ray, 2);
310}
311
312
313Vector3 GvsPreprocessor::CalcPredictedHitPoint(const VssRay &newRay,
314                                                                                           const Triangle3 &hitTriangle,
315                                                                                           const VssRay &oldRay) const
316{
317        // find the intersection of the plane induced by the
318        // hit triangle with the new ray
319        Plane3 plane(hitTriangle.GetNormal(), hitTriangle.mVertices[0]);
320
321        const Vector3 hitPt =
322                plane.FindIntersection(newRay.mTermination, newRay.mOrigin);
323       
324        return hitPt;
325}
326
327
328static bool EqualVisibility(const VssRay &a, const VssRay &b)
329{
330        return a.mTerminationObject == b.mTerminationObject;
331}
332
333
334int GvsPreprocessor::SubdivideEdge(const Triangle3 &hitTriangle,
335                                                                   const Vector3 &p1,
336                                                                   const Vector3 &p2,
337                                                                   const VssRay &ray1,
338                                                                   const VssRay &ray2,
339                                                                   const VssRay &oldRay)
340{
341        //cout <<"y"<<Magnitude(p1 - p2) << " ";
342        int castRays = 0;
343
344        // cast reverse rays if necessary
345        castRays += CheckDiscontinuity(ray1, hitTriangle, oldRay);
346        castRays += CheckDiscontinuity(ray2, hitTriangle, oldRay);
347
348        if (EqualVisibility(ray1, ray2) || (SqrMagnitude(p1 - p2) <= MIN_DIST))
349        {
350                return castRays;
351        }
352       
353        // the new subdivision point
354        const Vector3 p = (p1 + p2) * 0.5f;
355        //cout << "p: " << p << " " << p1 << " " << p2 << endl;
356        // cast ray into the new point
357        SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin, SamplingStrategy::GVS, 1.0f);
358
359        VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell);
360       
361        ++ castRays;
362
363        if (!newRay) return castRays;
364
365        //newRay->mFlags |= VssRay::BorderSample;
366
367        // add new ray to queue
368        const bool enqueued = HandleRay(newRay);
369
370        // subdivide further
371        castRays += SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay);
372        castRays += SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay);
373
374        // this ray will not be further processed
375        // note: ray deletion is handled by ray pool
376
377        return castRays;
378}
379
380
381int GvsPreprocessor::AdaptiveBorderSampling(const VssRay &currentRay)
382{
383        Intersectable *tObj = currentRay.mTerminationObject;
384        // q matt: can this be possible
385        if (!tObj) return 0;
386
387        Triangle3 hitTriangle;
388
389        // other types not implemented yet
390        if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE)
391                hitTriangle = static_cast<TriangleIntersectable *>(tObj)->GetItem();
392        else
393                cout << "border sampling: " << Intersectable::GetTypeName(tObj) << " not yet implemented" << endl;
394
395        //cout << "type: " << Intersectable::GetTypeName(tObj) << endl;
396
397        VertexContainer enlargedTriangle;
398       
399        /// create 3 new hit points for each vertex
400        EnlargeTriangle(enlargedTriangle, hitTriangle, currentRay);
401       
402        /// create rays from sample points and handle them
403        SimpleRayContainer simpleRays;
404        simpleRays.reserve(9);
405
406        VertexContainer::const_iterator vit, vit_end = enlargedTriangle.end();
407
408        for (vit = enlargedTriangle.begin(); vit != vit_end; ++ vit)
409        {
410                const Vector3 rayDir = (*vit) - currentRay.GetOrigin();
411
412                SimpleRay sr(currentRay.GetOrigin(), rayDir, SamplingStrategy::GVS, 1.0f);
413                simpleRays.AddRay(sr); 
414        }
415
416        if (0)
417        {
418                // visualize enlarged triangles
419                VizStruct dummy;
420                dummy.enlargedTriangle = new Polygon3(enlargedTriangle);
421                dummy.originalTriangle = hitTriangle;
422                vizContainer.push_back(dummy);
423        }
424
425        // cast rays to triangle vertices and determine visibility
426        VssRayContainer vssRays;
427
428        // don't cast double rays as we need only the forward rays
429        const bool castDoubleRays = !mPerViewCell;
430        // cannot prune invalid rays because we have to compare adjacent  rays.
431        const bool pruneInvalidRays = false;
432
433
434        //////////
435        //-- fill up simple rays with random rays so we can cast 16
436
437        //const int numRandomRays = 0;
438        const int numRandomRays = 16 - (int)simpleRays.size();
439
440        GenerateRays(numRandomRays, *mDistribution, simpleRays);
441
442
443        /////////////////////
444
445        // keep origin for per view cell sampling
446        CastRays(simpleRays, vssRays, castDoubleRays, pruneInvalidRays);
447
448        const int numBorderSamples = (int)vssRays.size() - numRandomRays;
449
450#if 0
451        // set flags
452        VssRayContainer::const_iterator rit, rit_end = vssRays.end();
453        for (rit = vssRays.begin(); rit != rit_end; ++ rit, ++ i)
454                (*rit)->mFlags |= VssRay::BorderSample;
455#endif
456
457        int castRays = (int)simpleRays.size();
458
459        VssRayContainer invalidSamples;
460
461        // handle rays
462        EnqueueRays(vssRays, invalidSamples);
463
464    // recursivly subdivide each edge
465        for (int i = 0; i < numBorderSamples; ++ i)
466        {
467                castRays += SubdivideEdge(hitTriangle,
468                                                                  enlargedTriangle[i],
469                                                                  enlargedTriangle[(i + 1) % numBorderSamples],
470                                                                  *vssRays[i],
471                                                                  *vssRays[(i + 1) % numBorderSamples],
472                                                                  currentRay);
473        }
474       
475        mGvsStats.mBorderSamples += castRays;
476
477        //CLEAR_CONTAINER(invalidSamples);
478       
479        //cout << "here3 cast rays: " << castRays << endl;
480        return castRays;
481}
482
483
484bool GvsPreprocessor::GetPassingPoint(const VssRay &currentRay,
485                                                                          const Triangle3 &occluder,
486                                                                          const VssRay &oldRay,
487                                                                          Vector3 &newPoint) const
488{
489        //-- The plane p = (xp, hit(x), hit(xold)) is intersected
490        //-- with the newly found occluder (xold is the previous ray from
491        //-- which x was generated). On the intersecting line, we select a point
492        //-- pnew which lies just outside of the new triangle so the ray
493        //-- just passes through the gap
494
495        const Plane3 plane(currentRay.GetOrigin(),
496                                           currentRay.GetTermination(),
497                                           oldRay.GetTermination());
498       
499        Vector3 pt1, pt2;
500
501        const bool intersects = occluder.GetPlaneIntersection(plane, pt1, pt2);
502
503        if (!intersects)
504        {
505                //cerr << "big error!! no intersection " << pt1 << " " << pt2 << endl;
506                return false;
507        }
508
509        // get the intersection point on the old ray
510        const Plane3 triPlane(occluder.GetNormal(), occluder.mVertices[0]);
511
512        const float t = triPlane.FindT(oldRay.mOrigin, oldRay.mTermination);
513        const Vector3 pt3 = oldRay.mOrigin + t * (oldRay.mTermination - oldRay.mOrigin);
514
515        // evaluate new hitpoint just outside the triangle
516        // the point is chosen to be on the side closer to the original ray
517        if (Distance(pt1, pt3) < Distance(pt2, pt3))
518                newPoint = pt1 + mEps * (pt1 - pt2);
519        else
520                newPoint = pt2 + mEps * (pt2 - pt1);
521
522        //cout << "passing point: " << newPoint << endl << endl;
523        return true;
524}
525
526
527VssRay *GvsPreprocessor::ReverseSampling(const VssRay &currentRay,
528                                                                                 const Triangle3 &hitTriangle,
529                                                                                 const VssRay &oldRay)
530{
531        // get triangle occluding the path to the hit mesh
532        Triangle3 occluder;
533        Intersectable *tObj = currentRay.mTerminationObject;
534
535        // q: why can this happen?
536        if (!tObj)
537                return NULL;
538
539        // other types not implemented yet
540        if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE)
541        {
542                occluder = static_cast<TriangleIntersectable *>(tObj)->GetItem();
543        }
544        else
545        {
546                cout << "reverse sampling: " << tObj->Type() << " not yet implemented" << endl;
547        }
548        // get a point which is passing just outside of the occluder
549    Vector3 newPoint;
550
551        // q: why is there sometimes no intersecton found?
552        if (!GetPassingPoint(currentRay, occluder, oldRay, newPoint))
553                return NULL;
554
555        const Vector3 predicted = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay);
556
557        Vector3 newDir, newOrigin;
558
559        //-- Construct the mutated ray with xnew,
560        //-- dir = predicted(x)- pnew as direction vector
561        newDir = predicted - newPoint;
562
563        // take xnew, p = intersect(viewcell, line(pnew, predicted(x)) as origin ?
564        // difficult to say!!
565        const float offset = 0.5f;
566        newOrigin = newPoint - newDir * offset;
567       
568
569        //////////////
570        //-- for per view cell sampling, we must check for intersection
571        //-- with the current view cell
572
573    if (mPerViewCell)
574        {
575                // send ray to view cell
576                static Ray ray;
577                ray.Clear();
578                ray.Init(newOrigin, -newDir, Ray::LOCAL_RAY);
579               
580                //cout << "z";
581                // check if ray intersects view cell
582                if (!mCurrentViewCell->CastRay(ray))
583                        return NULL;
584
585                Ray::Intersection &hit = ray.intersections[0];
586       
587                //cout << "q";
588                // the ray starts from the view cell
589                newOrigin = ray.Extrap(hit.mT);
590        }
591
592        ++ mGvsStats.mReverseSamples;
593
594        const SimpleRay simpleRay(newOrigin, newDir, SamplingStrategy::GVS, 1.0f);
595
596        VssRay *reverseRay =
597                mRayCaster->CastRay(simpleRay, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell);
598
599        return reverseRay;
600}
601
602
603int GvsPreprocessor::CastInitialSamples(int numSamples)
604{       
605        const long startTime = GetTime();
606
607        // generate simple rays
608        SimpleRayContainer simpleRays;
609       
610        ViewCellBorderBasedDistribution vcStrat(*this, mCurrentViewCell);
611    GenerateRays(numSamples, *mDistribution, simpleRays);
612
613        //cout << "sr: " << simpleRays.size() << endl;
614        // generate vss rays
615        VssRayContainer samples;
616       
617        const bool castDoubleRays = !mPerViewCell;
618        const bool pruneInvalidRays = true;
619       
620        CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays);
621       
622        VssRayContainer invalidSamples;
623
624        // add to ray queue
625        EnqueueRays(samples, invalidSamples);
626
627        //CLEAR_CONTAINER(invalidSamples);
628        //Debug << "generated " <<  numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
629        return (int)simpleRays.size();
630}
631
632
633void GvsPreprocessor::EnqueueRays(VssRayContainer &samples, VssRayContainer &invalidSamples)
634{
635        // add samples to ray queue
636        VssRayContainer::const_iterator vit, vit_end = samples.end();
637        for (vit = samples.begin(); vit != vit_end; ++ vit)
638        {
639                VssRay *ray = *vit;
640
641                HandleRay(ray);
642                //if (!HandleRay(ray)) invalidSamples.push_back(ray);
643        }
644}
645
646
647int GvsPreprocessor::ProcessQueue()
648{
649        ++ mGvsStats.mGvsRuns;
650
651        int castSamples = 0;
652
653        while (!mRayQueue.empty())//&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) )
654        {
655                // handle next ray
656                VssRay *ray = mRayQueue.top();
657                mRayQueue.pop();
658               
659                const int newSamples = AdaptiveBorderSampling(*ray);
660
661                castSamples += newSamples;
662                // note: don't have to delete because handled by ray pool
663        }
664
665        /*if (mRayCaster->mVssRayPool.mIndex > mSamplesPerPass)
666        {
667                cout << "warning: new samples: " << castSamples << " " << "queue: "  << (int)mRayQueue.size() << endl;
668                Debug << "warning: new samples: " << castSamples << " " << "queue: "  << (int)mRayQueue.size() << endl;
669        }*/
670
671        return castSamples;
672}
673
674
675void ExportVssRays(Exporter *exporter, const VssRayContainer &vssRays)
676{
677        VssRayContainer vcRays, vcRays2, vcRays3;
678
679        VssRayContainer::const_iterator rit, rit_end = vssRays.end();
680
681        // prepare some rays for output
682        for (rit = vssRays.begin(); rit != rit_end; ++ rit)
683        {
684                //const float p = RandomValue(0.0f, (float)vssRays.size());
685
686                if (1)//(p < raysOut)
687                {
688                        if ((*rit)->mFlags & VssRay::BorderSample)
689                        {
690                                vcRays.push_back(*rit);
691                        }
692                        else if ((*rit)->mFlags & VssRay::ReverseSample)
693                        {
694                                vcRays2.push_back(*rit);
695                        }
696                        else
697                        {
698                                vcRays3.push_back(*rit);
699                        }       
700                }
701        }
702
703        exporter->ExportRays(vcRays, RgbColor(1, 0, 0));
704        exporter->ExportRays(vcRays2, RgbColor(0, 1, 0));
705        exporter->ExportRays(vcRays3, RgbColor(1, 1, 1));
706}
707
708
709void GvsPreprocessor::VisualizeViewCell(const ObjectContainer &objects)
710{
711    Intersectable::NewMail();
712        Material m;
713       
714        char str[64]; sprintf(str, "pass%06d.wrl", mProcessedViewCells);
715
716        Exporter *exporter = Exporter::GetExporter(str);
717        if (!exporter)
718                return;
719
720        ObjectContainer::const_iterator oit, oit_end = objects.end();
721
722        for (oit = objects.begin(); oit != oit_end; ++ oit)
723        {
724                Intersectable *intersect = *oit;
725               
726                m = RandomMaterial();
727                exporter->SetForcedMaterial(m);
728                exporter->ExportIntersectable(intersect);
729        }
730
731        cout << "vssrays: " << (int)mVssRays.size() << endl;
732        ExportVssRays(exporter, mVssRays);
733
734
735        /////////////////
736        //-- export view cell geometry
737
738        //exporter->SetWireframe();
739
740        m.mDiffuseColor = RgbColor(0, 1, 0);
741        exporter->SetForcedMaterial(m);
742
743        AxisAlignedBox3 bbox = mCurrentViewCell->GetMesh()->mBox;
744        exporter->ExportBox(bbox);
745        //exporter->SetFilled();
746
747        delete exporter;
748}
749
750
751void GvsPreprocessor::VisualizeViewCells()
752{
753        char str[64]; sprintf(str, "tmp/pass%06d_%04d-", mProcessedViewCells, mPass);
754                       
755        // visualization
756        if (mGvsStats.mPassContribution > 0)
757        {
758                const bool exportRays = true;
759                const bool exportPvs = true;
760
761                mViewCellsManager->ExportSingleViewCells(mObjects,
762                                                                                                 10,
763                                                                                                 false,
764                                                                                                 exportPvs,
765                                                                                                 exportRays,
766                                                                                                 1000,
767                                                                                                 str);
768        }
769
770        // remove pass samples
771        ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end();
772
773        for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit)
774        {
775                (*vit)->DelRayRefs();
776        }
777}
778
779
780void GvsPreprocessor::CompileViewCellsFromPointList()
781{
782        ViewCell::NewMail();
783
784        // Receive list of view cells from view cells manager
785        ViewCellPointsList *vcPoints = mViewCellsManager->GetViewCellPointsList();
786
787        vector<ViewCellPoints *>::const_iterator vit, vit_end = vcPoints->end();
788
789        for (vit = vcPoints->begin(); vit != vit_end; ++ vit)
790        {
791                ViewCellPoints *vp = *vit;
792
793                if (vp->first) // view cell  specified
794                {
795                        ViewCell *viewCell = vp->first;
796
797                        if (!viewCell->Mailed())
798                        {
799                                viewCell->Mail();
800                                mViewCells.push_back(viewCell);
801
802                                if (mViewCells.size() >= mMaxViewCells)
803                                        break;
804                        }
805                }
806                else // no view cell specified => compute view cells using view point
807                {
808                        SimpleRayContainer::const_iterator rit, rit_end = vp->second.end();
809
810                        for (rit = vp->second.begin(); rit != rit_end; ++ rit)
811                        {
812                                SimpleRay ray = *rit;
813
814                                ViewCell *viewCell = mViewCellsManager->GetViewCell(ray.mOrigin);
815
816                                if (viewCell && !viewCell->Mailed())
817                                {
818                                        viewCell->Mail();
819                                        mViewCells.push_back(viewCell);
820
821                                        if (mViewCells.size() >= mMaxViewCells)
822                                                break;
823                                }
824                        }
825                }
826        }
827}
828
829
830void GvsPreprocessor::CompileViewCellsList()
831{
832        if (!mViewCellsManager->GetViewCellPointsList()->empty())
833        {
834                cout << "processing view point list" << endl;
835                CompileViewCellsFromPointList();
836        }
837        else
838        {
839                ViewCell::NewMail();
840
841                while ((int)mViewCells.size() < mMaxViewCells)
842                {
843                        const int tries = 10000;
844                        int i = 0;
845
846                        for (i = 0; i < tries; ++ i)
847                        {
848                                const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f);
849
850                                ViewCell *viewCell = mViewCellsManager->GetViewCell(idx);
851
852                                if (!viewCell->Mailed())
853                                {
854                                        viewCell->Mail();
855                                        break;
856                                }
857
858                                mViewCells.push_back(viewCell);
859                        }
860
861                        if (i == tries)
862                        {
863                                cerr << "big error! no view cell found" << endl;
864                                break;
865                        }
866                }
867        }
868
869        cout << "\ncomputing list of " << mViewCells.size() << " view cells" << endl;
870}
871
872
873void GvsPreprocessor::IntersectWithViewCell()
874{
875        AxisAlignedBox3 box = mCurrentViewCell->GetBox();
876
877        int oldTrianglePvs = (int)mTrianglePvs.size();
878        int newKdObj = 0;
879
880        // compute pvs kd nodes that intersect view cell
881        ObjectContainer kdobjects;
882
883        // find intersecting objects not in pvs (i.e., only unmailed)
884        mKdTree->CollectKdObjects(box, kdobjects);
885
886        ObjectContainer pvsKdObjects;
887
888        ObjectContainer::const_iterator oit, oit_end = kdobjects.end();
889
890        for (oit = kdobjects.begin(); oit != oit_end; ++ oit)
891        {
892        KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit);
893       
894                myobjects.clear();
895                mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), myobjects);
896
897                // account for kd object pvs
898                bool addkdobj = false;
899
900                ObjectContainer::const_iterator oit, oit_end = myobjects.end();
901
902                for (oit = myobjects.begin(); oit != oit_end; ++ oit)
903                {
904                        TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit);
905             
906                        // test if the triangle itself intersects
907                        if (box.Intersects(triObj->GetItem()))
908                                addkdobj = AddTriangleObject(triObj);
909                }
910               
911                // add node to kd pvs
912                if (1 && addkdobj)
913                {
914                        ++ newKdObj;
915                        mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f);
916                        //mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f);
917                        if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt);
918                }
919        }
920
921        cout << "added " << (int)mTrianglePvs.size() - oldTrianglePvs << " triangles (" << newKdObj << " objects) by intersection" << endl;
922}
923
924
925void GvsPreprocessor::PerViewCellComputation()
926{
927        while (mCurrentViewCell = NextViewCell())
928        {
929                // hack: reset counters
930                ObjectContainer::const_iterator oit, oit_end = mObjects.end();
931
932                for (oit = mObjects.begin(); oit != oit_end; ++ oit)
933                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT;
934
935                mDistribution->SetViewCell(mCurrentViewCell);
936        ComputeViewCell();
937        }
938}
939
940
941void GvsPreprocessor::PerViewCellComputation2()
942{
943        while (1)
944        {
945                if (!mRendererWidget)
946                        continue;
947
948        mCurrentViewCell = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint());
949
950                // no valid view cell or view cell already computed
951                if (!mCurrentViewCell || !mCurrentViewCell->GetPvs().Empty() || !mRendererWidget->mComputeGVS)
952                        continue;
953
954                mRendererWidget->mComputeGVS = false;
955                // hack: reset counters
956                ObjectContainer::const_iterator oit, oit_end = mObjects.end();
957
958                for (oit = mObjects.begin(); oit != oit_end; ++ oit)
959                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT;
960
961                ComputeViewCell();
962                ++ mProcessedViewCells;
963        }
964}
965
966
967void GvsPreprocessor::StorePvs(const ObjectContainer &objectPvs)
968{
969        ObjectContainer::const_iterator oit, oit_end = objectPvs.end();
970
971        for (oit = objectPvs.begin(); oit != oit_end; ++ oit)
972        {
973                mCurrentViewCell->GetPvs().AddSample(*oit, 1);
974        }
975}
976
977
978void GvsPreprocessor::UpdatePvs(ViewCell *currentViewCell)
979{
980        ObjectPvs newPvs;
981        BvhLeaf::NewMail();
982
983        ObjectPvsIterator pit = currentViewCell->GetPvs().GetIterator();
984
985        // output PVS of view cell
986        while (pit.HasMoreEntries())
987        {               
988                Intersectable *intersect = pit.Next();
989
990                BvhLeaf *bv = intersect->mBvhLeaf;
991
992                if (!bv || bv->Mailed())
993                        continue;
994               
995                bv->Mail();
996
997                //m.mDiffuseColor = RgbColor(1, 0, 0);
998                newPvs.AddSampleDirty(bv, 1.0f);
999        }
1000
1001        newPvs.SimpleSort();
1002
1003        currentViewCell->SetPvs(newPvs);
1004}
1005
1006 
1007void GvsPreprocessor::GetObjectPvs(ObjectContainer &objectPvs) const
1008{
1009        BvhLeaf::NewMail();
1010
1011        objectPvs.reserve((int)mTrianglePvs.size());
1012
1013        ObjectContainer::const_iterator oit, oit_end = mTrianglePvs.end();
1014
1015        for (oit = mTrianglePvs.begin(); oit != oit_end; ++ oit)
1016        {
1017                Intersectable *intersect = *oit;
1018       
1019                BvhLeaf *bv = intersect->mBvhLeaf;
1020
1021                // hack: reset counter
1022                (*oit)->mCounter = NOT_ACCOUNTED_OBJECT;
1023
1024                if (!bv || bv->Mailed())
1025                        continue;
1026
1027                bv->Mail();
1028                objectPvs.push_back(bv);
1029        }
1030}
1031
1032
1033void GvsPreprocessor::GlobalComputation()
1034{
1035        int passSamples = 0;
1036        int oldContribution = 0;
1037
1038        while (mGvsStats.mTotalSamples < mTotalSamples)
1039        {
1040                mRayCaster->InitPass();
1041
1042                // Ray queue empty =>
1043                // cast a number of uniform samples to fill ray queue
1044                int newSamples = CastInitialSamples(mInitialSamples);
1045
1046                if (!mOnlyRandomSampling)
1047                        newSamples += ProcessQueue();
1048
1049                passSamples += newSamples;
1050                mGvsStats.mTotalSamples += newSamples;
1051
1052                if (passSamples % (mGvsSamplesPerPass + 1) == mGvsSamplesPerPass)
1053                {
1054                        ++ mPass;
1055
1056                        mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution;
1057
1058                        ////////
1059                        //-- stats
1060
1061                        //cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples << " of " << mTotalSamples << endl;
1062                        mGvsStats.mPass = mPass;
1063                        mGvsStats.Stop();
1064                        mGvsStats.Print(mGvsStatsStream);
1065
1066                        // reset
1067                        oldContribution = mGvsStats.mTotalContribution;
1068                        mGvsStats.mPassContribution = 0;
1069                        passSamples = 0;
1070
1071                        if (GVS_DEBUG)
1072                                VisualizeViewCells();
1073                }
1074        }
1075}
1076
1077
1078bool GvsPreprocessor::ComputeVisibility()
1079{
1080        cout << "Gvs Preprocessor started\n" << flush;
1081        const long startTime = GetTime();
1082
1083        //Randomize(0);
1084        mGvsStats.Reset();
1085        mGvsStats.Start();
1086
1087        if (!mLoadViewCells)
1088        {       
1089                /// construct the view cells from the scratch
1090                ConstructViewCells();
1091                // reset pvs already gathered during view cells construction
1092                mViewCellsManager->ResetPvs();
1093                cout << "finished view cell construction" << endl;
1094        }
1095
1096        if (mPerViewCell)
1097        {
1098#if 1
1099                // provide list of view cells to compute
1100                CompileViewCellsList();
1101
1102                // start per view cell gvs
1103                PerViewCellComputation();
1104#else
1105                PerViewCellComputation2();
1106
1107#endif
1108        }
1109        else
1110        {
1111                GlobalComputation();
1112        }
1113
1114        cout << "cast " << mGvsStats.mTotalSamples / (1e3f * TimeDiff(startTime, GetTime())) << "M single rays/s" << endl;
1115
1116        if (GVS_DEBUG)
1117        {
1118                Visualize();
1119                CLEAR_CONTAINER(mVssRays);
1120        }
1121       
1122        // export the preprocessed information to a file
1123        if (0 && mExportVisibility)
1124        {
1125                ExportPreprocessedData(mVisibilityFileName);
1126        }
1127       
1128        // compute the pixel error of this visibility solution
1129        if (mEvaluatePixelError)
1130        {
1131                ComputeRenderError();
1132        }
1133
1134        return true;
1135}
1136
1137
1138void GvsPreprocessor::DeterminePvsObjects(VssRayContainer &rays)
1139{
1140        // store triangle directly
1141        mViewCellsManager->DeterminePvsObjects(rays, true);
1142}
1143
1144
1145void GvsPreprocessor::Visualize()
1146{
1147        Exporter *exporter = Exporter::GetExporter("gvs.wrl");
1148
1149        if (!exporter)
1150                return;
1151       
1152        vector<VizStruct>::const_iterator vit, vit_end = vizContainer.end();
1153       
1154        for (vit = vizContainer.begin(); vit != vit_end; ++ vit)
1155        {
1156                exporter->SetWireframe();
1157                exporter->ExportPolygon((*vit).enlargedTriangle);
1158                //Material m;
1159                exporter->SetFilled();
1160                Polygon3 poly = Polygon3((*vit).originalTriangle);
1161                exporter->ExportPolygon(&poly);
1162        }
1163
1164        VssRayContainer::const_iterator rit, rit_end = mVssRays.end();
1165
1166        for (rit = mVssRays.begin(); rit != rit_end; ++ rit)
1167        {
1168                Intersectable *obj = (*rit)->mTerminationObject;
1169                exporter->ExportIntersectable(obj);
1170        }
1171
1172        ExportVssRays(exporter, mVssRays);
1173       
1174        delete exporter;
1175}
1176
1177
1178void GvsStatistics::Print(ostream &app) const
1179{
1180        app << "#ViewCells\n" << mViewCells << endl;
1181        app << "#Id\n" << mViewCellId << endl;
1182        app << "#Time\n" << mTimePerViewCell << endl;;
1183        app << "#TriPvs\n" << mTrianglePvs << endl;
1184        app << "#ObjectPvs\n" << mPerViewCellPvs << endl;
1185        app << "#UpdatedPvs\n" << (int)mPvsCost << endl;
1186
1187        app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl;
1188        app << "#RaysPerSec\n" << RaysPerSec() << endl;
1189       
1190        app << "#TotalPvs\n" << mTotalPvs << endl;
1191        app << "#TotalTime\n" << mTotalTime << endl;
1192        app << "#TotalSamples\n" << mTotalSamples << endl;
1193
1194        app << "#TotalTrianglePvs\n" << mTotalTrianglePvs << endl;
1195       
1196        if (0)
1197        {
1198                app << "#ReverseSamples\n" << mReverseSamples << endl;
1199                app << "#BorderSamples\n" << mBorderSamples << endl;
1200
1201                app << "#Pass\n" << mPass << endl;
1202                app << "#ScDiff\n" << mPassContribution << endl;
1203                app << "#GvsRuns\n" << mGvsRuns << endl;       
1204
1205                app     << "#SamplesContri\n" << mTotalContribution << endl;
1206        }
1207
1208        app << endl;
1209}
1210
1211
1212void GvsPreprocessor::ComputeViewCell()
1213{
1214        //if (mCurrentViewCell->GetId() != 499) return;
1215
1216        // clean up
1217        mTrianglePvs.clear();
1218
1219        mCurrentViewCell->GetMesh()->ComputeBoundingBox();
1220
1221        KdNode::NewMail();
1222
1223        const long startTime = GetTime();
1224
1225        cout << "\n***********************\n"
1226                << "computing view cell " << mProcessedViewCells
1227                << " (id: " << mCurrentViewCell->GetId() << ")" << endl;
1228        cout << "bb: " << mCurrentViewCell->GetBox() << endl;
1229
1230        mGvsStats.mPerViewCellSamples = 0;
1231
1232        int oldContribution = 0;
1233        int passSamples = 0;
1234       
1235        for (int i = 0; i < 0; ++ i)
1236                mGenericStats[i] = 0;
1237
1238        while (1)
1239        {
1240                int oldPvsSize = mCurrentViewCell->GetPvs().GetSize();
1241               
1242                mRayCaster->InitPass();
1243
1244                // Ray queue empty =>
1245                // cast a number of uniform samples to fill ray queue
1246                int newSamples = CastInitialSamples(mInitialSamples);
1247
1248                if (!mOnlyRandomSampling)
1249                {
1250                        int samplesPerRun = ProcessQueue();
1251                        newSamples += samplesPerRun;
1252                        //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " ";
1253                }
1254
1255                passSamples += newSamples;
1256        mGvsStats.mPerViewCellSamples += newSamples;
1257
1258                if (passSamples >= mGvsSamplesPerPass)
1259                {
1260                        if (GVS_DEBUG) VisualizeViewCell(mTrianglePvs);
1261
1262                        //const bool convertPerPass = true;
1263                        const bool convertPerPass = false;
1264
1265                        if (convertPerPass)
1266                        {       
1267                                int newObjects = ConvertObjectPvs();
1268
1269                                cout << "added " << newObjects << " triangles to triangle pvs" << endl;
1270                                mGvsStats.mTotalContribution += newObjects;
1271                        }
1272
1273                        ++ mPass;
1274                        mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution;
1275
1276
1277                        ////////
1278                        //-- stats
1279
1280                        mGvsStats.mPass = mPass;
1281
1282                        cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl;
1283                        cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl;
1284                        cout << "obj contri=" << mCurrentViewCell->GetPvs().GetSize() - oldPvsSize << " (of " << mMinContribution << ")" << endl;
1285
1286                        // termination criterium
1287                        if (mGvsStats.mPassContribution < mMinContribution)
1288                                break;
1289
1290                        // reset stats
1291                        oldContribution = mGvsStats.mTotalContribution;
1292                        mGvsStats.mPassContribution = 0;
1293                        passSamples = 0;
1294                }
1295        }
1296       
1297        // at last compute objects that directly intersect view cell
1298        IntersectWithViewCell();
1299
1300               
1301        ////////
1302        //-- stats
1303
1304        // timing
1305        mGvsStats.mTimePerViewCell = TimeDiff(startTime, GetTime()) * 1e-3f;
1306
1307        ComputeStats();
1308}
1309
1310
1311void GvsPreprocessor::ComputeStats()
1312{
1313        // compute pvs size using larger (bvh objects)
1314        // note: for kd pvs we had to do this during gvs computation
1315
1316        if (!mUseKdPvs)
1317        {
1318                ObjectContainer objectPvs;
1319
1320                // optain object pvs
1321                GetObjectPvs(objectPvs);
1322
1323                // add pvs
1324                ObjectContainer::const_iterator it, it_end = objectPvs.end();
1325
1326                for (it = objectPvs.begin(); it != it_end; ++ it)
1327                {
1328                        mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f);
1329                }
1330
1331                cout << "triangle pvs of " << (int)mTrianglePvs.size()
1332                        << " was converted to object pvs of " << (int)objectPvs.size() << endl;
1333
1334                mGvsStats.mPerViewCellPvs = (int)objectPvs.size();
1335                mGvsStats.mPvsCost = 0; // todo objectPvs.EvalPvsCost();
1336        }
1337        else if (0)
1338        {
1339                //KdNode::NewMail();
1340
1341                // compute pvs kd nodes that intersect view cell
1342                ObjectContainer mykdobjects;
1343
1344                // extract kd pvs
1345                ObjectContainer::const_iterator it, it_end = mTrianglePvs.end();
1346
1347                for (it = mTrianglePvs.begin(); it != it_end; ++ it)
1348                {
1349                        Intersectable *obj = *it;
1350                        // find intersecting objects not yet in pvs (i.e., only unmailed)
1351                        mKdTree->CollectKdObjects(obj->GetBox(), mykdobjects);
1352                }
1353
1354                // add pvs
1355                it_end = mykdobjects.end();
1356
1357                for (it = mykdobjects.begin(); it != it_end; ++ it)
1358                {
1359                        mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f);
1360                }
1361
1362                cout << "added " << (int)mykdobjects.size() << " new objects " << endl;
1363
1364                mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize();
1365                mGvsStats.mPvsCost = mCurrentViewCell->GetPvs().EvalPvsCost();
1366
1367        }
1368
1369        mGvsStats.mTrianglePvs = (int)mTrianglePvs.size();
1370
1371
1372        ////////////////
1373        // global values
1374
1375        mGvsStats.mViewCells = mProcessedViewCells;
1376        mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs;
1377        mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell;
1378    mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs;
1379        mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples;
1380
1381        mGvsStats.Stop();
1382        mGvsStats.Print(mGvsStatsStream);
1383
1384        cout << "id: " << mCurrentViewCell->GetId() << " pvs cost: "
1385             << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl;
1386}
1387
1388
1389ObjectContainer triangles;
1390
1391int GvsPreprocessor::ConvertObjectPvs()
1392{
1393        int newObjects = 0;
1394
1395        ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator();
1396
1397        triangles.clear();
1398
1399        // output PVS of view cell
1400        while (pit.HasMoreEntries())
1401        {               
1402                KdIntersectable *kdInt = static_cast<KdIntersectable *>(pit.Next());
1403
1404                mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), triangles);
1405
1406                ObjectContainer::const_iterator oit, oit_end = triangles.end();
1407
1408                for (oit = triangles.begin(); oit != oit_end; ++ oit)
1409                {
1410                        if (AddTriangleObject(*oit))
1411                                ++ newObjects;
1412                }
1413        }
1414
1415        return newObjects;
1416}
1417
1418
1419bool GvsPreprocessor::AddTriangleObject(Intersectable *triObj)
1420{
1421        if ((triObj->mCounter < ACCOUNTED_OBJECT))
1422        {
1423                triObj->mCounter += ACCOUNTED_OBJECT;
1424
1425                mTrianglePvs.push_back(triObj);
1426                //mDummyBuffer.push_back(mGvsStats.mGvsRuns);
1427                mGenericStats[0] = (int)mTrianglePvs.size();
1428                return true;
1429        }
1430
1431        return false;
1432}
1433
1434
1435
1436}
Note: See TracBrowser for help on using the repository browser.