Changeset 1640


Ignore:
Timestamp:
10/18/06 18:17:27 (18 years ago)
Author:
mattausch
Message:

worked on vsp osp methodsd

Location:
GTP/trunk/Lib/Vis
Files:
12 edited

Legend:

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

    r1623 r1640  
    160160void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam) 
    161161{ 
    162         //Ogre::LogManager::getSingleton().logMessage("here4"); 
    163162        // add player camera for visualization purpose 
    164163        try  
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.env

    r1633 r1640  
    184184VspTree { 
    185185        Construction { 
    186                 samples 100000 
    187186        } 
    188187 
     
    225224         
    226225        Construction { 
    227                 # type 0 = sequential computation, type 1=interleaved 
    228                 type 2 
     226 
     227                samples 100000 
     228 
     229                # type 0 = sequential computation, 1 = interleaved, 2 = gradient 
     230                type 1 
     231 
    229232                # if the object space should be subdivided first (if false, the view space is subdivided first) 
    230233                startWithObjectSpace true 
     
    233236                # only for interleaved method 
    234237 
    235                 # only for interleaved method: the minimum depth for object space partition 
    236                 minDepthForOsp 7 
    237                 # the minimum depth for view space partition 
    238                 minDepthForVsp 7 
    239  
    240238                # if dirty split candidates are reevaluated  
    241                 repairQueue false 
     239                repairQueue true 
     240 
     241                # recompute split plane when "repairing" a candidate 
     242                recomputeSplitPlaneOnRepair false 
    242243 
    243244                ################################################### 
     
    249250                levels 4 
    250251 
    251                 # recompute split plane when "repairing" a candidate 
    252                 recomputeSplitPlaneOnRepair true 
     252                # minimal steps of same type: for interleaved, this is only valid for the first few splits 
     253                minStepsOfSameType 200 
    253254        } 
    254255 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh

    r1633 r1640  
    1212 
    1313SCENE=vsposp_typical 
     14#SCENE=vsposp_vienna 
    1415#SCENE=soda5 
    1516#SCENE=cube 
     
    2526 
    2627 
    27 METHOD=sequential 
     28METHOD=interleaved_full 
    2829echo "$SCENE $METHOD" 
    2930 
     
    3435-bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
    3536-hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
    36 -hierarchy_construction_start_with_osp=true 
     37-hierarchy_construction_type=1 \ 
     38-hierarchy_construction_recompute_split_on_repair=true 
    3739 
    3840mv debug.log $LOG_PREFIX-$METHOD-debug.log 
     
    4042mv final_object_partition.wrl $LOG_PREFIX-$METHOD-final_object_partition.wrl 
    4143mv final_view_cells.wrl $LOG_PREFIX-$METHOD-final_view_cells.wrl 
     44 
     45 
     46METHOD=interleaved 
     47echo "$SCENE $METHOD" 
     48 
     49$PROGRAM $ENVIRONMENT \ 
     50-view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     51-view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     52-vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     53-bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     54-hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     55-hierarchy_construction_type=1 \ 
     56-hierarchy_construction_recompute_split_on_repair=false 
     57 
     58mv debug.log $LOG_PREFIX-$METHOD-debug.log 
     59mv view_cells.wrl $LOG_PREFIX-$METHOD-view_cells.wrl 
     60mv final_object_partition.wrl $LOG_PREFIX-$METHOD-final_object_partition.wrl 
     61mv final_view_cells.wrl $LOG_PREFIX-$METHOD-final_view_cells.wrl 
     62 
     63 
     64METHOD=gradient 
     65echo "$SCENE $METHOD" 
     66 
     67$PROGRAM $ENVIRONMENT \ 
     68-view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     69-view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     70-vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     71-bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     72-hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     73-hierarchy_construction_type=2 \ 
     74-hierarchy_construction_recompute_split_on_repair=true 
     75 
     76mv debug.log $LOG_PREFIX-$METHOD-debug.log 
     77mv view_cells.wrl $LOG_PREFIX-$METHOD-view_cells.wrl 
     78mv final_object_partition.wrl $LOG_PREFIX-$METHOD-final_object_partition.wrl 
     79mv final_view_cells.wrl $LOG_PREFIX-$METHOD-final_view_cells.wrl 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1636 r1640  
    15011501                mHierarchyManager->mVspTree->GetViewCells(*ray, tmpViewCells); 
    15021502 
     1503                // matt: probably slow to allocate memory for view cells every time 
    15031504                ViewCellContainer::const_iterator vit, vit_end = tmpViewCells.end(); 
    15041505 
     
    17861787 
    17871788 
    1788 void BvHierarchy::CreateRoot(const ObjectContainer &objects) 
     1789void BvHierarchy::Initialise(const ObjectContainer &objects) 
    17891790{ 
    17901791        /////// 
     
    17961797        mRoot = bvhleaf; 
    17971798 
     1799        // compute bounding box from objects 
     1800        mBoundingBox = mRoot->GetBoundingBox(); 
     1801 
    17981802        // associate root with current objects 
    17991803        AssociateObjectsWithLeaf(bvhleaf); 
    18001804} 
     1805 
    18011806 
    18021807/* 
     
    18311836        BvhSubdivisionCandidate::sBvHierarchy = this; 
    18321837         
    1833         // create new root 
    1834         CreateRoot(objects); 
    1835  
    1836         // compute bounding box from objects 
    1837         mBoundingBox = mRoot->GetBoundingBox(); 
     1838        // root and bounding box was already constructed 
    18381839        BvhLeaf *bvhLeaf = dynamic_cast<BvhLeaf *>(mRoot); 
    18391840 
     
    19611962        // reset root 
    19621963        DEL_PTR(mRoot); 
    1963         CreateRoot(objects); 
     1964         
     1965        BvhLeaf *bvhleaf = new BvhLeaf(mBoundingBox, NULL, (int)objects.size()); 
     1966        bvhleaf->mObjects = objects; 
     1967        mRoot = bvhleaf; 
    19641968         
    19651969#if PROBABILIY_IS_BV_VOLUME 
     
    20722076 
    20732077 
    2074 } 
     2078// TODO: return memory usage in MB 
     2079float BvHierarchy::GetMemUsage() const 
     2080{ 
     2081        return (float) 
     2082                 (sizeof(BvHierarchy) 
     2083                  + mBvhStats.Leaves() * sizeof(BvhLeaf)  
     2084                  + mBvhStats.Interior() * sizeof(BvhInterior) 
     2085                  ) / (1024.0f * 1024.0f); 
     2086} 
     2087 
     2088 
     2089} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1633 r1640  
    544544        BvhIntersectable *GetOrCreateBvhIntersectable(BvhNode *node); 
    545545 
    546         /** Collects rays. 
     546        /** Collects rays associated with the objects. 
    547547        */ 
    548548        void CollectRays(const ObjectContainer &objects, VssRayContainer &rays) const; 
     
    551551                @returns number of view cells found 
    552552        */ 
    553         int ComputeBoxIntersections( 
    554                 const AxisAlignedBox3 &box,  
    555                 ViewCellContainer &viewCells) const; 
     553        int ComputeBoxIntersections(const AxisAlignedBox3 &box,  
     554                                                                ViewCellContainer &viewCells) const; 
    556555 
    557556        /** Returns leaf the point pt lies in, starting from root. 
     
    566565        void SetViewCellsTree(ViewCellsTree *vt) { mViewCellsTree = vt; } 
    567566 
     567        /** Returns estimated memory usage of tree. 
     568        */ 
     569        float GetMemUsage() const; 
    568570 
    569571protected: 
     
    598600        /** Evaluate balanced object partition. 
    599601        */ 
    600         float EvalLocalObjectPartition( 
    601                 const BvhTraversalData &tData, 
    602                 const int axis, 
    603                 ObjectContainer &objectsFront, 
    604                 ObjectContainer &objectsBack); 
    605  
    606         float EvalSah( 
    607                 const BvhTraversalData &tData, 
    608                 const int axis, 
    609                 ObjectContainer &objectsFront, 
    610                 ObjectContainer &objectsBack); 
     602        float EvalLocalObjectPartition(const BvhTraversalData &tData, 
     603                                                                   const int axis, 
     604                                                                   ObjectContainer &objectsFront, 
     605                                                                   ObjectContainer &objectsBack); 
     606 
     607        /** Evaluate surface area heuristic for the node. 
     608        */ 
     609        float EvalSah(const BvhTraversalData &tData, 
     610                                  const int axis, 
     611                                  ObjectContainer &objectsFront, 
     612                                  ObjectContainer &objectsBack); 
    611613 
    612614        /** Computes priority of the traversal data and stores it in tData. 
     
    628630                @returns new root of the subtree 
    629631        */ 
    630         BvhNode *Subdivide( 
    631                 SplitQueue &tQueue,  
    632                 SubdivisionCandidate *splitCandidate, 
    633                 const bool globalCriteriaMet); 
     632        BvhNode *Subdivide(SplitQueue &tQueue,  
     633                                           SubdivisionCandidate *splitCandidate, 
     634                                           const bool globalCriteriaMet); 
    634635         
    635636        /** Subdivides leaf. 
     
    641642                @returns the new interior node = the of the subdivision 
    642643        */ 
    643         BvhInterior *SubdivideNode( 
    644                 const BvhSubdivisionCandidate &sc, 
    645                 BvhTraversalData &frontData, 
    646                 BvhTraversalData &backData); 
     644        BvhInterior *SubdivideNode(const BvhSubdivisionCandidate &sc, 
     645                                                           BvhTraversalData &frontData, 
     646                                                           BvhTraversalData &backData); 
    647647 
    648648        /** Splits the objects for the next subdivision. 
    649649                @returns cost for this split 
    650650        */ 
    651         float SelectObjectPartition( 
    652                 const BvhTraversalData &tData, 
    653                 ObjectContainer &frontObjects, 
    654                 ObjectContainer &backObjects); 
     651        float SelectObjectPartition(const BvhTraversalData &tData, 
     652                                                                ObjectContainer &frontObjects, 
     653                                                                ObjectContainer &backObjects); 
    655654         
    656655        /** Writes the node to disk 
     
    659658        void ExportNode(BvhNode *node, OUT_STREAM &stream); 
    660659 
     660        /** Exports objects associated with this leaf. 
     661        */ 
    661662        void ExportObjects(BvhLeaf *leaf, OUT_STREAM &stream); 
    662  
    663         /** Returns estimated memory usage of tree. 
    664         */ 
    665         float GetMemUsage() const; 
    666663 
    667664        /** Associates the objects with their bvh leaves. 
     
    677674                @param axis the current split axis 
    678675        */ 
    679         void PrepareLocalSubdivisionCandidates( 
    680                 const BvhTraversalData &tData, 
    681                 const int axis); 
    682  
    683         static void CreateLocalSubdivisionCandidates( 
    684                 const ObjectContainer &objects,  
    685                 SortableEntryContainer **subdivisionCandidates, 
    686                 const bool sort, 
    687                 const int axis); 
     676        void PrepareLocalSubdivisionCandidates(const BvhTraversalData &tData, 
     677                                                                                   const int axis); 
     678 
     679        static void CreateLocalSubdivisionCandidates(const ObjectContainer &objects,  
     680                                                                                                 SortableEntryContainer **subdivisionCandidates, 
     681                                                                                                 const bool sort, 
     682                                                                                                 const int axis); 
    688683 
    689684        /** Computes object partition with the best cost according to the heurisics. 
     
    696691                @returns relative cost (relative to parent cost) 
    697692        */ 
    698         float EvalLocalCostHeuristics( 
    699                 const BvhTraversalData &tData, 
    700                 const int axis, 
    701                 ObjectContainer &objectsFront, 
    702                 ObjectContainer &objectsBack); 
     693        float EvalLocalCostHeuristics(const BvhTraversalData &tData, 
     694                                                                  const int axis, 
     695                                                                  ObjectContainer &objectsFront, 
     696                                                                  ObjectContainer &objectsBack); 
    703697 
    704698        /** Evaluates the contribution to the front and back volume 
     
    709703                @param volPvs updates the right pvs 
    710704        */ 
    711         void EvalHeuristicsContribution( 
    712                 Intersectable *obj, 
    713                 float &volLeft,  
    714                 float &volRight); 
     705        void EvalHeuristicsContribution(Intersectable *obj, 
     706                                                                        float &volLeft,  
     707                                                                        float &volRight); 
    715708 
    716709        /** Prepares objects for the cost heuristics. 
     
    729722        /** Prepares construction for vsp and osp trees. 
    730723        */ 
    731         AxisAlignedBox3 EvalBoundingBox( 
    732                 const ObjectContainer &objects,  
    733                 const AxisAlignedBox3 *parentBox = NULL) const; 
     724        AxisAlignedBox3 EvalBoundingBox(const ObjectContainer &objects,  
     725                                                                        const AxisAlignedBox3 *parentBox = NULL) const; 
    734726 
    735727        /** Collects list of invalid candidates. Candidates 
     
    737729                that affects this candidate. 
    738730        */ 
    739         void CollectDirtyCandidates( 
    740                 BvhSubdivisionCandidate *sc, 
    741                 vector<SubdivisionCandidate *> &dirtyList, 
    742                 const bool onlyUnmailed); 
     731        void CollectDirtyCandidates(BvhSubdivisionCandidate *sc, 
     732                                                                vector<SubdivisionCandidate *> &dirtyList, 
     733                                                                const bool onlyUnmailed); 
    743734 
    744735        /** Collect view cells which see this bvh leaf. 
    745736        */ 
    746         void CollectViewCells( 
    747                 const ObjectContainer &objects,  
    748                 ViewCellContainer &viewCells, 
    749                 const bool setCounter = false) const; 
     737        void CollectViewCells(const ObjectContainer &objects,  
     738                                                  ViewCellContainer &viewCells, 
     739                                                  const bool setCounter = false) const; 
    750740 
    751741        /** Counts the view cells of this object. note: only 
     
    760750        /** Collects view cells which see an object. 
    761751        */ 
    762         void CollectViewCells( 
    763                 Intersectable *object,  
    764                 ViewCellContainer &viewCells,  
    765                 const bool useMailBoxing, 
    766                 const bool setCounter = false) const; 
     752        void CollectViewCells(Intersectable *object,  
     753                                                  ViewCellContainer &viewCells,  
     754                                                  const bool useMailBoxing, 
     755                                                  const bool setCounter = false) const; 
    767756 
    768757        /** Evaluates increase in pvs size. 
     
    772761        /** Rays will be clipped to the bounding box. 
    773762        */ 
    774         void PreprocessRays( 
    775                 BvhLeaf *root,  
    776                 const VssRayContainer &sampleRays, 
    777                 RayInfoContainer &rays); 
     763        void PreprocessRays(BvhLeaf *root,  
     764                                                const VssRayContainer &sampleRays, 
     765                                                RayInfoContainer &rays); 
    778766 
    779767        /** Print the subdivision stats in the subdivison log. 
     
    783771        /** Prints out the stats for this subdivision. 
    784772        */ 
    785         void AddSubdivisionStats( 
    786                 const int viewCells, 
    787                 const float renderCostDecr, 
    788                 const float totalRenderCost); 
     773        void AddSubdivisionStats(const int viewCells, 
     774                                                         const float renderCostDecr, 
     775                                                         const float totalRenderCost); 
    789776 
    790777        /** Stores rays with objects that see the rays. 
     
    800787                the first subdivision candidate. 
    801788        */ 
    802         SubdivisionCandidate *PrepareConstruction( 
    803                 const VssRayContainer &sampleRays, 
    804                 const ObjectContainer &objects); 
     789        SubdivisionCandidate *PrepareConstruction(const VssRayContainer &sampleRays, 
     790                                                                                          const ObjectContainer &objects); 
    805791 
    806792        /** Resets bv hierarchy. E.g. deletes root and resets stats. 
    807793        */ 
    808         SubdivisionCandidate *Reset( 
    809                 const VssRayContainer &rays,  
    810                 const ObjectContainer &objects); 
     794        SubdivisionCandidate *Reset(const VssRayContainer &rays,  
     795                                                                const ObjectContainer &objects); 
    811796 
    812797        /** Evaluates volume of view cells that see the objects. 
     
    820805        /** Assigns sorted objects to front and back data. 
    821806        */ 
    822         void AssignSortedObjects( 
    823                 const BvhSubdivisionCandidate &sc, 
    824                 BvhTraversalData &frontData, 
    825                 BvhTraversalData &backData); 
    826          
    827         /** Creates new root of hierarchy. 
    828         */ 
    829         void CreateRoot(const ObjectContainer &objects); 
    830 /*void 
    831 RenderBvhNode(BvhNode *node) 
    832 { 
    833   if (node->IsLeaf()) { 
    834         BvhLeaf *leaf = (BvhLeaf *) node; 
    835         for (int i=0; i < mObjects.size(); i++) 
    836                 cout << "leaf obj " << i << endl; 
    837           //RenderIntersectable(mObjects[i]); 
    838   } else { 
    839         BvhInterior *in = (BvhInterior *)node; 
    840         RenderBvhNode(in->GetBack()); 
    841         RenderBvhNode(in->GetFront()); 
    842   } 
    843    
    844 }*/ 
     807        void AssignSortedObjects(const BvhSubdivisionCandidate &sc, 
     808                                                         BvhTraversalData &frontData, 
     809                                                         BvhTraversalData &backData); 
     810         
     811        /** Creates new root of hierarchy and computes bounding box. 
     812                Has to be called before the preparation of the subdivision. 
     813        */ 
     814        void Initialise(const ObjectContainer &objects); 
     815 
     816 
    845817protected: 
    846818         
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1633 r1640  
    21682168                                        "10000"); 
    21692169 
    2170          
    21712170        RegisterOption("VspTree.Construction.renderCostDecreaseWeight", 
    21722171                                optFloat, 
     
    24622461 
    24632462         
     2463 
    24642464        /*******************************************************************/ 
    24652465        /*               Hierarchy Manager related options                 */ 
    24662466        /*******************************************************************/ 
     2467 
     2468        RegisterOption("Hierarchy.Construction.samples", 
     2469                                        optInt, 
     2470                                        "vsp_construction_samples=", 
     2471                                        "100000"); 
     2472 
    24672473 
    24682474        RegisterOption("Hierarchy.subdivisionStats", 
     
    25252531                                        "hierarchy_construction_levels=", 
    25262532                                        "4"); 
    2527  
    2528          
     2533         
     2534        RegisterOption("Hierarchy.Construction.minStepsOfSameType", 
     2535                                        optInt, 
     2536                                        "hierarchy_construction_min_steps_same_type=", 
     2537                                        "200"); 
     2538 
    25292539        RegisterOption("Hierarchy.Construction.recomputeSplitPlaneOnRepair", 
    25302540                                        optBool, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1636 r1640  
    109109                "Hierarchy.Construction.levels", mNumMultiLevels); 
    110110 
     111        Environment::GetSingleton()->GetIntValue( 
     112                "Hierarchy.Construction.minStepsOfSameType", mMinStepsOfSameType); 
     113         
     114 
    111115        char subdivisionStatsLog[100]; 
    112116        Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", subdivisionStatsLog); 
     
    116120                "Hierarchy.Construction.recomputeSplitPlaneOnRepair", mRecomputeSplitPlaneOnRepair); 
    117121 
    118         Debug << "******** Hierachy Manager Parameters ***********" << endl; 
     122        Debug << "******** Hierachy Manager Options ***********" << endl; 
    119123        Debug << "max leaves: " << mTermMaxLeaves << endl; 
    120124        Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 
     
    124128        Debug << "number of multilevels: " << mNumMultiLevels << endl; 
    125129        Debug << "recompute split plane on repair: " << mRecomputeSplitPlaneOnRepair << endl; 
     130        Debug << "minimal number of steps from same type: " << mMinStepsOfSameType << endl; 
    126131 
    127132        switch (mConstructionType) 
     
    228233void HierarchyManager::EvalSubdivisionStats() 
    229234{ 
     235        // TODO 
     236        const float objectSpaceMem = GetObjectSpaceMemUsage(); 
     237        const float viewSpaceMem = mVspTree->GetMemUsage(); 
     238         
     239        // calculate cost in MB 
     240        const float memoryCost = mHierarchyStats.mMemory  / (1024.0f * 1024.0f) 
     241                                                         + objectSpaceMem + viewSpaceMem; 
     242 
    230243        //cout << "pvs entries " << mHierarchyStats.pvsEntries << endl; 
    231244        AddSubdivisionStats(mHierarchyStats.Leaves(), 
     
    233246                                                mHierarchyStats.mTotalCost, 
    234247                                                mHierarchyStats.mPvsEntries, 
    235                                                 mHierarchyStats.mMemory, 
    236                                                 1.0f / (mHierarchyStats.mTotalCost * mHierarchyStats.mMemory) 
     248                                                memoryCost, 
     249                                                1.0f / (mHierarchyStats.mTotalCost * memoryCost) 
    237250                                                ); 
    238251} 
     
    243256                                                                                   const float totalRenderCost, 
    244257                                                                                   const int pvsEntries, 
    245                                                                                    const int memory, 
     258                                                                                   const float memory, 
    246259                                                                                   const float renderCostPerStorage) 
    247260{ 
     
    309322         
    310323        mHierarchyStats.mNodes = 2; 
    311          
     324 
     325        // create first nodes 
     326        mVspTree->Initialise(sampleRays, forcedViewSpace); 
     327        InitialiseObjectSpaceSubdivision(objects); 
     328 
     329        // hack: assume that object space can be seen from view space 
    312330        mHierarchyStats.mTotalCost = (float)objects.size(); 
     331        mHierarchyStats.mPvsEntries = 1; 
     332        mHierarchyStats.mMemory = sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
     333 
     334        EvalSubdivisionStats(); 
    313335        Debug << "setting total cost to " << mHierarchyStats.mTotalCost << endl; 
    314336 
     
    316338        cout << "Constructing view space / object space tree ... \n"; 
    317339         
    318         // compute view space bounding box 
    319         mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 
    320  
    321340        SplitQueue objectSpaceQueue; 
    322341        SplitQueue viewSpaceQueue; 
     
    326345        mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 
    327346        mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 
    328  
    329         mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 
     347        //mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 
    330348 
    331349        // number of initial splits 
    332         int minSteps = 200; 
     350        const int minSteps = mMinStepsOfSameType; 
    333351        float renderCostDecr = Limits::Infinity; 
    334352 
     
    337355         
    338356        objectSpaceQueue.Push(osc); 
     357 
    339358 
    340359        ///////////////////////// 
     
    349368                RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps); 
    350369 
    351         cout << ospSteps << " object space partition steps taken" << endl; 
    352  
     370        cout << "\n" << ospSteps << " object space partition steps taken" << endl; 
     371 
     372        // create view space 
    353373        SubdivisionCandidate *vsc =  
    354374                        PrepareViewSpaceSubdivision(sampleRays, objects); 
    355375 
    356376        viewSpaceQueue.Push(vsc); 
    357  
     377         
    358378        // view space subdivision was constructed 
    359379        mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
    360380 
    361         // don't terminate on max steps 
    362         //maxSteps = mTermMaxLeaves; 
     381        // the priorities were calculated for driving sha. 
     382        // => recalculate "real" priorities taking visibility into 
     383        // account so we can compare to view space splits 
     384        ResetQueue(objectSpaceQueue, false); 
     385 
     386         
     387        // lower number of minsteps: the decicion of which domain to subdivide 
     388        // should be decided using the render cost decrease from now 
     389        //minSteps = 1; 
    363390 
    364391        // This method subdivides view space / object space  
     
    370397        while (!(viewSpaceQueue.Empty() && objectSpaceQueue.Empty())) 
    371398        { 
     399                const float vspPriority = viewSpaceQueue.Empty() ? 0 : viewSpaceQueue.Top()->GetPriority(); 
     400                const float ospPriority = objectSpaceQueue.Empty() ? 0 : objectSpaceQueue.Top()->GetPriority(); 
     401 
     402                cout << "new decicion, vsp: " << vspPriority << ", osp: " << ospPriority << endl; 
     403 
    372404                // should view or object space be subdivided further? 
    373                 if (viewSpaceQueue.Empty() || 
    374                         (!objectSpaceQueue.Empty() && 
    375                         (objectSpaceQueue.Top()->GetPriority() > viewSpaceQueue.Top()->GetPriority()))) 
    376                 { 
    377                         // use splits of one kind until rendercost slope is reached 
    378                         //renderCostDecr = mHierarchyStats.mRenderCostDecrease; 
    379                          
    380                         // lower number of minsteps: this should be solved  
    381                         // with render cost decrease from now 
    382                         //minSteps = 5;  
    383  
     405                if (ospPriority >= vspPriority) 
     406                { 
     407                        // use splits of one kind until rendercost decrease of other domain is reached 
     408                        renderCostDecr = vspPriority; 
     409                        cout << "comparing with this render cost: " << renderCostDecr << endl; 
    384410                        // dirtied view space candidates 
    385411                        SubdivisionCandidateContainer dirtyVspList; 
     
    391417                                RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps); 
    392418 
    393                         cout << ospSteps << " object space partition steps taken" << endl; 
     419                        cout << "\n" << ospSteps << " object space partition steps taken" << endl; 
    394420                 
    395                         // object space subdivision constructed 
    396                         mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
    397  
    398                         /// Repair split queue 
     421                        /// Repair split queue, i.e., affected view space candidates 
    399422                        cout << "repairing queue ... " << endl; 
    400423                        RepairQueue(dirtyVspList, viewSpaceQueue, true); 
    401                         cout << "repaired " << dirtyVspList.size() << " candidates" << endl; 
     424                        cout << "\nrepaired " << (int)dirtyVspList.size() << " candidates" << endl; 
    402425                } 
    403426                else 
    404427                { 
    405428                        // use splits of one kind until rendercost slope is reached 
    406                 //      renderCostDecr = mHierarchyStats.mRenderCostDecrease; 
     429                        renderCostDecr = ospPriority; 
     430                        cout << "comparing with this render cost: " << renderCostDecr << endl; 
    407431 
    408432                        ///////////////// 
     
    415439                                RunConstruction(viewSpaceQueue, dirtyOspList, renderCostDecr, minSteps); 
    416440 
    417                         cout << vspSteps << " view space partition steps taken" << endl; 
     441                        cout << "\n" << vspSteps << " view space partition steps taken" << endl; 
    418442 
    419443                        // view space subdivision constructed 
     
    423447                        cout << "repairing queue ... " << endl; 
    424448                        RepairQueue(dirtyOspList, objectSpaceQueue, true); 
    425                         cout << "repaired " << dirtyOspList.size() << " candidates" << endl; 
     449                        cout << "repaired " << (int)dirtyOspList.size() << " candidates" << endl; 
    426450                } 
    427451        } 
     
    443467        mHierarchyStats.Start(); 
    444468        mHierarchyStats.mNodes = 2; // two nodes for view space and object space 
    445  
     469        mHierarchyStats.mPvsEntries = 1; 
     470        mHierarchyStats.mMemory = sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
    446471        mHierarchyStats.mTotalCost = (float)objects.size(); 
     472 
    447473        mHierarchyStats.mRenderCostDecrease = 0; 
    448474 
     
    453479        cout << "Constructing view space / object space tree ... \n"; 
    454480         
    455         // compute view space bounding box 
    456         mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 
     481        // create only roots 
     482        mVspTree->Initialise(sampleRays, forcedViewSpace); 
     483        InitialiseObjectSpaceSubdivision(objects); 
    457484 
    458485        // use objects for evaluating vsp tree construction in the  
     
    464491        mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 
    465492 
    466         // create just one view cell 
    467         SubdivisionCandidate *vspSc =  
    468                 PrepareViewSpaceSubdivision(sampleRays, objects); 
    469  
    470493        // start view space subdivison immediately? 
    471494        if (StartViewSpaceSubdivision()) 
    472495        { 
    473496                // prepare vsp tree for traversal 
    474                 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
     497        mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
     498                SubdivisionCandidate *vspSc =  
     499                        PrepareViewSpaceSubdivision(sampleRays, objects); 
     500 
    475501                mTQueue.Push(vspSc); 
    476502        } 
     
    489515                                        sampleRays,  
    490516                                        objects,  
    491                                         forcedViewSpace,//  
    492                                         vspSc); 
     517                                        forcedViewSpace); 
    493518         
    494519        cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    519544 
    520545        return vsc; 
     546} 
     547 
     548 
     549float HierarchyManager::GetObjectSpaceMemUsage() const 
     550{ 
     551        if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 
     552        { 
     553                // TODO; 
     554        } 
     555        else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 
     556        { 
     557                return mBvHierarchy->GetMemUsage(); 
     558        } 
     559 
     560        return -1; 
     561} 
     562 
     563void HierarchyManager::InitialiseObjectSpaceSubdivision(const ObjectContainer &objects) 
     564{ 
     565        if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 
     566        { 
     567                // TODO; 
     568        } 
     569        else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 
     570        { 
     571                mBvHierarchy->Initialise(objects); 
     572        } 
    521573} 
    522574 
     
    608660        } 
    609661         
    610         mHierarchyStats.mTotalCost -= sc->GetRenderCostDecrease(); 
    611          
    612662        cout << sc->Type() << " "; 
    613663                 
     664        ///////////// 
    614665        // update stats 
     666 
    615667        mHierarchyStats.mNodes += 2; 
    616          
    617         const int pvsEntries = sc->GetPvsEntriesIncr(); 
    618         mHierarchyStats.mPvsEntries += pvsEntries; 
    619          
    620         //cout << "pvs entries: " << pvsEntries << " " << mHierarchyStats.pvsEntries << endl; 
    621         mHierarchyStats.mMemory += 0; // TODO 
     668        mHierarchyStats.mTotalCost -= sc->GetRenderCostDecrease(); 
     669 
     670        const int pvsEntriesIncr = sc->GetPvsEntriesIncr(); 
     671        mHierarchyStats.mPvsEntries += pvsEntriesIncr; 
     672        //cout << "pvs entries: " << pvsEntriesIncr << " " << mHierarchyStats.pvsEntries << endl; 
     673 
     674        const int sizeOfEntry = sizeof(PvsData) + sizeof(Intersectable *); 
     675        // memory size in byte 
     676        mHierarchyStats.mMemory += float(pvsEntriesIncr * sizeOfEntry); 
    622677        mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 
    623678 
    624         // subdivision successful 
     679        // output stats 
    625680        EvalSubdivisionStats(); 
    626681                 
     
    656711 
    657712 
     713int HierarchyManager::GetObjectSpaceSubdivisionLeaves() const 
     714{ 
     715        int maxLeaves= 0; 
     716 
     717        if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 
     718        { 
     719                maxLeaves = mOspTree->mOspStats.Leaves(); 
     720        } 
     721        else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 
     722        { 
     723                maxLeaves = mBvHierarchy->mBvhStats.Leaves(); 
     724        } 
     725 
     726        return maxLeaves; 
     727} 
     728 
     729 
    658730bool HierarchyManager::StartObjectSpaceSubdivision() const 
    659731{ 
     
    673745        return  
    674746                ((mConstructionType == INTERLEAVED) &&  
    675                  (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth)); 
     747                 (mMinStepsOfSameType <= mVspTree->mVspStats.nodes)); 
    676748} 
    677749 
     
    694766        return  
    695767                ((mConstructionType == INTERLEAVED) &&  
    696                  (mMinDepthForViewSpaceSubdivion <= GetObjectSpaceSubdivisionDepth())); 
     768                 (mMinStepsOfSameType <= GetObjectSpaceSubdivisionLeaves())); 
    697769} 
    698770 
     
    701773                                                                           const VssRayContainer &sampleRays, 
    702774                                                                           const ObjectContainer &objects, 
    703                                                                            AxisAlignedBox3 *forcedViewSpace, 
    704                                                                            SubdivisionCandidate *firstVsp) 
     775                                                                           AxisAlignedBox3 *forcedViewSpace) 
    705776{ 
    706777        while (!FinishedConstruction()) 
     
    719790                        mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
    720791 
    721                         cout << "\nstarting object space subdivision at depth "  
    722                                  << mVspTree->mVspStats.maxDepth << " ("  
    723                                  << mMinDepthForObjectSpaceSubdivion << ") " << endl; 
     792                        cout << "\nstarting object space subdivision after "  
     793                                 << mVspTree->mVspStats.nodes << " ("  
     794                                 << mMinStepsOfSameType << ") " << endl; 
    724795 
    725796                        SubdivisionCandidate *ospSc = PrepareObjectSpaceSubdivision(sampleRays, objects); 
     797                         
     798                        cout << "reseting queue ... "; 
     799                        ResetQueue(mTQueue, mRecomputeSplitPlaneOnRepair); 
     800                        cout << "finished" << endl; 
     801 
    726802                        mTQueue.Push(ospSc); 
     803                } 
     804 
     805                if (StartViewSpaceSubdivision()) 
     806                { 
     807                        mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
     808 
     809                        cout << "\nstarting view space subdivision at depth "  
     810                                 << GetObjectSpaceSubdivisionLeaves() << " ("  
     811                                 << mMinStepsOfSameType << ") " << endl; 
     812 
     813                        SubdivisionCandidate *vspSc = PrepareViewSpaceSubdivision(sampleRays, objects); 
    727814 
    728815                        cout << "reseting queue ... "; 
    729                         ResetQueue(); 
     816                        ResetQueue(mTQueue, mRecomputeSplitPlaneOnRepair); 
    730817                        cout << "finished" << endl; 
    731                 } 
    732  
    733                 if (StartViewSpaceSubdivision()) 
    734                 { 
    735                         mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
    736  
    737                         cout << "\nstarting view space subdivision at depth "  
    738                                  << GetObjectSpaceSubdivisionDepth() << " ("  
    739                                  << mMinDepthForViewSpaceSubdivion << ") " << endl; 
    740  
    741                         //SubdivisionCandidate *vspSc = PrepareViewSpaceSubdivision(sampleRays, objects); 
    742                         mTQueue.Push(firstVsp); 
    743  
    744                         cout << "reseting queue ... "; 
    745                         ResetQueue(); 
    746                         cout << "finished" << endl; 
     818 
     819                        // push view space candidate                     
     820                        mTQueue.Push(vspSc); 
    747821                } 
    748822 
     
    784858                if ((sc->GetRenderCostDecrease() < minRenderCostDecr) && 
    785859                        !(steps < minSteps)) 
     860                { 
     861                        cout << "breaking on " << sc->GetRenderCostDecrease() << " smaller than " << minRenderCostDecr << endl; 
    786862                        break; 
    787  
     863                } 
    788864                //////// 
    789865                //-- subdivide leaf node of either type 
     
    826902                 
    827903                        mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 
    828  
     904                         
     905                        // bug!! pvs entries could be much higher at this stage 
    829906                        mHierarchyStats.mNodes = 2; 
    830                         mHierarchyStats.mPvsEntries = 0; 
     907                        mHierarchyStats.mPvsEntries = 1; 
    831908                        mHierarchyStats.mRenderCostDecrease = 0; 
    832909 
     
    861938         
    862939        mHierarchyStats.mNodes = 2; 
    863         mHierarchyStats.mPvsEntries = 0; 
     940        // bug!! pvs entries could be much higher at this stage 
     941        mHierarchyStats.mPvsEntries = 1; 
    864942        mHierarchyStats.mRenderCostDecrease = 0; 
    865943 
     944        // evaluate new stats before first subdivsiion 
    866945        EvalSubdivisionStats(); 
    867946 
     
    884963        cout << "Constructing view space / object space tree ... \n"; 
    885964         
    886         // compute view space bounding box 
    887         mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 
     965        // initialise view / object space 
     966        mVspTree->Initialise(sampleRays, forcedViewSpace); 
     967        InitialiseObjectSpaceSubdivision(objects); 
    888968 
    889969        // use sah for evaluating osp tree construction  
     
    892972        mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 
    893973        mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 
    894          
    895         // first view cell 
    896         SubdivisionCandidate *vspVc = PrepareViewSpaceSubdivision(sampleRays, objects); 
    897974 
    898975        mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 
    899         //mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 
     976        mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 
    900977 
    901978        const int limit = mNumMultiLevels; 
     
    9351012                // subdivide view space with respect to the objects 
    9361013 
    937                 if (!ViewSpaceSubdivisionConstructed()) 
    938                 { 
    939                         mTQueue.Push(vspVc); 
    940                          
    941                         // view space subdivision constructed 
    942                         mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
    943                 } 
    944                 else 
    945                 { 
    946                         ResetViewSpaceSubdivision(sampleRays, objects); 
    947                 } 
     1014                SubdivisionCandidate *vspVc = ResetViewSpaceSubdivision(sampleRays, objects); 
     1015                mTQueue.Push(vspVc); 
     1016 
     1017                // view space subdivision constructed 
     1018                mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
     1019                 
    9481020 
    9491021                // process view space candidates 
     
    9691041        FinishObjectSpaceSubdivision(objects); 
    9701042} 
     1043 
     1044 
     1045void HierarchyManager::OptimizeMultiLevel(const VssRayContainer &sampleRays,                                                                                      
     1046                                                                                  const ObjectContainer &objects, 
     1047                                                                                  AxisAlignedBox3 *forcedViewSpace) 
     1048{ 
     1049        mHierarchyStats.Reset(); 
     1050        mHierarchyStats.Start(); 
     1051        mHierarchyStats.mNodes = 2; 
     1052         
     1053        mHierarchyStats.mTotalCost = (float)objects.size(); 
     1054        Debug << "setting total cost to " << mHierarchyStats.mTotalCost << endl; 
     1055 
     1056        const long startTime = GetTime(); 
     1057        cout << "Constructing view space / object space tree ... \n"; 
     1058         
     1059        // initialise view / object space 
     1060        mVspTree->Initialise(sampleRays, forcedViewSpace); 
     1061        InitialiseObjectSpaceSubdivision(objects); 
     1062 
     1063        // use sah for evaluating osp tree construction  
     1064        // in the first iteration of the subdivision 
     1065         
     1066        mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 
     1067        mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 
     1068 
     1069        mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 
     1070        mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 
     1071 
     1072        const int limit = mNumMultiLevels; 
     1073        int i = 0; 
     1074 
     1075        // This method subdivides view space / object space  
     1076        // in order to converge to some optimal cost for this partition 
     1077        // start with object space partiton 
     1078        // then optimizate view space partition for the current osp 
     1079        // and vice versa until iteration depth is reached. 
     1080        while (1) 
     1081        { 
     1082                char subdivisionStatsLog[100]; 
     1083                sprintf(subdivisionStatsLog, "tests/i3d/subdivision-%04d.log", i); 
     1084                mSubdivisionStats.open(subdivisionStatsLog); 
     1085 
     1086                // subdivide object space first 
     1087                ResetObjectSpaceSubdivision(sampleRays, objects); 
     1088 
     1089                // process object space candidates 
     1090                RunConstruction(false); 
     1091 
     1092                // object space subdivision constructed 
     1093                mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
     1094 
     1095                cout << "iteration " << i << " of " << limit << " finished" << endl; 
     1096 
     1097                mSubdivisionStats.close(); 
     1098 
     1099                if ((i ++) >= limit) 
     1100                        break; 
     1101 
     1102                sprintf(subdivisionStatsLog, "tests/i3d/subdivision-%04d.log", i); 
     1103                mSubdivisionStats.open(subdivisionStatsLog); 
     1104 
     1105                ///////////////// 
     1106                // subdivide view space with respect to the objects 
     1107 
     1108                SubdivisionCandidate *vspVc = ResetViewSpaceSubdivision(sampleRays, objects); 
     1109                mTQueue.Push(vspVc); 
     1110 
     1111                // view space subdivision constructed 
     1112                mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
     1113                 
     1114 
     1115                // process view space candidates 
     1116                RunConstruction(false); 
     1117 
     1118                cout << "iteration " << i << " of " << limit << " finished" << endl; 
     1119 
     1120                mSubdivisionStats.close(); 
     1121 
     1122                if ((i ++) >= limit) 
     1123                        break; 
     1124        } 
     1125         
     1126        cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     1127 
     1128/*#if _DEBUG 
     1129        cout << "view space: " << GetViewSpaceBox() << endl; 
     1130        cout << "object space:  " << GetObjectSpaceBox() << endl; 
     1131#endif*/ 
     1132 
     1133        mHierarchyStats.Stop(); 
     1134        mVspTree->mVspStats.Stop(); 
     1135        FinishObjectSpaceSubdivision(objects); 
     1136} 
     1137 
    9711138 
    9721139 
     
    10671234 
    10681235 
    1069 void HierarchyManager::ResetQueue() 
     1236void HierarchyManager::ResetQueue(SplitQueue &splitQueue, const bool recomputeSplitPlane) 
    10701237{ 
    10711238        SubdivisionCandidateContainer mCandidateBuffer; 
    10721239 
    10731240        // remove from queue 
    1074         while (!mTQueue.Empty()) 
    1075         { 
    1076                 SubdivisionCandidate *candidate = NextSubdivisionCandidate(mTQueue); 
     1241        while (!splitQueue.Empty()) 
     1242        { 
     1243                SubdivisionCandidate *candidate = NextSubdivisionCandidate(splitQueue); 
    10771244                 // reevaluate local split plane and priority 
    1078                 candidate->EvalPriority(); 
     1245                candidate->EvalPriority(recomputeSplitPlane); 
    10791246                cout << "."; 
    10801247                mCandidateBuffer.push_back(candidate); 
     
    10851252    for (sit = mCandidateBuffer.begin(); sit != sit_end; ++ sit) 
    10861253        { 
    1087                 mTQueue.Push(*sit); 
     1254                splitQueue.Push(*sit); 
    10881255        } 
    10891256} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1635 r1640  
    5151        /// total number of entries in the pvs 
    5252        int mPvsEntries; 
    53         /// storage cost 
    54         int mMemory; 
     53        /// storage cost in MB 
     54        float mMemory; 
    5555        /// total number of nodes 
    5656        int mNodes; 
     
    7676 
    7777        int Nodes() const {return mNodes;} 
    78         int Interior() const { return mNodes / 2; } 
     78        int Interior() const { return mNodes / 2 - 1; } 
    7979        int Leaves() const { return (mNodes / 2) + 1; } 
    8080         
     
    246246 
    247247 
     248        /** Create bounding box and root. 
     249        */ 
     250        void InitialiseObjectSpaceSubdivision(const ObjectContainer &objects); 
     251 
     252        /** Returns memory usage of object space hierarchy. 
     253        */ 
     254        float GetObjectSpaceMemUsage() const; 
     255 
    248256        ////////////////////////////// 
    249257        // the main loop 
     
    255263                                                 const VssRayContainer &sampleRays, 
    256264                                                 const ObjectContainer &objects, 
    257                                                  AxisAlignedBox3 *forcedViewSpace, 
    258                                                  SubdivisionCandidate *firstVsp); 
     265                                                 AxisAlignedBox3 *forcedViewSpace); 
    259266         
    260267        /** This is for interleaved construction using some objects  
     
    307314                                                         const float totalRenderCost, 
    308315                                                         const int totalPvsEntries,  
    309                                                          const int memory, 
     316                                                         const float memory, 
    310317                                                         const float renderCostPerStorage); 
    311318 
     
    365372        /** Reset the split queue, i.e., reevaluate the split candidates. 
    366373        */ 
    367     void ResetQueue(); 
     374    void ResetQueue(SplitQueue &splitQueue, const bool recomputeSplitPlane); 
    368375 
    369376        /** After the suddivision has ended, do some final tasks. 
     
    374381        */ 
    375382        int GetObjectSpaceSubdivisionDepth() const; 
     383 
     384        /** Returns number of leaves in object space subdivision. 
     385        */ 
     386        int GetObjectSpaceSubdivisionLeaves() const; 
    376387 
    377388        /** Construct object space partition interleaved with view space partition. 
     
    401412                                                         AxisAlignedBox3 *forcedViewSpace); 
    402413 
     414        /** Based on a given subdivision, we try to optimize using an 
     415                multiple iteration over view and object space. 
     416        */ 
     417        void OptimizeMultiLevel(const VssRayContainer &sampleRays,                                                                                        
     418                                                        const ObjectContainer &objects, 
     419                                                        AxisAlignedBox3 *forcedViewSpace); 
     420 
    403421        /** Reset the object space subdivision.  
    404422                E.g., deletes hierarchy and resets stats. 
     
    471489        //////////////////// 
    472490 
     491        int mMinStepsOfSameType; 
     492 
    473493        /// statistics about the hierarchy 
    474494        HierarchyStatistics mHierarchyStats; 
     
    490510        */ 
    491511        bool mUseMultiLevelConstruction; 
     512 
    492513        /// number of iteration steps for multilevel approach    
    493514        int mNumMultiLevels; 
     515 
    494516        /** if split plane should be recomputed for the repair. 
    495517                Otherwise only the priority is recomputed, the 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1633 r1640  
    25992599{ 
    26002600        Environment::GetSingleton()->GetIntValue("BspTree.Construction.samples", mInitialSamples); 
     2601 
    26012602        mBspTree->SetViewCellsManager(this); 
    26022603        mBspTree->SetViewCellsTree(mViewCellsTree); 
     
    47744775: ViewCellsManager(vcTree), mHierarchyManager(hm) 
    47754776{ 
    4776         Environment::GetSingleton()->GetIntValue("VspTree.Construction.samples", mInitialSamples); 
     4777        Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", mInitialSamples); 
    47774778 
    47784779        mHierarchyManager->SetViewCellsManager(this); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1633 r1640  
    559559 
    560560 
    561 // TODO: return memory usage in MB 
     561// $$matt temporary: number of rayrefs + pvs should be in there, but 
     562// commented out for testing 
    562563float VspTree::GetMemUsage() const 
    563564{ 
    564565        return (float) 
    565                  (sizeof(VspTree) +  
    566                   mVspStats.Leaves() * sizeof(VspLeaf) +  
    567                   mCreatedViewCells * sizeof(VspViewCell) + 
    568                   mVspStats.pvs * sizeof(PvsData) + 
    569                   mVspStats.Interior() * sizeof(VspInterior) + 
    570                   mVspStats.accumRays * sizeof(RayInfo)) / (1024.0f * 1024.0f); 
     566                 (sizeof(VspTree) 
     567                  + mVspStats.Leaves() * sizeof(VspLeaf)  
     568                  + mVspStats.Leaves() * sizeof(VspViewCell) 
     569                  + mVspStats.Interior() * sizeof(VspInterior) 
     570                  //+ mVspStats.pvs * sizeof(PvsData) 
     571                  //+ mVspStats.rayRefs * sizeof(RayInfo) 
     572                  ) / (1024.0f * 1024.0f); 
    571573} 
    572574 
     
    739741        { 
    740742                // view cell is created during subdivision 
    741                 //CreateViewCell(tData);  
    742  
    743743                VspLeaf *leaf = dynamic_cast<VspLeaf *>(newNode); 
    744744                ViewCell *viewCell = leaf->GetViewCell(); 
     
    18581858 
    18591859        // accumulate rays to compute rays /  leaf 
    1860         mVspStats.accumRays += (int)data.mRays->size(); 
     1860        mVspStats.rayRefs += (int)data.mRays->size(); 
    18611861 
    18621862        if (data.mPvs < mTermMinPvs) 
     
    28342834 
    28352835 
     2836void VspTree::Initialise(const VssRayContainer &rays, 
     2837                                                 AxisAlignedBox3 *forcedBoundingBox) 
     2838{ 
     2839        ComputeBoundingBox(rays, forcedBoundingBox); 
     2840 
     2841        VspLeaf *leaf = new VspLeaf(); 
     2842        mRoot = leaf; 
     2843 
     2844        VspViewCell *viewCell = new VspViewCell(); 
     2845    leaf->SetViewCell(viewCell); 
     2846 
     2847        // set view cell values 
     2848        viewCell->mLeaves.push_back(leaf); 
     2849 
     2850        viewCell->SetVolume(mBoundingBox.GetVolume()); 
     2851    leaf->mProbability = mBoundingBox.GetVolume(); 
     2852} 
     2853 
     2854 
    28362855SubdivisionCandidate *VspTree::PrepareConstruction(const VssRayContainer &sampleRays, 
    28372856                                                                                                   RayInfoContainer &rays) 
     
    28462865        // initialise termination criteria 
    28472866        mTermMinProbability *= mBoundingBox.GetVolume(); 
     2867         
    28482868        // get clipped rays 
    28492869        PreprocessRays(sampleRays, rays); 
     
    28522872        const int pvsSize = EvalPvsSize(rays); 
    28532873         
     2874        // root and bounding box were already constructed 
     2875        VspLeaf *leaf = dynamic_cast<VspLeaf *>(mRoot); 
    28542876 
    28552877        ////////// 
     
    28582880        const float prop = mBoundingBox.GetVolume(); 
    28592881         
    2860         // we assume that leaf was already created 
    2861         VspLeaf *leaf = new VspLeaf(); 
    2862         mRoot = leaf; 
    2863  
    28642882        // first vsp traversal data 
    2865         VspTraversalData vData(leaf, 0, &rays, pvsSize, prop, mBoundingBox); 
    2866  
    2867         // create first view cell 
    2868         CreateViewCell(vData, false); 
     2883        VspTraversalData vData(leaf, 0, &rays, pvsSize, prop, mBoundingBox); 
     2884 
    28692885 
    28702886#if WORK_WITH_VIEWCELL_PVS 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1633 r1640  
    7979        /// number of invalid leaves 
    8080        int invalidLeaves; 
    81         /// accumulated number of rays refs 
    82         int accumRays; 
     81        /// number of rays refs 
     82        int rayRefs; 
    8383        /// overall pvs size 
    8484        int pvs; 
     
    100100        // TODO: computation wrong 
    101101        double AvgDepth() const { return accumDepth / (double)Leaves();};  
    102         double AvgRays() const { return accumRays / (double)Leaves();};  
     102        double AvgRays() const { return rayRefs / (double)Leaves();};  
    103103 
    104104        void Reset()  
     
    124124                maxPvs = 0; 
    125125                invalidLeaves = 0; 
    126                 accumRays = 0; 
     126                rayRefs = 0; 
    127127                maxObjectRefs = 0; 
    128128                mGlobalCostMisses = 0; 
     
    996996        int EvalContributionToPvs(KdLeaf *leaf) const; 
    997997 
     998        /** Creates new root of hierarchy and computes bounding box. 
     999                Has to be called before the preparation of the subdivision. 
     1000        */ 
     1001        void Initialise(const VssRayContainer &rays, 
     1002                                        AxisAlignedBox3 *forcedBoundingBox); 
    9981003 
    9991004protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1634 r1640  
    112112                else 
    113113                { 
    114                         strippedFilename = string(StripPath(currentFile.c_str())); 
     114                        char *str = StripPath(currentFile.c_str()); 
     115                        strippedFilename = string(str); 
     116 
     117                        delete []str; 
    115118                } 
    116119                 
Note: See TracChangeset for help on using the changeset viewer.