Changeset 1129


Ignore:
Timestamp:
07/12/06 18:30:48 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1121 r1129  
    12731273                                        "view_cells_evaluation_stats_prefix=", 
    12741274                                        "viewCells"); 
    1275  
    12761275        RegisterOption("ViewCells.Evaluation.histogram", 
    12771276                                        optBool, 
     
    12881287                                        "view_cells_render_cost_evaluation=", 
    12891288                                        "perobject"); 
     1289 
     1290        RegisterOption("ViewCells.Evaluation.countKdPvs", 
     1291                                        optBool, 
     1292                                        "view_cells_evaluation_count_kd_pvs=", 
     1293                                        "false"); 
    12901294 
    12911295        RegisterOption("ViewCells.active", 
     
    23032307                        "0.99"); 
    23042308 
    2305         RegisterOption("OspTree.Evaluation.countKdPvs", 
     2309        RegisterOption("OspTree.Construction.useEqualWeightForHeuristics", 
    23062310                optBool, 
    2307                 "osp_evaluation_count_kd_pvs=", 
     2311                "osp_construction_use_equal_weight_for_heuristics=", 
    23082312                "false"); 
    23092313 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1122 r1129  
    49014901        long startTime; 
    49024902 
    4903         //mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 
    4904         mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 
     4903        mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 
     4904        //mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 
    49054905         
    49064906        //-- stats 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1123 r1129  
    26472647OspTree::OspTree(): 
    26482648mRoot(NULL), 
    2649 mTimeStamp(1) 
     2649mTimeStamp(1), 
     2650mUseEqualWeightForHeuristics(false) 
    26502651{ 
    26512652        bool randomize = false; 
     
    26672668        Environment::GetSingleton()->GetFloatValue("OspTree.Termination.minGlobalCostRatio", 
    26682669                mTermMinGlobalCostRatio); 
    2669         Environment::GetSingleton()->GetIntValue("OspTree.Termination.mTermGlobalCostMissTolerance); 
    2670  
     2670         
    26712671 
    26722672        //-- factors for bsp tree split plane heuristics 
     
    26892689        Environment::GetSingleton()->GetFloatValue("OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
    26902690         
     2691        Environment::GetSingleton()->GetBoolValue("OspTree.Construction.useEqualWeightForHeuristics", mUseEqualWeightForHeuristics); 
     2692 
     2693 
    26912694        //-- debug output 
    26922695 
     
    29882991        // C = ct_div_ci  + (ol + or)/queries 
    29892992         
    2990         int pvsSize = PrepareHeuristics(node->mObjects); 
    2991         int pvsl = 0, pvsr = pvsSize; 
     2993        float totalVol = PrepareHeuristics(node->mObjects); 
     2994        int voll = 0, volr = totalVol; 
    29922995   
     2996        const int totalPvs = (int)node->mObjects.size(); 
     2997 
    29932998        const float minBox = box.Min(axis); 
    29942999        const float maxBox = box.Max(axis); 
    29953000 
    29963001        const float sizeBox = maxBox - minBox; 
    2997          
    2998                          
     3002                                 
    29993003        // if no good split can be found, take mid split 
    3000         position = minBox + 0.5f * sizeBox; 
     3004        int pvsBack = totalPvs / 2; 
    30013005         
    30023006        // the relative cost ratio 
     
    30093013    float minSum = 1e20f; 
    30103014 
    3011         int pvsBack = pvsl; 
    3012         int pvsFront = pvsr; 
    3013  
    3014         float sum = (float)pvsSize * sizeBox; 
    3015 float dummy1 = 0; 
    3016 float dummy2 = 0; 
     3015        float volBack = voll; 
     3016        float volFront = volr; 
     3017 
     3018        float sum = (float)totalVol * sizeBox; 
    30173019 
    30183020        vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 
    3019 cout << "***********" << endl; 
     3021 
     3022 
    30203023        //-- traverse through visibility events 
    30213024        for (ci = mSplitCandidates->begin(); ci != ci_end; ++ ci) 
    30223025        { 
    3023                 int pvslold = pvsl; 
    3024                 EvalPvsIncr(*ci, pvsl, pvsr); 
     3026                EvalPvsIncr(*ci, voll, volr); 
    30253027 
    30263028                cout << "incr: " << ci->mObject->mViewCellPvs.GetSize() << " obj id "  
     
    30303032                if (((*ci).value >= minBand) && ((*ci).value <= maxBand)) 
    30313033                { 
    3032                         sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
    3033  
    3034                         cout << "pos=" << (*ci).value << "\t pvs=(" <<  pvsl << ","  
    3035                                  << pvsr << ")" << "\t cost= " << sum << endl; 
     3034                        //sum = costl * ((*ci).value - minBox) + costr * (maxBox - (*ci).value); 
     3035                        sum = voll * (*ci).value +volr * (totalPvs - (*ci).value); 
     3036 
     3037                        cout << "pos=" << (*ci).value << "\t volt=(" <<  voll << ","  
     3038                                 << volr << ")" << "\t volt= " << sum << endl; 
    30363039 
    30373040                        if (sum < minSum) 
     
    30403043 
    30413044                                minSum = sum; 
    3042                                 position = (*ci).value; 
     3045                                pvsBack = (*ci).value; 
    30433046                                 
    3044                                 pvsBack = pvsl; 
    3045                                 pvsFront = pvsr; 
     3047                                volBack = voll; 
     3048                                volFront = volr; 
    30463049                        } 
    30473050                } 
     
    30533056        const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
    30543057 
    3055         const float pOverall = sizeBox; 
    3056         const float pBack = position - minBox; 
    3057         const float pFront = maxBox - position; 
    3058  
    3059         const float penaltyOld = EvalPvsPenalty(pvsSize, lowerPvsLimit, upperPvsLimit); 
    3060     const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
    3061         const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
     3058        const float pOverall = totalVol; 
     3059        const float pBack = volBack; 
     3060        const float pFront = volFront; 
     3061 
     3062        const float penaltyOld = totalPvs;//EvalPvsPenalty(pvsSize, lowerPvsLimit, upperPvsLimit); 
     3063    const float penaltyFront = totalPvs - pvsBack;//EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
     3064        const float penaltyBack = pvsBack;//EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
    30623065         
    30633066        const float oldRenderCost = penaltyOld * pOverall + Limits::Small; 
    30643067        const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
     3068 
    30653069 
    30663070        if (splitPlaneFound) 
     
    30723076        Debug << "axis=" << axis << " costRatio=" << ratio << " pos="  
    30733077                  << position << " t=" << (position - minBox) / (maxBox - minBox) 
    3074               << "\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl; 
     3078              << "\t pb=(" << volBack << ")\t pf=(" << volFront << ")" << endl; 
    30753079 
    30763080        return ratio; 
     
    30973101 
    30983102        // insert all queries  
    3099         for(mi = node->mObjects.begin(); mi != mi_end; ++ mi)  
     3103        int pvs = 0; 
     3104        for(mi = node->mObjects.begin(); mi != mi_end; ++ mi, ++ pvs)  
    31003105        { 
    31013106                AxisAlignedBox3 box = (*mi)->GetBox(); 
    31023107 
     3108                // only first event should be sufficient 
     3109                // but maybe introduces problems with symmetry ... 
    31033110                mSplitCandidates->push_back(SortableEntry(SortableEntry::BOX_MIN, 
    3104                                         box.Min(axis), *mi)); 
    3105  
    3106  
    3107                 mSplitCandidates->push_back(SortableEntry(SortableEntry::BOX_MAX, 
    3108                                         box.Max(axis), *mi)); 
     3111                                        pvs, *mi)); 
     3112 
     3113                //mSplitCandidates->push_back(SortableEntry(SortableEntry::BOX_MAX, 
     3114                //                      pvs, *mi)); 
    31093115        } 
    31103116 
     
    31133119 
    31143120 
    3115 int OspTree::PrepareHeuristics(Intersectable *object) 
    3116 { 
    3117         if (mUseSah) 
     3121float OspTree::PrepareHeuristics(Intersectable *object) 
     3122{ 
     3123        if (mUseEqualWeightForHeuristics) 
     3124        {        
     3125                // like sah: each object has weight one for heuristics 
    31183126                return 1; 
     3127        } 
    31193128        else 
    3120                 // the priotity of the object is the number of view cell pvs entries of the object 
    3121                 return object->mViewCellPvs.GetSize(); 
     3129        { 
     3130                // the priotity of the object is the sum of view cells  
     3131                // weighted per their volume 
     3132                float vol = 0; 
     3133                return vol; 
     3134                //return object->mViewCellPvs.GetSize(); 
     3135        } 
    31223136} 
    31233137 
     
    31293143 
    31303144 
    3131 int OspTree::PrepareHeuristics(const ObjectContainer &objects) 
     3145float OspTree::PrepareHeuristics(const ObjectContainer &objects) 
    31323146{        
    31333147        Intersectable::NewMail(); 
    31343148        ViewCell::NewMail(); 
    31353149 
    3136         int pvsSize = 0; 
     3150        float vol = 0; 
    31373151 
    31383152        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    31393153 
    3140         //-- set all pvs as belonging to the front pvs 
     3154        //-- set all view cell volume as belonging to front volume 
    31413155        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    31423156        { 
    31433157                Intersectable *obj = *oit; 
    3144                 pvsSize += PrepareHeuristics(obj);               
    3145         } 
    3146  
    3147         return pvsSize; 
     3158                vol += PrepareHeuristics(obj);           
     3159        } 
     3160 
     3161        return vol; 
    31483162} 
    31493163 
     
    31843198void OspTree::RemoveContriFromPvs(Intersectable *object, int &pvs) const 
    31853199{ 
    3186         if (mUseSah) 
     3200        if (mUseEqualWeightForHeuristics) 
    31873201                -- pvs; 
    31883202        else 
     
    31943208void OspTree::AddContriToPvs(Intersectable *object, int &pvs) const 
    31953209{ 
    3196         if (mUseSah) 
     3210        if (mUseEqualWeightForHeuristics) 
    31973211                ++ pvs; 
    31983212        else 
     
    32823296float OspTree::EvalViewCellPvsIncr(Intersectable *object) const 
    32833297{ 
    3284         if (mUseSah) 
     3298        if (mUseEqualWeightForHeuristics) 
    32853299                return 1; 
    32863300        else 
     
    37843798        // makes no sense otherwise because only one kd cell available 
    37853799        // during view space partition 
     3800        const int savedCountMethod = 
    37863801        mVspTree.mPvsCountMethod = VspTree::PER_OBJECT; 
    37873802 
     
    38583873         
    38593874        cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
     3875 
     3876        mVspTree.mPvsCountMethod = savedCountMethod; 
    38603877} 
    38613878 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1123 r1129  
    738738                                                                ViewCellContainer &viewCells) const; 
    739739 
     740        /** Remove the references of the parent view cell from the kd nodes associated with 
     741                the objects. 
     742        */ 
     743        void RemoveParentViewCellReferences(ViewCell *parent) const; 
     744 
     745        /** Adds references to the view cell to the kd nodes associated with the objects. 
     746        */ 
     747        void AddViewCellReferences(ViewCell *vc) const; 
     748 
     749 
     750 
    740751        /// pointer to the hierarchy of view cells 
    741752        ViewCellsTree *mViewCellsTree; 
    742  
    743         /** Remove the references of the parent view cell from the kd nodes associated with 
    744                 the objects. 
    745         */ 
    746         void RemoveParentViewCellReferences(ViewCell *parent) const; 
    747  
    748         /** Adds references to the view cell to the kd nodes associated with the objects. 
    749         */ 
    750         void AddViewCellReferences(ViewCell *vc) const; 
    751  
    752753 
    753754protected: 
     
    15481549                @returns pvs size of the node 
    15491550        */ 
    1550         int PrepareHeuristics(const ObjectContainer &objects); 
    1551  
    1552         int PrepareHeuristics(Intersectable *object); 
    1553  
     1551        float PrepareHeuristics(const ObjectContainer &objects); 
     1552 
     1553        /** Evaluates contribution for one object  
     1554                to heuristics preparation. 
     1555        */ 
     1556        float PrepareHeuristics(Intersectable *object); 
     1557 
     1558        /** Prepares construction for vsp and osp trees. 
     1559        */ 
    15541560        void PrepareConstruction(const ObjectContainer &objects, 
    15551561                AxisAlignedBox3 *forcedBoundingBox); 
     
    15581564                vector<SplitCandidate *> &dirtyList); 
    15591565 
     1566        /** Collect view cells which see this kd leaf. 
     1567        */ 
    15601568        void CollectViewCells(KdLeaf *leaf,  
    15611569                ViewCellContainer &viewCells); 
     1570 
    15621571 
    15631572protected: 
     
    16271636 
    16281637 
    1629         bool mUseSah; 
     1638        bool mUseEqualWeightForHeuristics; 
    16301639 
    16311640        /// subdivision stats output file 
Note: See TracChangeset for help on using the changeset viewer.