Changeset 2542


Ignore:
Timestamp:
08/20/07 12:51:12 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
1 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBiHierarchySceneManager.cpp

    r2455 r2542  
    7272} 
    7373 
     74 
    7475BiHierarchySceneManager::~BiHierarchySceneManager(void) 
    7576{ 
     
    7778        delete mBiHierarchy; 
    7879} 
     80 
    7981 
    8082void BiHierarchySceneManager::clearScene() 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj

    r2532 r2542  
    268268                        </File> 
    269269                        <File 
    270                                 RelativePath=".\FlexibleHeap.h"> 
    271                         </File> 
    272                         <File 
    273270                                RelativePath="..\src\FrustumCullingManager.cpp"> 
    274271                        </File> 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp

    r2539 r2542  
    106106                                        int nodesTested = 0; 
    107107 
    108 #if 1 
    109                                         // test a certain ratio of random candidates 
    110                                         HierarchyNodeContainer mynodes; 
    111                                         mHierarchyInterface->CollectLeaves(node, mynodes); 
    112  
    113                                         const int p = mRandomCandidates * RAND_MAX / (int)mynodes.size(); 
    114  
    115                                         HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 
    116  
    117                                         for (nit = mynodes.begin(); nit != nit_end; ++ nit) 
     108                                        if(1) 
    118109                                        { 
    119                                                 HierarchyNode *leaf = *nit; 
    120  
    121                                                 if (rand() > p) 
    122                                                         continue; 
     110                                                // test a certain ratio of random candidates 
     111                                                HierarchyNodeContainer mynodes; 
     112                                                mHierarchyInterface->CollectLeaves(node, mynodes); 
     113 
     114                                                const int p = mRandomCandidates * RAND_MAX / (int)mynodes.size(); 
     115 
     116                                                HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 
     117 
     118                                                for (nit = mynodes.begin(); nit != nit_end; ++ nit) 
     119                                                { 
     120                                                        HierarchyNode *leaf = *nit; 
     121 
     122                                                        if (rand() > p) 
     123                                                                continue; 
     124 
     125                                                        bool intersects = false; 
     126                                                        const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 
     127 
     128                                                        // don't test in these cases ... 
     129                                                        if (frustumCulled || intersects) 
     130                                                                continue; 
     131 
     132                                                        ++ nodesTested; 
     133 
     134                                                        mHierarchyInterface->SetNodeVisible(leaf, false); 
     135 
     136                                                        // update node's visited flag: this is important as we are not testing 
     137                                                        // all nodes in the hierarchy in this mode 
     138                                                        mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
     139                                                        // issue the query 
     140                                                        mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves); 
     141                                                } 
     142 
     143                                                //std::stringstream d; d << "rc: " << mRandomCandidates << " tested: " << nodesTested << " of " << (int)mynodes.size(); 
     144                                                //CullingLogManager::GetSingleton()->LogMessage(d.str()); 
     145                                        } 
     146                                        else 
     147                                        { 
     148                                                // always test one random candidate 
     149                                                HierarchyNode *leaf = mHierarchyInterface->GetRandomLeaf(node); 
    123150 
    124151                                                bool intersects = false; 
    125152                                                const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 
    126153 
    127                                                 // don't test in these cases ... 
    128                                                 if (frustumCulled || intersects) 
     154                                                if (frustumCulled || intersects) // don't test in these cases ... 
    129155                                                        continue; 
    130                  
     156 
    131157                                                ++ nodesTested; 
    132                                                  
     158 
    133159                                                mHierarchyInterface->SetNodeVisible(leaf, false); 
    134160 
     
    137163                                                mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
    138164                                                // issue the query 
    139                                                 mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves); 
     165                                                mHierarchyInterface->IssueNodeOcclusionQuery(leaf, mTestGeometryForVisibleLeaves); 
    140166                                        } 
    141167 
    142                                         //std::stringstream d; d << "rc: " << mRandomCandidates << " tested: " << nodesTested << " of " << (int)mynodes.size(); 
    143                                         //CullingLogManager::GetSingleton()->LogMessage(d.str()); 
    144  
    145 #else 
    146                                         // always test one random candidate 
    147                                         HierarchyNode *leaf = mHierarchyInterface->GetRandomLeaf(node); 
    148                                          
    149                                         bool intersects = false; 
    150                                         const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 
    151  
    152                                         if (frustumCulled || intersects) // don't test in these cases ... 
    153                                                 continue; 
    154  
    155                                         ++ nodesTested; 
    156  
    157                                         mHierarchyInterface->SetNodeVisible(leaf, false); 
    158  
    159                                         // update node's visited flag: this is important as we are not testing 
    160                                         // all nodes in the hierarchy in this mode 
    161                                         mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
    162                                         // issue the query 
    163                                         mHierarchyInterface->IssueNodeOcclusionQuery(leaf, mTestGeometryForVisibleLeaves); 
    164  
    165 #endif 
    166                                          
     168                                        // render the whole subtree 
    167169                                        mHierarchyInterface->RenderNodeRecursive(node); 
    168170 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env

    r2539 r2542  
    219219                ################################################### 
    220220 
    221                 # minimal steps of same type: for interleaved, this is only valid for the first few splits 
     221                # minimal steps of same domain (view /object): for interleaved mode 
    222222                minStepsOfSameType 100 
    223223                maxStepsOfSameType 900 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r2538 r2542  
    23932393                                "vsp_term_max_view_cells=", 
    23942394                                "10000"); 
    2395  
    23962395         
    23972396        RegisterOption("VspTree.Termination.missTolerance", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h

    r2360 r2542  
    3434 
    3535 
    36 /** This class implements a flexible heap for 
    37 use as a priority queue. 
    38  
    39 Unlike the stl priority_queue, the class allows access to all  
    40 elements. It implements efficient insertion routines and remove routines 
    41 of arbitrary elements. 
     36/** This class implements a flexible heap for use as a priority queue. 
     37        Unlike the stl priority_queue, the class allows access to all  
     38        elements. It implements efficient insertion routines and remove routines 
     39        of arbitrary elements. 
    4240*/ 
    4341template<typename T> 
     
    4846        FlexibleHeap(const unsigned int n): mBuffer(n) { } 
    4947 
    50         void Push(T t) { Push(t, t->GetPriority()); } 
     48        void Push(T t); 
    5149        void Push(T t, const float priority); 
    52         bool Update(T t) { return Update(t, t->GetPriority()); } 
     50        bool Update(T t); 
    5351        bool Update(T t, const float priority); 
    5452 
    55         unsigned int Size() const { return (unsigned int)mBuffer.size(); } 
    56         bool Empty() const {return mBuffer.empty(); } 
    57         T Item(const unsigned int i) { return mBuffer[i]; } 
    58         const T Item(const unsigned int i) const { return mBuffer[i]; } 
     53        inline unsigned int Size() const; 
     54        inline bool Empty() const; 
     55        inline T Item(const unsigned int i); 
     56        inline const T Item(const unsigned int i) const; 
    5957        T Pop(); 
    60         T Top() const { return (mBuffer.empty() ? (T)NULL : mBuffer.front()); } 
     58        inline T Top() const; 
    6159        /** Erases the element from the heap. 
    6260        */ 
     
    7977 
    8078 
    81 /*****************************************************************************/ 
    82 /*                         MyHeap implementation                             * 
    83 /*****************************************************************************/ 
     79 
     80 
     81/******************************************************************/ 
     82/*                 FexibleHeap implementation                     */ 
     83/******************************************************************/ 
     84 
     85 
     86template <typename T> 
     87void FlexibleHeap<T>::Push(T t)  
     88{  
     89        Push(t, t->GetPriority());  
     90} 
     91 
     92 
     93template <typename T> 
     94bool FlexibleHeap<T>::Update(T t)  
     95{  
     96        return Update(t, t->GetPriority());  
     97} 
     98 
     99 
     100template <typename T> 
     101inline unsigned int FlexibleHeap<T>::Size() const  
     102{  
     103        return (unsigned int)mBuffer.size();  
     104} 
     105 
     106 
     107template <typename T> 
     108inline bool FlexibleHeap<T>::Empty() const  
     109{ 
     110        return mBuffer.empty();  
     111} 
     112 
     113 
     114template <typename T> 
     115inline T FlexibleHeap<T>::Item(const unsigned int i)  
     116{  
     117        return mBuffer[i];  
     118} 
     119 
     120 
     121template <typename T> 
     122inline const T FlexibleHeap<T>::Item(const unsigned int i) const  
     123{  
     124        return mBuffer[i];  
     125} 
     126 
     127 
     128template <typename T> 
     129inline T FlexibleHeap<T>::Top() const  
     130{  
     131        return (mBuffer.empty() ? (T)NULL : mBuffer.front());  
     132} 
     133 
    84134 
    85135template <typename T> 
     
    120170        } 
    121171} 
     172 
    122173 
    123174template <typename T> 
     
    200251        mBuffer.pop_back(); 
    201252 
    202         DownHeap(0); 
     253        if (!mBuffer.empty()) 
     254                DownHeap(0); 
     255 
    203256        dead->NotInHeap(); 
    204257 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r2539 r2542  
    549549         
    550550        PrepareViewSpaceSubdivision(viewSpaceQueue, sampleRays, objects); 
    551  
     551        /// q: why clear the dirty list here? 
    552552        dirtyList.clear(); 
    553553        // view space subdivision started 
  • GTP/trunk/Lib/Vis/Preprocessing/src/LogManager.h

    r1112 r2542  
    1616        there is always only one log manager. 
    1717*/ 
    18 class LogManager { 
    19  
     18class LogManager  
     19{ 
    2020public: 
    2121 
     
    3434        LogManager(); 
    3535 
    36   ~LogManager() {} 
    37    
     36        ~LogManager() {} 
     37 
    3838        void LogMessage(const std::string &str); 
    3939 
    4040protected: 
    41  
    4241        std::ofstream mOutStream; 
    4342 
    4443private: 
    45  
    4644        static LogManager *sLogManager; 
    47          
    4845}; 
    4946 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp

    r2176 r2542  
    15911591        } 
    15921592 
    1593         // andidates holding this view cells are thrown into dirty list 
     1593        // candidates that contain this view cells are thrown into dirty list 
    15941594        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    15951595 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h

    r2538 r2542  
    255255                { 
    256256                        mDirty = false; 
    257                         // todo: avoid computing split plane 
    258257                        sOspTree->EvalSubdivisionCandidate(*this);       
    259258                } 
     
    272271                } 
    273272 
    274                 void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, 
    275                                                                         const bool onlyUnmailed) 
     273                void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, const bool onlyUnmailed) 
    276274                { 
    277275                        sOspTree->CollectDirtyCandidates(this, dirtyList, onlyUnmailed); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2539 r2542  
    509509        if (result)  
    510510        {  
    511  
    512511                mSceneGraph->AssignObjectIds(); 
    513512  
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2538 r2542  
    462462                        if (mUseSpatialFilter)  
    463463                        { 
    464                                 // 9.11. 2006 -> experiment with new spatial filter 
    465 #if 0 
    466                                 mViewCellsManager->ApplySpatialFilter(mKdTree, 
    467                                         mSpatialFilterSize* 
    468                                         Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 
    469                                         mPvsCache.mPvs); 
    470 #else 
    471                                 //cout<<"updating filter" << endl; 
    472464                                // mSpatialFilter size is in range 0.001 - 0.1 
    473465                                mViewCellsManager->ApplyFilter2(viewcell, 
    474                                         mUseFilter, 
    475                                         100 * mSpatialFilterSize, 
    476                                         mPvsCache.mPvs, 
    477                                         &mPvsCache.filteredBoxes 
    478                                         ); 
    479 #endif 
    480                         }  
     466                                                                    mUseFilter, 
     467                                                                                                100 * mSpatialFilterSize, 
     468                                                                                                mPvsCache.mPvs, 
     469                                                                                                &mPvsCache.filteredBoxes); 
     470                        } 
    481471                        else 
    482472                        { 
     
    496486                if (mUseSpatialFilter && mRenderBoxes)  
    497487                { 
    498                         for (int i=0; i < mPvsCache.filteredBoxes.size(); i++) 
     488                        for (int i=0; i < mPvsCache.filteredBoxes.size(); ++ i) 
     489                        { 
    499490                                RenderBox(mPvsCache.filteredBoxes[i]); 
     491                        } 
    500492                }  
    501493                else  
     
    507499                        else 
    508500                        { 
     501                                mPvsSize = mPvsCache.mPvs.GetSize(); 
     502 
    509503                                ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
    510504 
    511                                 mPvsSize = mPvsCache.mPvs.GetSize(); 
    512                                 for (; it.HasMoreEntries(); )  
     505                                while (it.HasMoreEntries()) 
    513506                                { 
    514507                                        Intersectable *object = it.Next(pvsData); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ResourceManager.h

    r2176 r2542  
    88#include "Mesh.h" 
    99#include "Material.h" 
     10 
     11 
    1012 
    1113namespace GtpVisibilityPreprocessor { 
     
    124126        ResourceManager<T>() 
    125127        {} 
    126  
    127128        /** Release resources. 
    128129        */ 
     
    137138                } 
    138139        } 
    139    
    140140        /** Copy constructor. 
    141141        */ 
     
    143143    { 
    144144    } 
    145  
    146          /** Helper function returning unique id for resource. 
    147          */ 
     145        /** Helper function returning unique id for resource. 
     146        */ 
    148147        static unsigned int CreateUniqueId() 
    149148        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.cpp

    r2176 r2542  
    3737                                   Vector3 &normal) const 
    3838{ 
    39 #if 0 
    40         VertexContainer vertices; 
    41         vertices.push_back(mVertices[0]); 
    42         vertices.push_back(mVertices[1]); 
    43         vertices.push_back(mVertices[2]); 
    44  
    45         Polygon3 poly(vertices); 
    46  
    47         int dummy = poly.CastRay(ray, t, nearestT); 
    48         normal = poly.GetNormal(); 
    49          
    50         //      cout << "polyversion code: " << dummy << " t: " << t << " nearestT: " << nearestT << endl; 
    51         return dummy; 
    52 #endif 
    53          
    5439        ////////////// 
    5540        // specialised triangle ray casting version 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r2539 r2542  
    25892589 
    25902590/////////////////// 
    2591 // Binary export 
     2591//-- Binary export 
    25922592 
    25932593void ViewCellsTree::ExportBinInterior(OUT_STREAM &stream, ViewCellInterior *interior) 
    25942594{ 
    2595 #if TODO 
    25962595        int interiorid = TYPE_INTERIOR; 
    25972596        stream.write(reinterpret_cast<char *>(&interiorid), sizeof(int)); 
    2598  
    2599         int axis = interior->GetAxis(); 
    2600         float pos = interior->GetPosition(); 
    2601  
    2602         stream.write(reinterpret_cast<char *>(&axis), sizeof(int)); 
    2603         stream.write(reinterpret_cast<char *>(&pos), sizeof(float)); 
    2604 #endif 
    26052597} 
    26062598 
     
    26082600void ViewCellsTree::ExportBinLeaf(OUT_STREAM &stream, ViewCell *leaf) 
    26092601{ 
    2610 #if TODO 
    26112602        int type = TYPE_LEAF; 
    26122603 
    2613         int id = -1; 
    2614         if (viewCell != mOutOfBoundsCell) 
    2615                 id = viewCell->GetId(); 
     2604        int id = leaf->GetId(); 
    26162605 
    26172606        stream.write(reinterpret_cast<char *>(&type), sizeof(int)); 
    26182607        stream.write(reinterpret_cast<char *>(&id), sizeof(int)); 
    26192608 
    2620         int pvsSize = viewCell->GetPvs().GetSize(); 
     2609        int pvsSize = leaf->GetPvs().GetSize(); 
    26212610        stream.write(reinterpret_cast<char *>(&pvsSize), sizeof(int)); 
    26222611 
    2623         ObjectPvsIterator pit = viewCell->GetPvs().GetIterator(); 
    2624  
    2625         // write PVS of view cell 
     2612        ObjectPvsIterator pit = leaf->GetPvs().GetIterator(); 
     2613 
     2614        // write pvs 
    26262615        while (pit.HasMoreEntries()) 
    26272616        { 
     
    26302619                stream.write(reinterpret_cast<char *>(&id), sizeof(int)); 
    26312620        } 
    2632 #endif 
    26332621} 
    26342622 
     
    26362624bool ViewCellsTree::ExportBinary(OUT_STREAM &stream) 
    26372625{ 
    2638 #if TODO 
     2626 
    26392627        // export binary version of mesh 
    26402628        queue<ViewCell *> tStack; 
     
    26522640                else 
    26532641                { 
    2654                         VspInterior *interior = static_cast<ViewCellInterior *>(node); 
    2655  
     2642                        ViewCellInterior *interior = static_cast<ViewCellInterior *>(node); 
     2643 
     2644                        // export current interior 
    26562645                        ExportBinInterior(stream, interior); 
    26572646                         
    2658                         tStack.push(interior->GetFront()); 
    2659                         tStack.push(interior->GetBack()); 
    2660                 } 
    2661         } 
    2662 #endif 
     2647                        // push children 
     2648                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     2649 
     2650                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     2651                        { 
     2652                                tStack.push(*it); 
     2653                        } 
     2654                } 
     2655        } 
     2656 
    26632657        return true; 
    26642658} 
     
    26662660 
    26672661////////////////// 
    2668 // import binary 
     2662//-- import binary 
    26692663 
    26702664ViewCellInterior *ViewCellsTree::ImportBinInterior(IN_STREAM  &stream, ViewCellInterior *parent) 
     
    27252719 
    27262720 
    2727 /** Data used for tree traversal 
    2728 */ 
    2729 struct MyTraversalData 
    2730  
    2731 public: 
    2732  
    2733         MyTraversalData(ViewCell *node, const int depth, const AxisAlignedBox3 &box): 
    2734         mNode(node), mDepth(depth), mBox(box) 
    2735         {} 
    2736  
    2737  
    2738         ////////////////////// 
    2739  
    2740         /// the current node 
    2741         ViewCell *mNode; 
    2742         /// current depth 
    2743         int mDepth; 
    2744         /// the bounding box 
    2745         AxisAlignedBox3 mBox; 
    2746 }; 
    2747  
    2748  
    27492721bool ViewCellsTree::ImportBinary(IN_STREAM &stream, const ObjectContainer &pvsObjects) 
    27502722{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2539 r2542  
    3434#define PVS_ADD_DIRTY 1 
    3535 
     36 
     37 
    3638namespace GtpVisibilityPreprocessor { 
    3739 
     
    4648const static bool CLAMP_TO_BOX = true; 
    4749 
     50 
     51 
     52inline static bool ilt(Intersectable *obj1, Intersectable *obj2) 
     53{ 
     54        return obj1->mId < obj2->mId; 
     55} 
    4856 
    4957 
     
    9941002        EvaluateViewCellsStats(); 
    9951003 
    996         if (1) CompressViewCells(); 
     1004        // compress the final solution 
     1005        if (0) CompressViewCells(); 
    9971006 
    9981007        // write view cells to disc 
     
    10211030                                                                                                  
    10221031{ 
     1032        if (!Debug.is_open()) Debug.open("debug.log"); 
     1033 
    10231034        // give just an empty container as parameter: 
    10241035        // this loading function is used in the engine, thus it 
    10251036        // does not need to load the entities the preprocessor works on 
    10261037        ObjectContainer preprocessorObjects; 
    1027  
    1028         if (!Debug.is_open()) Debug.open("debug.log"); 
    10291038 
    10301039        return LoadViewCells(filename,  
     
    10331042                                                 finalizeViewCells, 
    10341043                                                 bconverter); 
     1044} 
     1045 
     1046 
     1047void ViewCellsManager::LoadIndexedBoundingBoxes(IN_STREAM &stream, IndexedBoundingBoxContainer &iboxes) 
     1048{ 
     1049        Vector3 bmin; 
     1050        Vector3 bmax; 
     1051        int id; 
     1052 
     1053        stream.read(reinterpret_cast<char *>(&bmin), sizeof(Vector3)); 
     1054        stream.read(reinterpret_cast<char *>(&bmax), sizeof(Vector3)); 
     1055        stream.read(reinterpret_cast<char *>(&id), sizeof(int)); 
     1056 
     1057        AxisAlignedBox3 box(bmin, bmax); 
     1058 
     1059        iboxes.push_back(IndexedBoundingBox(id, box)); 
     1060        //Debug << "bbox: " << box << endl; 
     1061} 
     1062 
     1063 
     1064ViewCellsManager *ViewCellsManager::LoadViewCellsBin(const string &filename,  
     1065                                                                                                         ObjectContainer &pvsObjects, 
     1066                                                                                                         ObjectContainer &preprocessorObjects, 
     1067                                                                                                         bool finalizeViewCells, 
     1068                                                                                                         BoundingBoxConverter *bconverter) 
     1069{ 
     1070        IN_STREAM stream(filename.c_str()); 
     1071         
     1072        IndexedBoundingBoxContainer iboxes; 
     1073        LoadIndexedBoundingBoxes(stream, iboxes); 
     1074 
     1075        if (bconverter) 
     1076        { 
     1077                // all bounding boxes gathered in this step =>  
     1078                // associate object ids with bounding boxes 
     1079                bconverter->IdentifyObjects(iboxes, pvsObjects); 
     1080        } 
     1081 
     1082        // sort objects by id 
     1083        sort(pvsObjects.begin(), pvsObjects.end(), ilt); 
     1084 
     1085        ViewCellsTree *vcTree = new ViewCellsTree(); 
     1086        VspTree *vspTree = new VspTree(); 
     1087 
     1088        HierarchyManager *hm = new HierarchyManager(0); 
     1089 
     1090        vspTree->ImportBinary(stream, pvsObjects); 
     1091         
     1092        VspOspViewCellsManager *vcm = new VspOspViewCellsManager(vcTree, hm); 
     1093 
     1094        return vcm; 
    10351095} 
    10361096 
     
    10611121        } 
    10621122         
    1063         if (0) //hack: should work with reset function, but something is wrong .. 
     1123        if (0) //hack: reset function should work, but something is wrong .. 
    10641124        { 
    10651125                vm->ResetViewCells(); 
     
    11041164                                                                                         const ObjectContainer &objects) 
    11051165{ 
     1166        // no view cells constructed yet 
    11061167        if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 
    1107         { 
    11081168                return false; 
    1109         } 
    11101169 
    11111170        cout << "exporting view cells to xml ... "; 
     
    24242483 
    24252484 
    2426  
    2427                   if (evaluateFilter) { 
     2485                  if (evaluateFilter)  
     2486                  { 
    24282487                          ObjectPvs filteredPvs; 
    24292488 
    2430                           PvsFilterStatistics fstat = ApplyFilter2(viewcell, 
    2431                                   false, 
    2432                                   mFilterWidth, 
    2433                                   filteredPvs); 
    2434  
    2435                           float filteredCost = filteredPvs.EvalPvsCost(); 
     2489                          PvsFilterStatistics fstat = ApplyFilter2(viewcell, false, mFilterWidth, filteredPvs); 
     2490 
     2491                          const float filteredCost = filteredPvs.EvalPvsCost(); 
    24362492 
    24372493                          stat.avgFilteredPvs += filteredCost; 
     
    30703126                        MeshInstance *mi = static_cast<MeshInstance *>(*it); 
    30713127                        const AxisAlignedBox3 box = mi->GetBox(); 
     3128                         
    30723129                        Vector3 bmin = box.Min(); 
    30733130                        Vector3 bmax = box.Max(); 
     3131                         
    30743132                        int id = mi->GetId(); 
    30753133 
     
    34443502 
    34453503        // Minimal number of samples so that filtering takes place 
    3446 #define MIN_SAMPLES  50 
     3504        const float MIN_SAMPLES = 50; 
    34473505 
    34483506        if (samples > MIN_SAMPLES)  
     
    35373595        } 
    35383596 
    3539         Debug << " nPvs size = " << pvs.GetSize() << endl; 
     3597        //Debug << " nPvs size = " << pvs.GetSize() << endl; 
    35403598 
    35413599        if (!mUseKdPvs) 
     
    58875945 
    58885946 
    5889 Intersectable * 
    5890 VspOspViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 
     5947Intersectable *VspOspViewCellsManager::GetIntersectable(const VssRay &ray,  
     5948                                                                                                                const bool isTermination) const 
    58915949{ 
    58925950        if (mUseKdPvs) 
     
    63876445                        const bool exportBounds = false; 
    63886446 
    6389                         if (1) 
    63906447                        mHierarchyManager->ExportObjectSpaceHierarchy(exporter,  
    63916448                                                                      objects,  
     
    65756632                                                                                         const ObjectContainer &objects) 
    65766633{ 
     6634        // no view cells were computed 
    65776635        if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 
    65786636                return false; 
     6637 
     6638        cout << "exporting binary" << endl; 
     6639        string fname("test.vc"); 
     6640        return ExportBinaryViewCells(fname, exportPvs, objects); 
    65796641 
    65806642        const long starttime = GetTime(); 
     
    66126674 
    66136675                                stream << "<BoundingBox" << " id=\"" << id << "\"" 
    6614                                    << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    6615                                    << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
     6676                                           << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
     6677                                       << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
    66166678                        } 
     6679 
    66176680                        stream << "</BoundingBoxes>" << endl; 
    66186681                } 
     
    66616724                                                                                                   const ObjectContainer &objects) 
    66626725{ 
     6726        // no view cells constructed yet 
    66636727        if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 
    66646728                return false; 
     
    66786742    /////////////// 
    66796743        //-- export bounding boxes 
    6680         //-- we need the boxes to identify objects in the target engine 
    6681  
     6744 
     6745        // we use bounding box intersection to identify pvs objects in the target engine 
    66826746        vector<KdIntersectable *>::const_iterator kit, kit_end = mPreprocessor->mKdTree->mKdIntersectables.end(); 
    66836747 
     
    66896753                const AxisAlignedBox3 &box = obj->GetBox(); 
    66906754 
    6691                 // set kd node id 
     6755                // setting the kd node id important to identify the kd node as pvs entry 
    66926756                obj->SetId(id); 
     6757 
    66936758                Vector3 bmin = box.Min(); 
    66946759                Vector3 bmax = box.Max(); 
     
    67036768        //-- export the view cells and the pvs 
    67046769 
    6705  
    67066770        int numViewCells = mCurrentViewCellsStats.viewCells; 
    67076771        stream.write(reinterpret_cast<char *>(&numViewCells), sizeof(int)); 
     
    67126776        stream.write(reinterpret_cast<char *>(&vmin), sizeof(Vector3)); 
    67136777        stream.write(reinterpret_cast<char *>(&vmax), sizeof(Vector3)); 
     6778 
     6779        // todo 
     6780        mViewCellsTree->ExportBinary(stream); 
    67146781 
    67156782 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2539 r2542  
    520520                                                                                   BoundingBoxConverter *bconverter = NULL); 
    521521 
     522        /** Convenience function assuming that there are no preprocessor objects. 
     523        */ 
    522524        static ViewCellsManager *LoadViewCells(const string &filename,  
    523525                                                                                   ObjectContainer &pvsObjects, 
     
    525527                                                                                   BoundingBoxConverter *bconverter = NULL); 
    526528 
     529        ViewCellsManager *LoadViewCellsBin(const string &filename,  
     530                                           ObjectContainer &pvsObjects, 
     531                                                                           ObjectContainer &preprocessorObjects, 
     532                                                                           bool finalizeViewCells, 
     533                                                                           BoundingBoxConverter *bconverter); 
     534 
     535 
    527536        /////////////////////// 
    528         // visiblity filter options 
     537        //-- visiblity filter options 
    529538 
    530539        // TODO: write own visibiltiy filter class 
     
    636645                                                const vector<int> &strategies, 
    637646                                                VssRayContainer &vssRays) const; 
    638  
     647        /** cast samples for the purpose of evaluating the view cells solution 
     648        */ 
    639649        int CastEvaluationSamples(const int samplesPerPass,  
    640650                                                          VssRayContainer &passSamples);// const; 
     
    660670        */ 
    661671        void EvaluateViewCellsStats(); 
     672        /** This helper function loads the bounding boxes for a binary solution. 
     673        */ 
     674        void LoadIndexedBoundingBoxes(IN_STREAM &stream, IndexedBoundingBoxContainer &iboxes); 
    662675 
    663676 
     
    11351148{ 
    11361149        friend class ViewCellsParseHandlers; 
     1150        friend class ViewCellsManager; 
    11371151 
    11381152public: 
    11391153 
     1154        /** This version takes a view cells tree and a hierarchy 
     1155                as input. 
     1156        */ 
    11401157        VspOspViewCellsManager(ViewCellsTree *vcTree,  
    11411158                                                   const string &hierarchyType); 
     
    11961213                                                           const string &prefix, 
    11971214                                                           VssRayContainer *visRays = NULL); 
    1198          
    1199         ; 
    12001215        /** See parent class. 
    12011216        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r2539 r2542  
    6060//      can be set via the -v= command. 
    6161// --------------------------------------------------------------------------- 
    62 static bool     doNamespaces      = false; 
    63 static bool     doSchema          = false; 
    64 static bool     schemaFullChecking = false; 
    65 static SAXParser::ValSchemes    valScheme      = SAXParser::Val_Auto; 
     62static bool doNamespaces = false; 
     63static bool doSchema = false; 
     64static bool schemaFullChecking = false; 
     65static SAXParser::ValSchemes valScheme = SAXParser::Val_Auto; 
    6666 
    6767// hack for loading bvh nodes 
     
    313313        else 
    314314        { 
     315                // sort objects by id 
    315316                sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 
    316317        } 
     
    318319        Debug << "\nconverted bounding boxes to objects in " 
    319320                  << TimeDiff(startTime, GetTime()) * 1e-6 << " secs" << endl; 
     321 
    320322        mBoxTimer.Exit(); 
    321323} 
     
    693695                string attrName(StrX(attributes.getName(i)).LocalForm()); 
    694696                StrX attrValue(attributes.getValue(i)); 
     697 
    695698                const char *ptr = attrValue.LocalForm(); 
    696699 
     
    711714        AxisAlignedBox3 box(bmin, bmax); 
    712715        mIBoundingBoxes.push_back(IndexedBoundingBox(id, box)); 
    713         //Debug << "bbox: " << box << endl; 
    714716} 
    715717 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r2539 r2542  
    792792         
    793793        mPlaneTimer.Exit(); 
    794  
    795794        mEvalTimer.Entry(); 
    796795 
    797796        VspLeaf *leaf = static_cast<VspLeaf *>(splitCandidate.mParentData.mNode); 
     797 
    798798 
    799799        ////////////// 
     
    832832 
    833833#if COUNT_ORIGIN_OBJECTS 
    834  
    835834                obj = (*ray).mOriginObject; 
    836835 
     
    838837                { 
    839838                        leaf = mBvHierarchy->GetLeaf(obj); 
    840  
    841839                        UpdateContributionsToPvs(leaf, cf, sData);  
    842840                } 
     
    32273225 
    32283226void VspTree::AddCandidateToDirtyList(const VssRay &ray,  
    3229                                                                 const bool isTermination, 
    3230                                                                 vector<SubdivisionCandidate *> &dirtyList, 
    3231                                                                 const bool onlyUnmailed) const 
     3227                                                                          const bool isTermination, 
     3228                                                                          vector<SubdivisionCandidate *> &dirtyList, 
     3229                                                                          const bool onlyUnmailed) const 
    32323230 
    32333231{ 
    32343232#if HACK_PERFORMANCE 
    3235  
    32363233        Intersectable *obj = isTermination ? ray.mTerminationObject : ray.mOriginObject;  
    32373234 
     
    32513248        } 
    32523249#else 
    3253  
    32543250        SubdivisionCandidate *candidate = NULL; 
    32553251 
     
    33793375                        // simple render cost evaluation 
    33803376                        if (-- leaf->mCounter == 0) 
    3381                                 //pvs += (int)leaf->mObjects.size(); 
    33823377                                pvs += BvHierarchy::EvalAbsCost(leaf->mObjects); 
     3378 
    33833379                        break; 
    33843380                } 
     
    34663462        return pvsSize; 
    34673463#endif 
    3468          
    34693464} 
    34703465 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r2332 r2542  
    254254{ 
    255255        //debuggerWidget = new GlDebuggerWidget(renderer); 
    256         //  renderer->resize(640, 480); 
     256        //renderer->resize(640, 480); 
    257257        //debuggerWidget->resize(640, 480); 
    258258 
     
    265265        exporter->ExportGeometry(objects); 
    266266        exporter->SetFilled(); 
     267         
    267268        //Randomize(); 
    268 // §§matt 
    269 //      debuggerWidget = new GlDebuggerWidget(renderer); 
    270  
    271         /*debuggerWidget->mBeam = beam; 
     269        //§§matt 
     270        //debuggerWidget = new GlDebuggerWidget(renderer); 
     271 
     272        /* 
     273        debuggerWidget->mBeam = beam; 
    272274        debuggerWidget->mSourceObject = sourceObj; 
    273275        debuggerWidget->mSamples = 10000; 
     
    276278        debuggerWidget->show(); 
    277279         
    278         renderer->makeCurrent();*/ 
     280        renderer->makeCurrent(); 
     281        */ 
    279282 
    280283        for (int i = 0; i < 10; ++ i) 
     
    299302 
    300303                BeamSampleStatistics stats; 
    301 // §§matt 
    302 /*              renderer->SampleBeamContributions(sourceObj, 
     304 
     305                // §§matt 
     306                /*       
     307                renderer->SampleBeamContributions(sourceObj, 
    303308                                                                                  beam, 
    304309                                                                                  200000, 
     
    310315                image.save(s, "PNG"); 
    311316                Debug << "beam statistics: " << stats << endl << endl; 
    312 */ 
     317                */ 
     318 
    313319                if (1) 
    314320                { 
     
    321327                } 
    322328 
    323                 bool exportViewCells = false; 
     329                const bool exportViewCells = false; 
     330 
    324331                if (exportViewCells) 
    325332                { 
     
    338345                                exporter->ExportViewCell(*it); 
    339346                        } 
    340  
    341                         /*vector<KdNode *>::const_iterator it, it_end = beam.mKdNodes.end(); 
    342                          
    343                         for (it = beam.mKdNodes.begin(); it != beam.mKdNodes.end(); ++ it) 
    344                         { 
    345                                 exporter->ExportBox(mKdTree->GetBox((*it))); 
    346                         }*/ 
    347347                } 
    348348        } 
    349         /*while (1) 
    350         { debuggerWidget->repaint(); 
    351         };*/ 
     349         
    352350        delete exporter; 
    353351} 
     
    376374        int totalSamples = 0; 
    377375 
    378         //mSceneGraph->CollectObjects(&mObjects); 
    379  
    380376        if (!mLoadViewCells) 
    381377        { 
    382                 //-- generate new view cells from the scratch 
    383                 //-- for construction the manager uses it's own set of samples 
     378                // generate new view cells from the scratch using coarse sampling 
    384379                ConstructViewCells(); 
    385380        } 
     
    387382        else  
    388383        {         
    389                 //-- load view cells from file 
    390                 //-- test successful view cells loading by exporting them again 
    391                 VssRayContainer dummies; 
    392                 mViewCellsManager->Visualize(mObjects, dummies); 
     384                // load view cells from file 
     385                // we test success by exporting view cells again 
     386                VssRayContainer dummyContainer; 
     387                mViewCellsManager->Visualize(mObjects, dummyContainer); 
     388                 
    393389                mViewCellsManager->ExportViewCells("test.xml.zip", mViewCellsManager->GetExportPvs(), mObjects); 
    394390        } 
     
    401397        { 
    402398                cout << "Loading samples from file ... "; 
     399                 
    403400                LoadSamples(mVssRays, mObjects); 
     401                 
    404402                cout << "finished\n" << endl; 
    405403                totalSamples = (int)mVssRays.size(); 
Note: See TracChangeset for help on using the changeset viewer.