source: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp @ 2742

Revision 2742, 47.9 KB checked in by mattausch, 16 years ago (diff)
RevLine 
[2583]1
[372]2#include "SceneGraph.h"
3#include "Exporter.h"
4#include "UnigraphicsParser.h"
5#include "X3dParser.h"
6#include "Preprocessor.h"
7#include "ViewCell.h"
8#include "Environment.h"
[439]9#include "ViewCellsManager.h"
[445]10#include "ViewCellBsp.h"
11#include "VspBspTree.h"
[469]12#include "RenderSimulator.h"
[496]13#include "GlRenderer.h"
[749]14#include "PlyParser.h"
[1020]15#include "SamplingStrategy.h"
[1233]16#include "VspTree.h"
17#include "OspTree.h"
[1221]18#include "ObjParser.h"
[1264]19#include "BvHierarchy.h"
[1279]20#include "HierarchyManager.h"
[1287]21#include "VssRay.h"
[1520]22#include "IntelRayCaster.h"
[2575]23#include "HavranRayCaster.h"
[1520]24#include "InternalRayCaster.h"
[1968]25#include "GlobalLinesRenderer.h"
[2183]26#include "ObjectsParser.h"
[2707]27#include "SepPlanesBox3.h"
[1264]28
[1287]29
[1292]30#define DEBUG_RAYCAST 0
[1584]31#define SHOW_RAYCAST_TIMING 1
[1292]32
[2183]33using namespace std;
[1292]34
[863]35namespace GtpVisibilityPreprocessor {
[860]36
37
[2710]38static int sCurrentDynamicId = 0;
39
40
[2544]41inline static bool ilt(Intersectable *obj1, Intersectable *obj2)
42{
43        return obj1->mId < obj2->mId;
44}
45
46
[2187]47Preprocessor *preprocessor = NULL;
[1867]48 
[752]49
[372]50Preprocessor::Preprocessor():
51mKdTree(NULL),
[409]52mBspTree(NULL),
[445]53mVspBspTree(NULL),
[1002]54mViewCellsManager(NULL),
[1251]55mRenderSimulator(NULL),
[1279]56mPass(0),
[1520]57mSceneGraph(NULL),
[1613]58mRayCaster(NULL),
[1926]59mStopComputation(false),
[1968]60mThread(NULL),
[2076]61mGlobalLinesRenderer(NULL),
[2574]62mUseHwGlobalLines(false),
[2709]63mTotalRaysCast(0),
64mSynchronize(false)
[308]65{
[1004]66        Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer);
[538]67 
[840]68        // renderer will be constructed when the scene graph and viewcell manager will be known
69        renderer = NULL;
[1785]70       
[1004]71        Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlDebugger", mUseGlDebugger);
[1379]72        Environment::GetSingleton()->GetBoolValue("Preprocessor.loadMeshes", mLoadMeshes);
[1004]73        Environment::GetSingleton()->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish);
74        Environment::GetSingleton()->GetBoolValue("Preprocessor.computeVisibility", mComputeVisibility);
75        Environment::GetSingleton()->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace);
76        Environment::GetSingleton()->GetBoolValue("Preprocessor.exportVisibility", mExportVisibility );
[1520]77       
[871]78        char buffer[256];
[1004]79        Environment::GetSingleton()->GetStringValue("Preprocessor.visibilityFile",  buffer);
[871]80        mVisibilityFileName = buffer;
[1771]81       
82        Environment::GetSingleton()->GetStringValue("Preprocessor.stats",  buffer);
83        mStats.open(buffer);
[2048]84               
[1749]85        Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilityFilter", mApplyVisibilityFilter);
[1004]86        Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter",
[1695]87                                                                                          mApplyVisibilitySpatialFilter );
[1004]88        Environment::GetSingleton()->GetFloatValue("Preprocessor.visibilityFilterWidth", mVisibilityFilterWidth);
[878]89
[1695]90        Environment::GetSingleton()->GetBoolValue("Preprocessor.exportObj", mExportObj);
91       
[1723]92        Environment::GetSingleton()->GetBoolValue("Preprocessor.useViewSpaceBox", mUseViewSpaceBox);
93
[1900]94        Environment::GetSingleton()->GetBoolValue("Preprocessor.Export.rays", mExportRays);
[2008]95        Environment::GetSingleton()->GetBoolValue("Preprocessor.Export.animation", mExportAnimation);
[1900]96        Environment::GetSingleton()->GetIntValue("Preprocessor.Export.numRays", mExportNumRays);
97
[1966]98        Environment::GetSingleton()->GetIntValue("Preprocessor.samplesPerPass", mSamplesPerPass);
99        Environment::GetSingleton()->GetIntValue("Preprocessor.totalSamples", mTotalSamples);
[2046]100        Environment::GetSingleton()->GetIntValue("Preprocessor.totalTime", mTotalTime);
[1966]101        Environment::GetSingleton()->GetIntValue("Preprocessor.samplesPerEvaluation",
102                                                                                         mSamplesPerEvaluation);
103
[1695]104        Debug << "******* Preprocessor Options **********" << endl;
[840]105        Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl;
[1379]106        Debug << "load meshes: " << mLoadMeshes << endl;
[1695]107        Debug << "load meshes: " << mLoadMeshes << endl;
108        Debug << "export obj: " << mExportObj << endl;
[1723]109        Debug << "use view space box: " << mUseViewSpaceBox << endl;
[2048]110
111        cout << "samples per pass " << mSamplesPerPass << endl;
[372]112}
113
114
115Preprocessor::~Preprocessor()
116{
[1291]117        cout << "cleaning up" << endl;
[752]118
[1291]119        cout << "Deleting view cells manager ... \n";
120        DEL_PTR(mViewCellsManager);
121        cout << "done.\n";
[2047]122       
[1291]123        cout << "Deleting bsp tree ... \n";
124        DEL_PTR(mBspTree);
[1924]125        cout << "done.\n";
[752]126
[1924]127        cout << "Deleting kd tree ...\n";
[1291]128        DEL_PTR(mKdTree);
129        cout << "done.\n";
[752]130
[1923]131        cout << "Deleting vspbsp tree ... \n";
[1291]132        DEL_PTR(mVspBspTree);
133        cout << "done.\n";
[1002]134
[1923]135        cout << "Deleting scene graph ... \n";
[1291]136        DEL_PTR(mSceneGraph);
137        cout << "done.\n";
138
[2017]139        cout << "deleting render simulator ... \n";
[1291]140        DEL_PTR(mRenderSimulator);
[2017]141        mRenderSimulator = NULL;
[2609]142
[2017]143        cout << "deleting renderer ... \n";
[1291]144        DEL_PTR(renderer);
[2017]145        renderer = NULL;
[2609]146
[2017]147        cout << "deleting ray caster ... \n";
[1523]148        DEL_PTR(mRayCaster);
[1999]149
[1990]150#ifdef USE_CG
[2017]151        cout << "deleting global lines renderer ... \n";
[1968]152        DEL_PTR(mGlobalLinesRenderer);
[1990]153#endif
[2017]154        cout << "finished" << endl;
[372]155}
156
[1521]157
158GlRendererBuffer *Preprocessor::GetRenderer()
159{
160        return renderer;
161}
162
163
[387]164
165
[1926]166void Preprocessor::SetThread(PreprocessorThread *t)
167{
168        mThread = t;
169}
170
171
172PreprocessorThread *Preprocessor::GetThread() const
173{
174        return mThread;
175}
176
177
[2183]178bool Preprocessor::LoadBinaryObj(const string &filename,
[2600]179                                                                 SceneGraphLeaf *root,
[2621]180                                                                 vector<FaceParentInfo> *parents,
181                                                                 float scale)
[1655]182{
[2452]183        //ifstream inStream(filename, ios::binary);
184        igzstream inStream(filename.c_str());
[1658]185       
[2452]186        if (!inStream.is_open())
[1655]187                return false;
188
[1658]189        cout << "binary obj dump available, loading " << filename.c_str() << endl;
[2003]190       
[2004]191        // read in triangle size
192        int numTriangles;
193
[2614]194        const int t = 500000;
[2452]195        inStream.read(reinterpret_cast<char *>(&numTriangles), sizeof(int));
[2004]196        root->mGeometry.reserve(numTriangles);
[2572]197        cout << "loading " << numTriangles << " triangles (" << numTriangles *
198                (sizeof(TriangleIntersectable) + sizeof(TriangleIntersectable *)) /
199                (1024 * 1024) << " MB)" << endl;
[2003]200
[2004]201        int i = 0;
[2572]202
[1655]203        while (1)
204        {
205                Triangle3 tri;
206               
[2452]207                inStream.read(reinterpret_cast<char *>(tri.mVertices + 0), sizeof(Vector3));
208                inStream.read(reinterpret_cast<char *>(tri.mVertices + 1), sizeof(Vector3));
209                inStream.read(reinterpret_cast<char *>(tri.mVertices + 2), sizeof(Vector3));
[2005]210
[2621]211                if (scale > 0.0f)
212                {
213                        tri.mVertices[0] *= scale;
214                        tri.mVertices[1] *= scale;
215                        tri.mVertices[2] *= scale;
216                }
217
[1655]218                // end of file reached
[2452]219                if (inStream.eof())
[1655]220                        break;
221
222                TriangleIntersectable *obj = new TriangleIntersectable(tri);
223                root->mGeometry.push_back(obj);
[2005]224               
[2614]225                if ((i ++) % t == t)
[2005]226                         cout<<"\r"<<i<<"/"<<numTriangles<<"\r";
[1655]227        }
228       
[2004]229        if (i != numTriangles)
230        {
231                cout << "warning: triangle size does not match with loaded triangle size" << endl;
232                return false;
233        }
234
235        cout << "loaded " << numTriangles << " triangles" << endl;
236
[1655]237        return true;
238}
239
240
[2601]241bool Preprocessor::ExportBinaryObj(const string &filename, SceneGraphLeaf *root)
[1658]242{
243        ogzstream samplesOut(filename.c_str());
[2004]244
[1658]245        if (!samplesOut.is_open())
246                return false;
247
[2004]248        int numTriangles = (int)root->mGeometry.size();
249
250        samplesOut.write(reinterpret_cast<char *>(&numTriangles), sizeof(int));
251
[1658]252        ObjectContainer::const_iterator oit, oit_end = root->mGeometry.end();
253
254        for (oit = root->mGeometry.begin(); oit != oit_end; ++ oit)
255        {
256                Intersectable *obj = *oit;
257
258                if (obj->Type() == Intersectable::TRIANGLE_INTERSECTABLE)
259                {
[2017]260                        Triangle3 tri = static_cast<TriangleIntersectable *>(obj)->GetItem();
[1658]261
262                        samplesOut.write(reinterpret_cast<char *>(tri.mVertices + 0), sizeof(Vector3));
263                        samplesOut.write(reinterpret_cast<char *>(tri.mVertices + 1), sizeof(Vector3));
264                        samplesOut.write(reinterpret_cast<char *>(tri.mVertices + 2), sizeof(Vector3));
265                }
266                else
267                {
268                        cout << "not implemented intersectable type " << obj->Type() << endl;
269                }
270        }
271
[2004]272        cout << "exported " << numTriangles << " triangles" << endl;
273
[1658]274        return true;
275}
276
[1695]277
[2342]278bool Preprocessor::ExportObj(const string &filename, const ObjectContainer &objects)
[1695]279{
280        ofstream samplesOut(filename.c_str());
281
282        if (!samplesOut.is_open())
283                return false;
284
285        ObjectContainer::const_iterator oit, oit_end = objects.end();
286
[2004]287        //AxisAlignedBox3 bbox = mSceneGraph->GetBox(); bbox.Enlarge(30.0);
[1695]288        for (oit = objects.begin(); oit != oit_end; ++ oit)
289        {
290                Intersectable *obj = *oit;
291
292                if (obj->Type() == Intersectable::TRIANGLE_INTERSECTABLE)
293                {
[2017]294                        Triangle3 tri = static_cast<TriangleIntersectable *>(obj)->GetItem();
[2004]295                        //if (!(bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2])))continue;
296                       
297                        samplesOut << "v " << tri.mVertices[0].x << " " << tri.mVertices[0].y << " " << tri.mVertices[0].z << endl;
298                        samplesOut << "v " << tri.mVertices[1].x << " " << tri.mVertices[1].y << " " << tri.mVertices[1].z << endl;
299                        samplesOut << "v " << tri.mVertices[2].x << " " << tri.mVertices[2].y << " " << tri.mVertices[2].z << endl;
[1701]300                        //}
[1695]301                }
302                else
303                {
304                        cout << "not implemented intersectable type " << obj->Type() << endl;
305                }
306        }
307
308        // write faces
309        int i = 1;
[1713]310        for (oit = objects.begin(); oit != oit_end; ++ oit)
[1695]311        {
312                Intersectable *obj = *oit;
313                if (obj->Type() == Intersectable::TRIANGLE_INTERSECTABLE)
314                {
[2017]315                        //Triangle3 tri = static_cast<TriangleIntersectable *>(obj)->GetItem();
[2004]316                        //if (!(bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2]))) continue;
317                       
[2017]318                        Triangle3 tri = static_cast<TriangleIntersectable *>(obj)->GetItem();
[2004]319                        samplesOut << "f " << i << " " << i + 1 << " " << i + 2 << endl;
320                        i += 3;
[1695]321                }
322                else
323                {
324                        cout << "not implemented intersectable type " << obj->Type() << endl;
325                }
326        }
327
328        return true;
329
330}
331
[1658]332
333
[2710]334Intersectable *Preprocessor::GetParentObject(int index) const
[1786]335{
[2003]336        if (index < 0)
337        {
[2004]338                //cerr << "Warning: triangle index smaller zero! " << index << endl;
[2003]339                return NULL;
340        }
[1786]341       
342        if (!mFaceParents.empty())
343        {
344                if (index >= (int)mFaceParents.size())
345                {
[1978]346                        cerr << "Warning: triangle index out of range! " << index << endl;
[1786]347                        return NULL;
348                }
349                else
350                {
351                        return mFaceParents[index].mObject;
352                }
353        }
354        else
[2003]355        {
[2710]356                return mObjects[index];
[2003]357        }
[1786]358}
359
360
361Vector3 Preprocessor::GetParentNormal(const int index) const
362{
363        if (!mFaceParents.empty())
364        {
365                return mFaceParents[index].mObject->GetNormal(mFaceParents[index].mFaceIndex);
366        }       
367        else
368        {
369                return mObjects[index]->GetNormal(0);
370        }
371}
372
373
[372]374bool
[2342]375Preprocessor::LoadScene(const string &filename)
[372]376{
[1655]377    // use leaf nodes of the original spatial hierarchy as occludees
[508]378        mSceneGraph = new SceneGraph;
[372]379 
[508]380        Parser *parser;
[387]381        vector<string> filenames;
[1404]382        const int files = SplitFilenames(filename, filenames);
[712]383        cout << "number of input files: " << files << endl;
[2183]384
[387]385        bool result = false;
[1695]386        bool isObj = false;
[1344]387
388        // root for different files
[2601]389        mSceneGraph->SetRoot(new SceneGraphInterior());
[1344]390
[1404]391        // intel ray caster can only trace triangles
[1520]392        int rayCastMethod;
[2575]393        Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod",
394                                                 rayCastMethod);
395
[1827]396        vector<FaceParentInfo> *fi =
[2583]397          ((rayCastMethod == RayCaster::INTEL_RAYCASTER ||
398                rayCastMethod == RayCaster::HAVRAN_RAYCASTER
399                ) && mLoadMeshes) ?
[1867]400          &mFaceParents : NULL;
[2583]401       
[1658]402        if (files == 1)
[2544]403        {
[2601]404                SceneGraphLeaf *leaf = new SceneGraphLeaf();
405
[387]406                if (strstr(filename.c_str(), ".x3d"))
[2544]407                {
[1655]408                        parser = new X3dParser;
[2601]409                       
[1658]410                        result = parser->ParseFile(filename,
[2601]411                                                                           leaf,
412                                                                           mLoadMeshes,
413                                                                           fi);
[1658]414                        delete parser;
[1655]415                }
[1658]416                else if (strstr(filename.c_str(), ".ply") || strstr(filename.c_str(), ".plb"))
[1655]417                {
[1658]418                        parser = new PlyParser;
[1655]419
[1658]420                        result = parser->ParseFile(filename,
[2601]421                                leaf,
[2544]422                                mLoadMeshes,
423                                fi);
[1658]424                        delete parser;
[1655]425                }
[1658]426                else if (strstr(filename.c_str(), ".obj"))
427                {
[1695]428                        isObj = true;
429
[1658]430                        // hack: load binary dump
[2004]431                        const string bnFile = ReplaceSuffix(filename, ".obj", ".bn");
[2544]432
[1658]433                        if (!mLoadMeshes)
434                        {
[2601]435                                result = LoadBinaryObj(bnFile, leaf, fi);
[1658]436                        }
437
[2004]438                        // parse obj
[2544]439                        if (!result)
[1658]440                        {
441                                cout << "no binary dump available or loading full meshes, parsing file" << endl;
442                                parser = new ObjParser;
[2544]443
[2601]444                                result = parser->ParseFile(filename, leaf, mLoadMeshes, fi);
[2544]445
[2601]446                                cout << "loaded " << (int)leaf->mGeometry.size() << " entities" << endl;
[2183]447
[1658]448                                // only works for triangles
[2004]449                                if (result && !mLoadMeshes)
[1658]450                                {
[2004]451                                        cout << "exporting binary obj to " << bnFile << "... " << endl;
[2183]452
[2601]453                                        ExportBinaryObj(bnFile, leaf);
[2544]454
[1658]455                                        cout << "finished" << endl;
456                                }
[1655]457
[1658]458                                delete parser;
459                        }
460                }
461                else
462                {
463                        parser = new UnigraphicsParser;
[2601]464                        result = parser->ParseFile(filename, leaf, mLoadMeshes, fi);
[1658]465                        delete parser;
466                }
[2544]467
[2601]468                if (result)
469                {
470                        mSceneGraph->GetRoot()->mChildren.push_back(leaf);
471                }
472
[1658]473                cout << filename << endl;
[1404]474        }
[1658]475        else
476        {
[1404]477                vector<string>::const_iterator fit, fit_end = filenames.end();
[2544]478
[1404]479                for (fit = filenames.begin(); fit != fit_end; ++ fit)
480                {
481                        const string filename = *fit;
[1328]482
[1404]483                        cout << "parsing file " << filename.c_str() << endl;
484                        if (strstr(filename.c_str(), ".x3d"))
485                                parser = new X3dParser;
486                        else
487                                parser = new UnigraphicsParser;
488
[2601]489                        SceneGraphLeaf *node = new SceneGraphLeaf();
490
[1695]491                        const bool success =
492                                parser->ParseFile(filename, node, mLoadMeshes, fi);
[1404]493
494                        if (success)
495                        {
496                                mSceneGraph->GetRoot()->mChildren.push_back(node);
497                                result = true; // at least one file parsed
498                        }
499
[1713]500                        // temporare hack
[1701]501                        //if (!strstr(filename.c_str(), "plane")) mSceneGraph->GetRoot()->UpdateBox();
502
[1404]503                        delete parser;
[387]504                }
505        }
[2544]506
[752]507        if (result)
[2544]508        { 
[1020]509                int intersectables, faces;
510                mSceneGraph->GetStatistics(intersectables, faces);
[1344]511 
[1020]512                cout<<filename<<" parsed successfully."<<endl;
513                cout<<"#NUM_OBJECTS (Total numner of objects)\n"<<intersectables<<endl;
514                cout<<"#NUM_FACES (Total numner of faces)\n"<<faces<<endl;
[1701]515               
[1697]516                mObjects.reserve(intersectables);
[2601]517                mSceneGraph->CollectObjects(mObjects);
[2544]518       
519                mSceneGraph->AssignObjectIds();
520
[1328]521                mSceneGraph->GetRoot()->UpdateBox();
[1713]522                               
523                cout << "finished loading" << endl;
[387]524        }
[2700]525
[492]526        return result;
[372]527}
528
529bool
[2342]530Preprocessor::ExportPreprocessedData(const string &filename)
[372]531{
[1486]532        mViewCellsManager->ExportViewCells(filename, true, mObjects);
533        return true;
[372]534}
535
[1486]536
[372]537bool
[871]538Preprocessor::PostProcessVisibility()
539{
540 
[904]541  if (mApplyVisibilityFilter || mApplyVisibilitySpatialFilter) {
[997]542        cout<<"Applying visibility filter ...";
[1002]543        cout<<"filter width = " << mVisibilityFilterWidth << endl;
[904]544       
[1002]545        if (!mViewCellsManager)
[1199]546          return false;
547       
[2076]548       
[871]549        mViewCellsManager->ApplyFilter(mKdTree,
[2076]550                                                                   mApplyVisibilityFilter ?
551                                                                   mVisibilityFilterWidth : -1.0f,
552                                                                   mApplyVisibilitySpatialFilter ?
553                                                                   mVisibilityFilterWidth : -1.0f);
[997]554        cout << "done." << endl;
[871]555  }
556 
557  // export the preprocessed information to a file
[2053]558  if (1 && mExportVisibility)
[1486]559  {
560          ExportPreprocessedData(mVisibilityFileName);
561  }
562
[871]563  return true;
564}
565
566
567bool
[372]568Preprocessor::BuildKdTree()
569{
570  mKdTree = new KdTree;
[1344]571
[372]572  // add mesh instances of the scene graph to the root of the tree
573  KdLeaf *root = (KdLeaf *)mKdTree->GetRoot();
[1344]574       
[2601]575  mSceneGraph->CollectObjects(root->mObjects);
[1344]576 
[1415]577  const long startTime = GetTime();
[1201]578  cout << "building kd tree ... " << endl;
[1344]579
[372]580  mKdTree->Construct();
[2582]581  sceneBox = mKdTree->GetBox();
[1344]582
[1415]583  cout << "finished kd tree construction in " << TimeDiff(startTime, GetTime()) * 1e-3
584           << " secs " << endl;
[1344]585
[372]586  return true;
587}
588
[1415]589
[372]590void
591Preprocessor::KdTreeStatistics(ostream &s)
592{
593  s<<mKdTree->GetStatistics();
594}
595
596void
597Preprocessor::BspTreeStatistics(ostream &s)
598{
599        s << mBspTree->GetStatistics();
600}
601
602bool
[2342]603Preprocessor::Export( const string &filename,
[2544]604                                         const bool scene,
605                                         const bool kdtree
606                                         )
[372]607{
[2544]608        Exporter *exporter = Exporter::GetExporter(filename);
[372]609
[2544]610        if (exporter) {
611                if (2 && scene)
612                        exporter->ExportScene(mSceneGraph->GetRoot());
[372]613
[2544]614                if (1 && kdtree) {
615                        exporter->SetWireframe();
616                        exporter->ExportKdTree(*mKdTree);
617                }
[372]618
[2544]619                delete exporter;
620                return true;
621        }
622
623        return false;
[372]624}
[429]625
[508]626
[463]627bool Preprocessor::PrepareViewCells()
628{
[2660]629#if 0
[2543]630        // load the view cells assigning the found objects to the pvss
631        cerr << "loading binary view cells" << endl;
632        ViewCellsManager *dummyViewCellsManager =
633                LoadViewCellsBinary("test.vc", mObjects, false, NULL);
634
635    //cerr << "reexporting the binary view cells" << endl;
636        //dummyViewCellsManager->ExportViewCellsBinary("outvc.xml.gz", true, mObjects);
637       
638        return false;
639#endif
640
[1523]641        ///////
[577]642        //-- parse view cells construction method
[1563]643
[1004]644        Environment::GetSingleton()->GetBoolValue("ViewCells.loadFromFile", mLoadViewCells);
[577]645        char buf[100];
[1585]646
[2172]647        if (mLoadViewCells)
[997]648        {       
[2183]649               
650#ifdef USE_BIT_PVS
651                // HACK: for kd pvs, set pvs size to maximal number of kd nodes
652                vector<KdLeaf *> leaves;
653                preprocessor->mKdTree->CollectLeaves(leaves);
654
655                ObjectPvs::SetPvsSize((int)leaves.size());
656#endif
657
[2172]658                Environment::GetSingleton()->GetStringValue("ViewCells.filename", buf);
[2183]659                cout << "loading objects from " << buf << endl;
[2117]660
[2703]661                // load scene objects which are the entities used as pvs entries
[2183]662                ObjectContainer pvsObjects;
[2709]663                if (1) LoadObjects(buf, pvsObjects, mObjects);
[2117]664
[2700]665                const bool finalizeViewCells = true;
[2183]666                cout << "loading view cells from " << buf << endl;
[2660]667               
[2183]668                mViewCellsManager = ViewCellsManager::LoadViewCells(buf,
669                                                                                                                        pvsObjects,
670                                                                                                                        mObjects,
671                                                                                                                        finalizeViewCells,
672                                                                                                                        NULL);
673
[1740]674                cout << "view cells loaded." << endl<<flush;
675
676                if (!mViewCellsManager)
677                {
[2072]678                        cerr << "no view cells manager could be loaded" << endl;
[1740]679                        return false;
680                }
[577]681        }
682        else
683        {
[2543]684                // parse type of view cells manager
[1004]685                Environment::GetSingleton()->GetStringValue("ViewCells.type", buf);             
[1740]686                mViewCellsManager = CreateViewCellsManager(buf);
[1112]687
[2700]688                // default view space is the extent of the scene
689                AxisAlignedBox3 viewSpaceBox;
690
[1723]691                if (mUseViewSpaceBox)
[1563]692                {
[2700]693                        viewSpaceBox = mSceneGraph->GetBox();
[1723]694
[1563]695                        // use a small box outside of the scene
[1723]696                        viewSpaceBox.Scale(Vector3(0.15f, 0.3f, 0.5f));
[2700]697                        //viewSpaceBox.Translate(Vector3(Magnitude(mSceneGraph->GetBox().Size()) * 0.5f, 0, 0));
[1723]698                        viewSpaceBox.Translate(Vector3(Magnitude(mSceneGraph->GetBox().Size()) * 0.3f, 0, 0));
699                        mViewCellsManager->SetViewSpaceBox(viewSpaceBox);
[1563]700                }
[2700]701                else
702                {
703                        viewSpaceBox = mSceneGraph->GetBox();
704                        mViewCellsManager->SetViewSpaceBox(viewSpaceBox);
705                }
706
[1545]707                bool loadVcGeometry;
708                Environment::GetSingleton()->GetBoolValue("ViewCells.loadGeometry", loadVcGeometry);
709
710                bool extrudeBaseTriangles;
711                Environment::GetSingleton()->GetBoolValue("ViewCells.useBaseTrianglesAsGeometry", extrudeBaseTriangles);
712
713                char vcGeomFilename[100];
714                Environment::GetSingleton()->GetStringValue("ViewCells.geometryFilename", vcGeomFilename);
[1740]715
[1940]716                // create view cells from specified geometry
[1627]717                if (loadVcGeometry)
[1545]718                {
[1627]719                        if (mViewCellsManager->GetType() == ViewCellsManager::BSP)
[1545]720                        {
[1627]721                                if (!mViewCellsManager->LoadViewCellsGeometry(vcGeomFilename, extrudeBaseTriangles))
722                                        cerr << "loading view cells geometry failed" << endl;
[1545]723                        }
[1627]724                        else
725                        {
726                                cerr << "loading view cells geometry is not implemented for this manager" << endl;
727                        }
[1545]728                }
[577]729        }
[1740]730
[2710]731
[1486]732        ////////
[1523]733        //-- evaluation of render cost heuristics
[1768]734
[473]735        float objRenderCost = 0, vcOverhead = 0, moveSpeed = 0;
736
[1004]737        Environment::GetSingleton()->GetFloatValue("Simulation.objRenderCost",objRenderCost);
738        Environment::GetSingleton()->GetFloatValue("Simulation.vcOverhead", vcOverhead);
739        Environment::GetSingleton()->GetFloatValue("Simulation.moveSpeed", moveSpeed);
[1740]740
[473]741        mRenderSimulator =
742                new RenderSimulator(mViewCellsManager, objRenderCost, vcOverhead, moveSpeed);
[440]743
[480]744        mViewCellsManager->SetRenderer(mRenderSimulator);
[1581]745        mViewCellsManager->SetPreprocessor(this);
[1940]746
[463]747        return true;
[490]748}
749
[1292]750 
[1563]751bool Preprocessor::ConstructViewCells()
[1292]752{
[1627]753        // construct view cells using it's own set of samples
754        mViewCellsManager->Construct(this);
755
756        // visualizations and statistics
757        Debug << "finished view cells:" << endl;
758        mViewCellsManager->PrintStatistics(Debug);
759
760        return true;
[1292]761}
[490]762
[1294]763
[575]764ViewCellsManager *Preprocessor::CreateViewCellsManager(const char *name)
765{
[1264]766        ViewCellsTree *vcTree = new ViewCellsTree;
767
[575]768        if (strcmp(name, "kdTree") == 0)
769        {
[1264]770                mViewCellsManager = new KdViewCellsManager(vcTree, mKdTree);
[575]771        }
772        else if (strcmp(name, "bspTree") == 0)
773        {
774                Debug << "view cell type: Bsp" << endl;
775
[577]776                mBspTree = new BspTree();
[1264]777                mViewCellsManager = new BspViewCellsManager(vcTree, mBspTree);
[575]778        }
779        else if (strcmp(name, "vspBspTree") == 0)
780        {
781                Debug << "view cell type: VspBsp" << endl;
782
[1004]783                mVspBspTree = new VspBspTree();
[1264]784                mViewCellsManager = new VspBspViewCellsManager(vcTree, mVspBspTree);
[575]785        }
[1006]786        else if (strcmp(name, "vspOspTree") == 0)
[575]787        {
[1421]788                Debug << "view cell type: VspOsp" << endl;
[1288]789                char buf[100];         
790                Environment::GetSingleton()->GetStringValue("Hierarchy.type", buf);     
[1022]791
[1740]792                mViewCellsManager = new VspOspViewCellsManager(vcTree, buf);
[575]793        }
[1421]794        else if (strcmp(name, "sceneDependent") == 0) //TODO
[575]795        {
[1143]796                Debug << "view cell type: Bsp" << endl;
[1421]797               
[575]798                mBspTree = new BspTree();
[1264]799                mViewCellsManager = new BspViewCellsManager(vcTree, mBspTree);
[575]800        }
801        else
802        {
[664]803                cerr << "Wrong view cells type " << name << "!!!" << endl;
[575]804                exit(1);
805        }
806
807        return mViewCellsManager;
808}
809
810
[491]811// use ascii format to store rays
812#define USE_ASCII 0
813
814
[2342]815bool Preprocessor::LoadKdTree(const string &filename)
[1197]816{
[1414]817        mKdTree = new KdTree();
[2539]818        return mKdTree->ImportBinTree(filename.c_str(), mObjects);
[1197]819}
820
[1414]821
[2342]822bool Preprocessor::ExportKdTree(const string &filename)
[1197]823{
[1414]824        return mKdTree->ExportBinTree(filename.c_str());
[1197]825}
826
827
[490]828bool Preprocessor::LoadSamples(VssRayContainer &samples,
829                                                           ObjectContainer &objects) const
830{
831        std::stable_sort(objects.begin(), objects.end(), ilt);
832        char fileName[100];
[1004]833        Environment::GetSingleton()->GetStringValue("Preprocessor.samplesFilename", fileName);
[490]834       
[491]835    Vector3 origin, termination;
[2709]836        // HACK: needed only for lower_bound algorithm to find the intersected objects
[491]837        MeshInstance sObj(NULL);
838        MeshInstance tObj(NULL);
[490]839
[491]840#if USE_ASCII
[2452]841        ifstream inStream(fileName);
842        if (!inStream.is_open())
[490]843                return false;
844
845        string buf;
[2452]846        while (!(getline(inStream, buf)).eof())
[490]847        {
[491]848                sscanf(buf.c_str(), "%f %f %f %f %f %f %d %d",
[490]849                           &origin.x, &origin.y, &origin.z,
[491]850                           &termination.x, &termination.y, &termination.z,
851                           &(sObj.mId), &(tObj.mId));
[490]852               
[491]853                Intersectable *sourceObj = NULL;
854                Intersectable *termObj = NULL;
855               
856                if (sObj.mId >= 0)
[490]857                {
858                        ObjectContainer::iterator oit =
[491]859                                lower_bound(objects.begin(), objects.end(), &sObj, ilt);
860                        sourceObj = *oit;
861                }
862               
863                if (tObj.mId >= 0)
864                {
865                        ObjectContainer::iterator oit =
866                                lower_bound(objects.begin(), objects.end(), &tObj, ilt);
867                        termObj = *oit;
868                }
[490]869
[491]870                samples.push_back(new VssRay(origin, termination, sourceObj, termObj));
871        }
872#else
[2452]873        ifstream inStream(fileName, ios::binary);
874        if (!inStream.is_open())
[491]875                return false;
876
877        while (1)
878        {
[2452]879                 inStream.read(reinterpret_cast<char *>(&origin), sizeof(Vector3));
880                 inStream.read(reinterpret_cast<char *>(&termination), sizeof(Vector3));
881                 inStream.read(reinterpret_cast<char *>(&(sObj.mId)), sizeof(int));
882                 inStream.read(reinterpret_cast<char *>(&(tObj.mId)), sizeof(int));
[491]883               
[2452]884                 if (inStream.eof())
[491]885                        break;
886
887                Intersectable *sourceObj = NULL;
888                Intersectable *termObj = NULL;
889               
890                if (sObj.mId >= 0)
891                {
892                        ObjectContainer::iterator oit =
893                                lower_bound(objects.begin(), objects.end(), &sObj, ilt);
894                        sourceObj = *oit;
[490]895                }
[491]896               
897                if (tObj.mId >= 0)
[490]898                {
[491]899                        ObjectContainer::iterator oit =
900                                lower_bound(objects.begin(), objects.end(), &tObj, ilt);
901                        termObj = *oit;
[490]902                }
[491]903
904                samples.push_back(new VssRay(origin, termination, sourceObj, termObj));
[490]905        }
[1779]906#endif
[491]907
[2452]908        inStream.close();
[490]909
910        return true;
911}
912
[508]913
914bool Preprocessor::ExportSamples(const VssRayContainer &samples) const
[490]915{
[491]916        char fileName[100];
[1004]917        Environment::GetSingleton()->GetStringValue("Preprocessor.samplesFilename", fileName);
[491]918       
[490]919
920        VssRayContainer::const_iterator it, it_end = samples.end();
921       
[491]922#if USE_ASCII
923        ofstream samplesOut(fileName);
[490]924        if (!samplesOut.is_open())
925                return false;
926
927        for (it = samples.begin(); it != it_end; ++ it)
928        {
929                VssRay *ray = *it;
[491]930                int sourceid = ray->mOriginObject ? ray->mOriginObject->mId : -1;               
931                int termid = ray->mTerminationObject ? ray->mTerminationObject->mId : -1;       
932
[490]933                samplesOut << ray->GetOrigin().x << " " << ray->GetOrigin().y << " " << ray->GetOrigin().z << " "
934                                   << ray->GetTermination().x << " " << ray->GetTermination().y << " " << ray->GetTermination().z << " "
[491]935                                   << sourceid << " " << termid << "\n";
[490]936        }
[491]937#else
938        ofstream samplesOut(fileName, ios::binary);
939        if (!samplesOut.is_open())
940                return false;
941
942        for (it = samples.begin(); it != it_end; ++ it)
943        {       
944                VssRay *ray = *it;
945                Vector3 origin(ray->GetOrigin());
946                Vector3 termination(ray->GetTermination());
947               
948                int sourceid = ray->mOriginObject ? ray->mOriginObject->mId : -1;               
949                int termid = ray->mTerminationObject ? ray->mTerminationObject->mId : -1;               
950
951                samplesOut.write(reinterpret_cast<char *>(&origin), sizeof(Vector3));
952                samplesOut.write(reinterpret_cast<char *>(&termination), sizeof(Vector3));
953                samplesOut.write(reinterpret_cast<char *>(&sourceid), sizeof(int));
954                samplesOut.write(reinterpret_cast<char *>(&termid), sizeof(int));
955    }
956#endif
[490]957        samplesOut.close();
[1194]958
[490]959        return true;
960}
[563]961
[1771]962
963int
964Preprocessor::GenerateRays(const int number,
[1867]965                                                   SamplingStrategy &strategy,
966                                                   SimpleRayContainer &rays)
[1020]967{
[2726]968        int invalidSamples;
969        return strategy.GenerateSamples(number, rays, invalidSamples);
[1771]970}
[860]971
[1990]972
[2726]973int Preprocessor::GenerateRays(const int number,
974                                                           SamplingStrategy &strategy,
975                                                           SimpleRayContainer &rays, int &invalidSamples)
976{
977        return strategy.GenerateSamples(number, rays, invalidSamples);
978}
979
980
[1771]981int
982Preprocessor::GenerateRays(const int number,
[1898]983                                                   const int sampleType,
984                                                   SimpleRayContainer &rays)
[1771]985{
[1772]986        SamplingStrategy *strategy = GenerateSamplingStrategy(sampleType);
[2726]987       
[1772]988        if (!strategy)
989                return 0;
990
[2726]991        int castRays = 0;
992        int invalidSamples;
[1381]993#if 1
[2726]994        castRays = strategy->GenerateSamples(number, rays, invalidSamples);
[1381]995#else
[1772]996        GenerateRayBundle(rays, newRay, 16, 0);
997        castRays += 16;
[1381]998#endif
[1772]999
1000        delete strategy;
1001        return castRays;
[878]1002}
[1020]1003
1004
[1884]1005SamplingStrategy *Preprocessor::GenerateSamplingStrategy(const int strategyId)
[1020]1006{
1007        switch (strategyId)
1008        {
[1520]1009        case SamplingStrategy::OBJECT_BASED_DISTRIBUTION:
[1020]1010                return new ObjectBasedDistribution(*this);
[1520]1011        case SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION:
[1020]1012                return new ObjectDirectionBasedDistribution(*this);
[1520]1013        case SamplingStrategy::DIRECTION_BASED_DISTRIBUTION:
[1020]1014                return new DirectionBasedDistribution(*this);
[1520]1015        case SamplingStrategy::DIRECTION_BOX_BASED_DISTRIBUTION:
[1020]1016                return new DirectionBoxBasedDistribution(*this);
[1520]1017        case SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION:
[1020]1018                return new SpatialBoxBasedDistribution(*this);
[1695]1019        case SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION:
1020                return new ReverseObjectBasedDistribution(*this);
[2691]1021        //case SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION:
1022        //      return new ViewCellBorderBasedDistribution(*this);
[1772]1023        case SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION:
1024                return new ReverseViewSpaceBorderBasedDistribution(*this);
[1824]1025        case SamplingStrategy::GLOBAL_LINES_DISTRIBUTION:
1026                return new GlobalLinesDistribution(*this);
1027               
1028                //case OBJECTS_INTERIOR_DISTRIBUTION:
1029                //      return new ObjectsInteriorDistribution(*this);
[1020]1030        default: // no valid strategy
[1279]1031                Debug << "warning: no valid sampling strategy" << endl;
[1020]1032                return NULL;
1033        }
[1221]1034
[1570]1035        return NULL; // should never come here
[1020]1036}
1037
1038
[2342]1039bool Preprocessor::LoadInternKdTree(const string &internKdTree)
[2003]1040{
[2583]1041  bool mUseKdTree = true;
[2342]1042
1043
[2583]1044  int rayCastMethod;
1045  Environment::GetSingleton()->
1046        GetIntValue("Preprocessor.rayCastMethod", rayCastMethod);
[2575]1047
[2700]1048#ifdef USE_HAVRAN_RAYCASTER
1049
[2643]1050  if ((rayCastMethod == 2) || (rayCastMethod == 3))
[2700]1051  {
1052          HavranRayCaster *hr = 0;
[2643]1053
[2700]1054          if (rayCastMethod == 3)
1055                  hr = reinterpret_cast<HavranDynRayCaster*>(mRayCaster);
1056          else
1057                  hr = reinterpret_cast<HavranRayCaster*>(mRayCaster);
[2701]1058         
1059          hr->Build(this->mObjects);
[2700]1060  }
[2701]1061
[2700]1062#endif
[2643]1063
1064
[2583]1065  if (!mUseKdTree) {
1066        // create just a dummy KdTree
1067        mKdTree = new KdTree;
[2035]1068        return true;
[2583]1069  }
1070 
1071 
1072 
1073  // always try to load the kd tree
1074  cout << "loading kd tree file " << internKdTree << " ... " << endl;
1075 
1076  if (!LoadKdTree(internKdTree)) {
1077        cout << "error loading kd tree with filename "
1078                 << internKdTree << ", rebuilding it instead ... " << endl;
1079        // build new kd tree from scene geometry
1080        BuildKdTree();
1081       
1082        // export kd tree?
1083        const long startTime = GetTime();
1084        cout << "exporting kd tree ... ";
1085       
1086        if (!ExportKdTree(internKdTree))
1087          {
1088                cout << " error exporting kd tree with filename "
1089                         << internKdTree << endl;
1090          }
1091        else
1092          {
1093                cout << "finished in "
1094                         << TimeDiff(startTime, GetTime()) * 1e-3
1095                         << " secs" << endl;
1096          }
1097  }
1098 
1099  KdTreeStatistics(cout);
[2588]1100  sceneBox = mKdTree->GetBox();
1101
[2583]1102  cout << mKdTree->GetBox() << endl;
1103 
1104  return true;
[2003]1105}
1106
1107
[2342]1108bool Preprocessor::InitRayCast(const string &externKdTree,
[2623]1109                                                           const string &internKdTree)
[1221]1110{
[1520]1111        int rayCastMethod;
[1968]1112        Environment::GetSingleton()->
[2623]1113                GetIntValue("Preprocessor.rayCastMethod", rayCastMethod);
[1520]1114
1115        if (rayCastMethod == 0)
[1221]1116        {
[2623]1117                cout << "ray cast method: internal" << endl;
1118                mRayCaster = new InternalRayCaster(*this);
[1221]1119        }
[2575]1120        if (rayCastMethod == 1)
[1520]1121        {
[1524]1122#ifdef GTP_INTERNAL
[2623]1123                cout << "ray cast method: intel" << endl;
1124                mRayCaster = new IntelRayCaster(*this, externKdTree);
[1524]1125#endif
[1251]1126        }
[2575]1127        if (rayCastMethod == 2)
1128        {
[2643]1129#ifdef USE_HAVRAN_RAYCASTER
[2629]1130          cout << "ray cast method: havran" << endl <<flush;
1131          mRayCaster = new GALIGN16 HavranRayCaster(*this);
[2643]1132#endif
[2575]1133        }
[2629]1134        if (rayCastMethod == 3)
1135        {
[2643]1136#ifdef USE_HAVRAN_RAYCASTER
[2629]1137          cout << "ray cast method: havran - dyn" << endl <<flush;
1138          mRayCaster = new GALIGN16 HavranDynRayCaster(*this);
[2643]1139#endif
[2629]1140        }
[2623]1141
[2629]1142       
[2559]1143        /////////////////
[2072]1144        //-- reserve constant block of rays
1145       
1146        // hack: If we dont't use view cells loading, there must be at least as much rays
1147        // as are needed for the view cells construction
1148        bool loadViewCells;
1149        Environment::GetSingleton()->GetBoolValue("ViewCells.loadFromFile", loadViewCells);
1150
[2187]1151        int reserveRays;       
1152        int constructionSamples;
[2072]1153
1154        if (!loadViewCells)
1155        {
[2187]1156                cout << "hack: setting ray pool size to view cell construction or evaluation size" << endl;
[2072]1157
[2187]1158                constructionSamples = 1000000;
1159
[2072]1160                char buf[100];
1161                Environment::GetSingleton()->GetStringValue("ViewCells.type", buf);     
[2187]1162
[2072]1163                if (strcmp(buf, "vspBspTree") == 0)
1164                {
[2187]1165                        Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", constructionSamples);
1166                       
[2072]1167                }
1168                else if (strcmp(buf, "vspOspTree") == 0)
1169                {
[2187]1170                        Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", constructionSamples);               
[2072]1171                }
[2187]1172
1173                int evalSamplesPerPass;
1174
1175                Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", evalSamplesPerPass);
1176
1177                reserveRays = max(constructionSamples, evalSamplesPerPass);
1178                reserveRays *= 2;
[2072]1179        }
1180        else
1181        {
[2687]1182                const int n = 4;
1183                reserveRays = mSamplesPerPass * n;
[2729]1184
[2072]1185        }
1186
[2742]1187#ifdef USE_RAY_POOL
1188        cout << "setting ray pool size to " << reserveRays << endl;       
1189
[2048]1190        cout << "======================" << endl;
[2072]1191        cout << "reserving " << reserveRays << " rays " << endl;
[2729]1192
[2072]1193        mRayCaster->ReserveVssRayPool(reserveRays);
[2729]1194       
[2583]1195        cout<<"done."<<endl<<flush;
[2742]1196#endif
1197
[1520]1198        return true;
[1281]1199}
1200
[1292]1201
[1281]1202void
1203Preprocessor::CastRays(
1204                                           SimpleRayContainer &rays,
[1520]1205                                           VssRayContainer &vssRays,
[1528]1206                                           const bool castDoubleRays,
[1996]1207                                           const bool pruneInvalidRays
[1281]1208                                           )
1209{
[2069]1210        const long t1 = GetTime();
[2582]1211
1212        // !!!!!!!!!!!!!!!! VH no sorting
[2726]1213        if (rays.size() > 10000)
[2614]1214        {
1215                mRayCaster->SortRays(rays);
1216                cout<<"Rays sorted in "<<TimeDiff(t1, GetTime())<<" ms."<<endl;
[1984]1217        }
[1972]1218
[2614]1219        int numTransformed = 0;
[2072]1220
[2614]1221
[2076]1222        if (mUseHwGlobalLines)
[2187]1223        {
[2539]1224                CastRaysWithHwGlobalLines(
1225                        rays,
1226                        vssRays,
1227                        castDoubleRays,
1228                        pruneInvalidRays
1229                        );
[2187]1230        }
[2076]1231        else
[2187]1232        {
[2539]1233                mRayCaster->CastRays(
1234                        rays,                           
1235                        vssRays,
1236                        mViewCellsManager->GetViewSpaceBox(),
1237                        castDoubleRays,
1238                        pruneInvalidRays);
[2609]1239
[2636]1240                // disabled not neccessary
1241                UpdateDynamicObjects();
[2187]1242        }
1243
[2610]1244       
[2187]1245        if (rays.size() > 10000)
[2076]1246        {
1247                cout << endl;
[2539]1248                long t2 = GetTime();
[2072]1249
[2076]1250#if SHOW_RAYCAST_TIMING
1251                if (castDoubleRays)
[2687]1252                        cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M double rays/s" << endl;
[2076]1253                else
[2687]1254                        cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M single rays/s" << endl;
[2076]1255#endif
[2590]1256
[2076]1257        }
[2687]1258
[2076]1259        DeterminePvsObjects(vssRays);
1260}
1261
1262 
1263void
1264Preprocessor::CastRaysWithHwGlobalLines(
1265                                                                                SimpleRayContainer &rays,
[2187]1266                                                                                VssRayContainer &vssRays,
1267                                                                                const bool castDoubleRays,
1268                                                                                const bool pruneInvalidRays)
[2076]1269{
1270  SimpleRayContainer::const_iterator rit, rit_end = rays.end();
1271  SimpleRayContainer rayBucket;
1272  int i = 0;
1273  for (rit = rays.begin(); rit != rit_end; ++ rit, ++ i)
[1292]1274        {
[2076]1275          SimpleRay ray = *rit;
[1990]1276#ifdef USE_CG
[1972]1277                // HACK: global lines must be treated special
[2076]1278          if (ray.mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION)
[1968]1279                {
[2076]1280                  mGlobalLinesRenderer->CastGlobalLines(ray, vssRays);
1281                  continue;
[1968]1282                }
[1990]1283#endif
[2187]1284                rayBucket.push_back(ray);
1285
1286                // 16 rays gathered => do ray casting
1287                if (rayBucket.size() >= 16)
[1520]1288                {
[2187]1289                        mRayCaster->CastRays16(
1290                                rayBucket,                             
1291                                vssRays,
1292                                mViewCellsManager->GetViewSpaceBox(),
1293                                castDoubleRays,
1294                                pruneInvalidRays);
1295
1296                        rayBucket.clear();
[1292]1297                }
[2187]1298
1299                if (rays.size() > 100000 && i % 100000 == 0)
[2072]1300                        cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r";
[1972]1301        }
[2072]1302   
[1972]1303        // cast rest of rays
1304        SimpleRayContainer::const_iterator sit, sit_end = rayBucket.end();
1305
1306        for (sit = rayBucket.begin(); sit != sit_end; ++ sit)
1307        {
1308                SimpleRay ray = *sit;
[1990]1309
1310#ifdef USE_CG
[1972]1311                // HACK: global lines must be treated special
1312                if (ray.mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION)
[1932]1313                {
[1972]1314                        mGlobalLinesRenderer->CastGlobalLines(ray, vssRays);
[1990]1315                        continue;
[1972]1316                }
[1990]1317#endif
1318                mRayCaster->CastRay(
1319                                                        ray,
1320                                                        vssRays,
1321                                                        mViewCellsManager->GetViewSpaceBox(),
1322                                                        castDoubleRays,
[1996]1323                                                        pruneInvalidRays);
[1990]1324               
[1524]1325        }
[1743]1326
[1251]1327}
1328
1329
[2726]1330bool Preprocessor::GenerateJitteredRays(SimpleRayContainer &rayBundle, 
1331                                                                                const SimpleRay &mainRay,
1332                                                                                int number,
[2736]1333                                                                                int pertubType,
1334                                                                                float scale) const
[1381]1335{
[2726]1336        Vector3 pertub;
[1381]1337
[2726]1338        for (int i = 0; i < number; ++ i)
[1381]1339        {
[2736]1340                pertub.x = RandomValue(-scale, scale);
1341                pertub.y = RandomValue(-scale, scale);
1342                pertub.z = RandomValue(-scale, scale);
[1381]1343
[2726]1344                Vector3 newDir = mainRay.mDirection + pertub;
1345                const float c = Magnitude(newDir);
1346                newDir *= 1.0f / c;
[1713]1347
[1381]1348                //const Vector3 newDir = mainRay.mDirection;
[2726]1349#if 0
[1381]1350                pertub.x = RandomValue(0.0f, pertubOrigin);
1351                pertub.y = RandomValue(0.0f, pertubOrigin);
1352                pertub.z = RandomValue(0.0f, pertubOrigin);
[1713]1353
[1381]1354                const Vector3 newOrigin = mainRay.mOrigin + pertub;
[2726]1355#endif
1356                const Vector3 newOrigin = mainRay.mOrigin;
[1381]1357
[1883]1358                rayBundle.push_back(SimpleRay(newOrigin, newDir, 0, 1.0f));
[1381]1359        }
1360
1361        return true;
1362}
1363
1364
[1251]1365void Preprocessor::SetupRay(Ray &ray,
1366                                                        const Vector3 &point,
[1713]1367                                                        const Vector3 &direction) const
[1251]1368{
1369        ray.Clear();
1370        // do not store anything else then intersections at the ray
[1713]1371        ray.Init(point, direction, Ray::LOCAL_RAY);     
[1251]1372}
1373
[1968]1374
[1917]1375void Preprocessor::EvalViewCellHistogram()
[1771]1376{
[1917]1377        char filename[256];
1378        Environment::GetSingleton()->GetStringValue("Preprocessor.histogram.file", filename);
[1771]1379 
[1917]1380        // mViewCellsManager->EvalViewCellHistogram(filename, 1000000);
1381        mViewCellsManager->EvalViewCellHistogramForPvsSize(filename, 1000000);
[1771]1382}
[1520]1383
[1900]1384
1385bool
1386Preprocessor::ExportRays(const char *filename,
1387                                                 const VssRayContainer &vssRays,
[2001]1388                                                 const int number,
1389                                                 const bool exportScene
[1900]1390                                                 )
1391{
1392  cout<<"Exporting vss rays..."<<endl<<flush;
1393 
1394  Exporter *exporter = NULL;
1395  exporter = Exporter::GetExporter(filename);
1396
1397  if (0) {
1398        exporter->SetWireframe();
1399        exporter->ExportKdTree(*mKdTree);
1400  }
1401 
1402  exporter->SetFilled();
1403  // $$JB temporarily do not export the scene
[2001]1404  if (exportScene)
[1900]1405        exporter->ExportScene(mSceneGraph->GetRoot());
1406
1407  exporter->SetWireframe();
1408
1409  if (1) {
1410        exporter->SetForcedMaterial(RgbColor(1,0,1));
1411        exporter->ExportBox(mViewCellsManager->GetViewSpaceBox());
1412        exporter->ResetForcedMaterial();
1413  }
1414 
1415  VssRayContainer rays;
1416  vssRays.SelectRays(number, rays);
1417  exporter->ExportRays(rays, RgbColor(1, 0, 0));
1418  delete exporter;
1419  cout<<"done."<<endl<<flush;
1420
1421  return true;
[1251]1422}
[1900]1423
[2002]1424bool
1425Preprocessor::ExportRayAnimation(const char *filename,
1426                                                                 const vector<VssRayContainer> &vssRays
1427                                                                 )
1428{
1429  cout<<"Exporting vss rays..."<<endl<<flush;
1430       
1431  Exporter *exporter = NULL;
1432  exporter = Exporter::GetExporter(filename);
1433  if (0) {
1434        exporter->SetWireframe();
1435        exporter->ExportKdTree(*mKdTree);
1436  }
1437  exporter->SetFilled();
1438  // $$JB temporarily do not export the scene
[2008]1439  if (0)
[2002]1440        exporter->ExportScene(mSceneGraph->GetRoot());
1441  exporter->SetWireframe();
1442
1443  if (1) {
1444        exporter->SetForcedMaterial(RgbColor(1,0,1));
1445        exporter->ExportBox(mViewCellsManager->GetViewSpaceBox());
1446        exporter->ResetForcedMaterial();
1447  }
1448 
1449  exporter->ExportRaySets(vssRays, RgbColor(1, 0, 0));
1450       
1451  delete exporter;
1452
1453  cout<<"done."<<endl<<flush;
1454
1455  return true;
1456}
1457
[1931]1458void
1459Preprocessor::ComputeRenderError()
1460{
[2709]1461  // compute rendering error   
[1931]1462  if (renderer && renderer->mPvsStatFrames) {
[2680]1463       
1464        if (!mViewCellsManager->GetViewCellPointsList()->empty())
1465        {
[2049]1466         
[2598]1467          ViewCellPointsList *vcPoints = mViewCellsManager->GetViewCellPointsList();
[2049]1468         
[2598]1469          ViewCellPointsList::const_iterator
[2050]1470                vit = vcPoints->begin(),
1471                vit_end = vcPoints->end();
1472
[2049]1473          SimpleRayContainer viewPoints;
1474         
[2050]1475          for (; vit != vit_end; ++ vit) {
[2049]1476                ViewCellPoints *vp = *vit;
1477
1478                SimpleRayContainer::const_iterator rit = vp->second.begin(), rit_end = vp->second.end();
1479                for (; rit!=rit_end; ++rit)
1480                  viewPoints.push_back(*rit);
1481          }
[2647]1482         
[2050]1483          if (viewPoints.size() != renderer->mPvsErrorBuffer.size()) {
1484                renderer->mPvsErrorBuffer.resize(viewPoints.size());
1485                renderer->ClearErrorBuffer();
1486          }
1487
[2680]1488          cout << "evaluating list of " << viewPoints.size() << " pts" << endl;
[2049]1489          renderer->EvalPvsStat(viewPoints);
1490        } else
[2648]1491        {
[2680]1492                cout << "evaluating random points" << endl;
[2049]1493          renderer->EvalPvsStat();
[2648]1494        }
1495
[1931]1496        mStats <<
1497          "#AvgPvsRenderError\n" <<renderer->mPvsStat.GetAvgError()<<endl<<
[2002]1498          "#AvgPixelError\n" <<renderer->GetAvgPixelError()<<endl<<
[2008]1499          "#MaxPixelError\n" <<renderer->GetMaxPixelError()<<endl<<
[1931]1500          "#MaxPvsRenderError\n" <<renderer->mPvsStat.GetMaxError()<<endl<<
1501          "#ErrorFreeFrames\n" <<renderer->mPvsStat.GetErrorFreeFrames()<<endl<<
1502          "#AvgRenderPvs\n" <<renderer->mPvsStat.GetAvgPvs()<<endl;
1503  }
[1900]1504}
[1931]1505
[1958]1506
1507Intersectable *Preprocessor::GetObjectById(const int id)
1508{
[1960]1509#if 1
[1958]1510        // create a dummy mesh instance to be able to use stl
1511        MeshInstance object(NULL);
1512        object.SetId(id);
1513
1514        ObjectContainer::const_iterator oit =
1515                lower_bound(mObjects.begin(), mObjects.end(), &object, ilt);
1516                               
1517        // objects sorted by id
1518        if ((oit != mObjects.end()) && ((*oit)->GetId() == object.GetId()))
1519        {
1520                return (*oit);
1521        }
1522        else
1523        {
1524                return NULL;
1525        }
1526#else
[2685]1527        return mObjects[id];
[1958]1528#endif
[1931]1529}
[1958]1530
[1968]1531
1532void Preprocessor::PrepareHwGlobalLines()
1533{
1534        int texHeight, texWidth;
1535        float eps;
1536        int maxDepth;
1537        bool sampleReverse;
1538
1539        Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.texHeight", texHeight);
[1969]1540        Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.texWidth", texWidth);
[1968]1541        Environment::GetSingleton()->GetFloatValue("Preprocessor.HwGlobalLines.stepSize", eps);
1542        Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.maxDepth", maxDepth);
1543        Environment::GetSingleton()->GetBoolValue("Preprocessor.HwGlobalLines.sampleReverse", sampleReverse);
1544
[1969]1545        Debug << "****** hw global line options *******" << endl;
1546        Debug << "texWidth: " << texWidth << endl;
1547        Debug << "texHeight: " << texHeight << endl;
1548        Debug << "sampleReverse: " << sampleReverse << endl;
1549        Debug << "max depth: " << maxDepth << endl;
1550        Debug << "step size: " << eps << endl;
1551        Debug << endl;
1552
[1990]1553#ifdef USE_CG
[1969]1554        globalLinesRenderer = mGlobalLinesRenderer =
[1968]1555                new GlobalLinesRenderer(this,
1556                                                                texHeight,
1557                                                                texWidth,
1558                                                                eps,
1559                                                                maxDepth,
1560                                                                sampleReverse);
[1990]1561
[1968]1562        mGlobalLinesRenderer->InitGl();
[1990]1563
1564#endif
[1958]1565}
[1968]1566
[2048]1567
1568void Preprocessor::DeterminePvsObjects(VssRayContainer &rays)
1569{
[2606]1570  mViewCellsManager->DeterminePvsObjects(rays, false);
[1968]1571}
[2048]1572
1573
[2183]1574bool Preprocessor::LoadObjects(const string &filename,
1575                                                           ObjectContainer &pvsObjects,
1576                                                           const ObjectContainer &preprocessorObjects)
1577{
1578        ObjectsParser parser;
1579
1580        const bool success = parser.ParseObjects(filename,
1581                                                                                         pvsObjects,
1582                                                                                         preprocessorObjects);
1583
1584        if (!success)
1585        {
1586                Debug << "Error: loading objects failed!" << endl;
1587        }
1588
1589        // hack: no bvh object could be found => take preprocessor objects
1590        if (pvsObjects.empty())
1591        {
1592                Debug << "no objects" << endl;
1593                pvsObjects = preprocessorObjects;
1594        }
1595
1596        return success;
[2048]1597}
[2183]1598
1599
[2702]1600void Preprocessor::RegisterDynamicObject(SceneGraphLeaf *leaf)
1601{       
1602        mDynamicObjects.push_back(leaf);
1603
[2710]1604        const int currentId = (int)mObjects.size() + sCurrentDynamicId;
1605
1606        leaf->GetIntersectable()->SetId(currentId);
1607
1608        for (size_t i = 0; i < leaf->mGeometry.size(); ++ i)
1609        {
1610                leaf->mGeometry[i]->SetId(currentId);
1611        }
1612
[2715]1613        cout << "new object registered with id " << currentId << endl;
[2710]1614
1615        ++ sCurrentDynamicId;
1616
[2709]1617        // tell ray caster to update
1618        ScheduleUpdateDynamicObjects();
[2609]1619}
1620
1621
[2720]1622SceneGraphLeaf *Preprocessor::GenerateBoxGeometry(const AxisAlignedBox3 &box)
1623{
1624        float offs = box.Min().y;
1625        AxisAlignedBox3 newBox = box;
1626        newBox.Translate(Vector3(0.0f, -offs, 0.0f));
1627
1628        const bool dynamic = true;
1629        SceneGraphLeaf *leaf = new SceneGraphLeaf(dynamic);
1630        newBox.Triangulate(leaf->mGeometry);
1631
1632        leaf->UpdateBox();
1633
1634        return leaf;
1635}
1636
1637
[2694]1638SceneGraphLeaf *Preprocessor::LoadDynamicGeometry(const string &filename)
[2609]1639{
[2682]1640        const bool dynamic = true;
[2615]1641        SceneGraphLeaf *leaf = new SceneGraphLeaf(dynamic);
[2682]1642
[2638]1643        bool parsed = false;
[2609]1644
[2678]1645        if (strstr(filename.c_str(), ".obj"))
1646        {
1647                cout<<"parsing obj file.."<<endl;
1648                ObjParser *p = new ObjParser;
[2694]1649                parsed = p->ParseFile(filename, leaf, false);
[2678]1650        }
1651        else
1652        {
1653                cout<<"parsing binary obj file ... " << endl;
1654                parsed = LoadBinaryObj(filename, leaf, NULL, 100);
[2638]1655        }
[2678]1656
[2638]1657        if (parsed)
[2678]1658        {
[2694]1659                ObjectContainer::const_iterator it, it_end = leaf->mGeometry.end();
[2678]1660
[2694]1661                for (it = leaf->mGeometry.begin(); it != it_end; ++ it)
1662                {
1663                        TriangleIntersectable *tri = static_cast<TriangleIntersectable *>(*it);
[2678]1664
[2694]1665                        Triangle3 t = tri->GetItem();
[2636]1666
[2702]1667                        // hack: scale object appropriately
1668                        float scale = 0.01f;
1669
[2694]1670                        t.mVertices[0] *= scale;
1671                        t.mVertices[1] *= scale;
1672                        t.mVertices[2] *= scale;
[2636]1673
[2694]1674                        tri->SetItem(t);
1675                }
[2682]1676
[2694]1677                leaf->UpdateBox();
[2709]1678
1679                float offs = -leaf->GetOriginalBox().Min().y;
1680
1681                // scale so pivot is always on bottom
1682                for (it = leaf->mGeometry.begin(); it != it_end; ++ it)
1683                {
1684                        TriangleIntersectable *tri = static_cast<TriangleIntersectable *>(*it);
1685
1686                        Triangle3 t = tri->GetItem();
1687
1688                        // hack: scale object appropriately
1689                        t.mVertices[0].y += offs;
1690                        t.mVertices[1].y += offs;
1691                        t.mVertices[2].y += offs;
1692
1693                        tri->SetItem(t);
1694                }
1695
1696                leaf->UpdateBox();
1697
1698
[2694]1699                cout<<"Dynamic object loaded successfully: " << leaf->GetBox() << endl;
1700
1701                return leaf;
1702        }
1703               
1704
1705        cout<<"Dynamic object loading failed."<<endl;
1706        return NULL;
[2183]1707}
[2593]1708
[2636]1709
[2720]1710float Preprocessor::_HackComputeRenderCost(ViewCell *vc)
1711{
[2722]1712        ObjectPvsIterator pit = vc->GetPvs().GetIterator();
[2720]1713
1714        float renderCost = 0;
[2722]1715        int i = 0;
[2723]1716       
[2720]1717        // first mark all objects from this pvs
1718        while (pit.HasMoreEntries())   
1719        {
1720                Intersectable *obj = pit.Next();
1721                if (obj->Type() == Intersectable::KD_INTERSECTABLE)
1722                {
[2722]1723                        KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj);
[2720]1724
1725                        /*if (mShowDistanceWeightedPvs)
1726                        {
1727                        const AxisAlignedBox3 box = kdObj->GetBox();
1728
1729                        const float dist = SqrDistance(vc->GetBox().Center(), box.Center());
1730                        renderCost += 1.0f / dist;
1731                        }
1732                        else if (mShowDistanceWeightedTriangles)
1733                        {
1734                        const AxisAlignedBox3 box = kdObj->GetBox();
1735
1736                        const float dist = SqrDistance(vc->GetBox().Center(), box.Center());
1737                        renderCost += kdObj->ComputeNumTriangles() / dist;
1738                        }
1739                        else //if (mShowWeightedTriangles)
1740                        {
1741                        */
1742                        renderCost += kdObj->ComputeNumTriangles();
1743                        //}
1744                }
[2723]1745                else if (obj->Type() == Intersectable::SCENEGRAPHLEAF_INTERSECTABLE)
1746                {
1747                        renderCost += (float)static_cast<SceneGraphLeafIntersectable *>(obj)->GetItem()->mGeometry.size();
1748                }
1749               
[2720]1750        }
1751
1752        return renderCost;
1753}
1754
1755
1756
1757
[2700]1758/** Object has moved - must dynamically update all affected PVSs */
1759void
[2707]1760Preprocessor::ObjectMoved(SceneGraphLeaf *leaf)
[2636]1761{
[2700]1762  // first invalidate all PVS from which this object is visible
1763  ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end();
[2707]1764 
1765  AxisAlignedBox3 box = leaf->GetBox();
1766  Intersectable *inter = leaf->GetIntersectable();
1767  int removedEntries = 0;
[2713]1768  int removedSelfEntries = 0;
[2708]1769  CSeparatingAxisTester shadowVolume;
[2713]1770  int maxPlanes = 0;
1771  int allEntries = 0;
[2722]1772
1773  int viewCells = 0;
1774
[2707]1775  // now search for pvss which contained any mailed node
[2722]1776  for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit)
1777  {
[2723]1778          ViewCell *vc = *vit;
1779          ObjectPvs &pvs = vc->GetPvs();
[2722]1780
1781          bool pvsChanged = false;
1782
[2723]1783          if (Overlap(box, vc->GetBox()))
[2722]1784          {
[2720]1785                  pvs.Clear();
1786                  removedEntries += pvs.GetSize();
[2722]1787                  pvsChanged = true;
1788          }
1789          else
1790          {
[2723]1791                  //cout<<vc->GetBox()<<" "<<box<<endl;
1792                  shadowVolume.Init(vc->GetBox(), box);
[2720]1793                  if (shadowVolume.CntPlanes() > maxPlanes)
1794                          maxPlanes = shadowVolume.CntPlanes();
1795
1796                  int j = 0;
[2722]1797                  for (int i=0; i < pvs.mEntries.size(); i++)
1798                  {
[2720]1799                          allEntries++;
1800                          Intersectable *o = pvs.mEntries[i].mObject;
[2722]1801                          if (o == inter)
1802                          {
[2720]1803                                  removedSelfEntries++;
[2722]1804                                  pvsChanged = true;
1805                          }
1806                          else
1807                          {
1808                                  if (!shadowVolume.TestIsInsideShaft(o->GetBox()))
1809                                  {
[2720]1810                                          if (j != i)
1811                                                  pvs.mEntries[j] = pvs.mEntries[i];
1812                                          j++;
[2722]1813                                  }
1814                                  else
1815                                  {
[2720]1816                                          removedEntries++;
[2722]1817                                          pvsChanged = true;
[2720]1818                                  }
1819                          }
[2713]1820                  }
[2722]1821
[2720]1822                  // now the pvs has to be resorted
1823                  pvs.mLastSorted = 0;
1824                  if (j==0)
1825                          pvs.mEntries.clear();
[2722]1826                  else
1827                  {
[2720]1828                          pvs.mEntries.resize(j);
1829                          if (j>1)
1830                                  pvs.SimpleSort();
1831                  }
[2707]1832          }
[2720]1833
[2722]1834          if (pvsChanged)
1835          {
1836                  // recompute render cost
1837                  float renderCost = _HackComputeRenderCost(vc);
1838                  vc->GetPvs().mStats.mWeightedTriangles = renderCost;
1839          }
[2707]1840  }
[2722]1841
[2713]1842  cerr<<"Number of removed pvs entries = "<<removedEntries<<" ("<<
1843        100.0f*removedEntries/(float)allEntries<<"%)"<<endl;
1844  cerr<<"Number of removed pvs self-entries = "<<removedSelfEntries<<endl;
1845  cerr<<"Max shadow planes used:"<<maxPlanes<<endl;
[2707]1846  //    cout<<"Cleared "<<pvsCounter<<" PVSs ("<<mViewCellsManager->GetViewCells().size()/
1847  //      (float)pvsCounter*100.0f<<"%) "<<endl;
1848 
[2593]1849}
[2636]1850
[2645]1851
[2709]1852void Preprocessor::ObjectRemoved(SceneGraphLeaf *leaf)
1853{
1854        ObjectMoved(leaf);
1855}
1856
1857
[2645]1858void Preprocessor::UpdateDynamicObjects()
[2636]1859{
[2645]1860        if (mUpdateDynamicObjects)
1861        {
[2716]1862                // delete ALL dynamic stuff and rebuild using the new trafos
1863                preprocessor->mRayCaster->DeleteDynamicObjects();
1864
[2724]1865#define MULTIPLE_OBJECTS 1
[2713]1866
[2714]1867#if MULTIPLE_OBJECTS
[2716]1868                static ObjectContainer objects;
1869                CLEAR_CONTAINER(objects);
1870
1871                for (size_t i = 0; i < mDynamicObjects.size(); ++ i)
1872                {
1873                        SceneGraphLeaf *l = mDynamicObjects[i];
1874
1875                        for (size_t j=0; j < l->mGeometry.size(); j++)
1876                        {
1877                                if (l->mGeometry[j]->Type() == Intersectable::TRIANGLE_INTERSECTABLE)
1878                                {
1879                                        Triangle3 t(((TriangleIntersectable *)l->mGeometry[j])->GetItem());
1880                                        t.ApplyTransformation(l->GetTransformation());
1881                                        TriangleIntersectable *to = new TriangleIntersectable(t);
1882                                        to->SetId(l->GetIntersectable()->GetId());
1883                                        objects.push_back(to);
1884                                }
1885                        }
[2714]1886                }
[2716]1887
1888                mRayCaster->AddDynamicObjecs(objects, IdentityMatrix());
[2714]1889#endif   
1890
[2716]1891                SceneGraphLeaf *toUpdate = NULL;
[2709]1892
[2716]1893                for (size_t i = 0; i < mDynamicObjects.size(); ++ i)
1894                {
1895                        SceneGraphLeaf *l = mDynamicObjects[i];
1896
[2714]1897#if  !MULTIPLE_OBJECTS
[2716]1898                        PrepareObjectsForRayCaster(l);
[2714]1899#endif
[2709]1900
[2716]1901                        if (l->HasChanged())
1902                        {
1903                                cout<<"Updating affected PVSs..."<<endl;
1904                                preprocessor->ObjectMoved(l);
1905                                cout<<"done."<<endl;   
1906                                l->SetHasChanged(false);
1907                        }
1908                }
1909               
1910                mUpdateDynamicObjects = false;
[2636]1911        }
1912}
1913
[2645]1914
1915void Preprocessor::ScheduleUpdateDynamicObjects()
1916{
[2709]1917        mUpdateDynamicObjects = true;
[2636]1918}
[2645]1919
1920
[2715]1921void Preprocessor::PrepareObjectsForRayCaster(SceneGraphLeaf *l)
[2709]1922{
1923        cout<<"Updating dynamic objects in ray caster..."<<endl;
1924
1925        mRayCaster->AddDynamicObjecs(l->mGeometry, l->GetTransformation());
1926        cout<<"done."<<endl;
[2645]1927}
[2709]1928
[2713]1929}
Note: See TracBrowser for help on using the repository browser.