Changeset 1129 for GTP/trunk/Lib/Vis
- Timestamp:
- 07/12/06 18:30:48 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1121 r1129 1273 1273 "view_cells_evaluation_stats_prefix=", 1274 1274 "viewCells"); 1275 1276 1275 RegisterOption("ViewCells.Evaluation.histogram", 1277 1276 optBool, … … 1288 1287 "view_cells_render_cost_evaluation=", 1289 1288 "perobject"); 1289 1290 RegisterOption("ViewCells.Evaluation.countKdPvs", 1291 optBool, 1292 "view_cells_evaluation_count_kd_pvs=", 1293 "false"); 1290 1294 1291 1295 RegisterOption("ViewCells.active", … … 2303 2307 "0.99"); 2304 2308 2305 RegisterOption("OspTree. Evaluation.countKdPvs",2309 RegisterOption("OspTree.Construction.useEqualWeightForHeuristics", 2306 2310 optBool, 2307 "osp_ evaluation_count_kd_pvs=",2311 "osp_construction_use_equal_weight_for_heuristics=", 2308 2312 "false"); 2309 2313 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1122 r1129 4901 4901 long startTime; 4902 4902 4903 //mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox);4904 mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox);4903 mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 4904 //mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 4905 4905 4906 4906 //-- stats -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1123 r1129 2647 2647 OspTree::OspTree(): 2648 2648 mRoot(NULL), 2649 mTimeStamp(1) 2649 mTimeStamp(1), 2650 mUseEqualWeightForHeuristics(false) 2650 2651 { 2651 2652 bool randomize = false; … … 2667 2668 Environment::GetSingleton()->GetFloatValue("OspTree.Termination.minGlobalCostRatio", 2668 2669 mTermMinGlobalCostRatio); 2669 Environment::GetSingleton()->GetIntValue("OspTree.Termination.mTermGlobalCostMissTolerance); 2670 2670 2671 2671 2672 2672 //-- factors for bsp tree split plane heuristics … … 2689 2689 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 2690 2690 2691 Environment::GetSingleton()->GetBoolValue("OspTree.Construction.useEqualWeightForHeuristics", mUseEqualWeightForHeuristics); 2692 2693 2691 2694 //-- debug output 2692 2695 … … 2988 2991 // C = ct_div_ci + (ol + or)/queries 2989 2992 2990 int pvsSize= PrepareHeuristics(node->mObjects);2991 int pvsl = 0, pvsr = pvsSize;2993 float totalVol = PrepareHeuristics(node->mObjects); 2994 int voll = 0, volr = totalVol; 2992 2995 2996 const int totalPvs = (int)node->mObjects.size(); 2997 2993 2998 const float minBox = box.Min(axis); 2994 2999 const float maxBox = box.Max(axis); 2995 3000 2996 3001 const float sizeBox = maxBox - minBox; 2997 2998 3002 2999 3003 // if no good split can be found, take mid split 3000 position = minBox + 0.5f * sizeBox;3004 int pvsBack = totalPvs / 2; 3001 3005 3002 3006 // the relative cost ratio … … 3009 3013 float minSum = 1e20f; 3010 3014 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; 3017 3019 3018 3020 vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 3019 cout << "***********" << endl; 3021 3022 3020 3023 //-- traverse through visibility events 3021 3024 for (ci = mSplitCandidates->begin(); ci != ci_end; ++ ci) 3022 3025 { 3023 int pvslold = pvsl; 3024 EvalPvsIncr(*ci, pvsl, pvsr); 3026 EvalPvsIncr(*ci, voll, volr); 3025 3027 3026 3028 cout << "incr: " << ci->mObject->mViewCellPvs.GetSize() << " obj id " … … 3030 3032 if (((*ci).value >= minBand) && ((*ci).value <= maxBand)) 3031 3033 { 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; 3036 3039 3037 3040 if (sum < minSum) … … 3040 3043 3041 3044 minSum = sum; 3042 p osition= (*ci).value;3045 pvsBack = (*ci).value; 3043 3046 3044 pvsBack = pvsl;3045 pvsFront = pvsr;3047 volBack = voll; 3048 volFront = volr; 3046 3049 } 3047 3050 } … … 3053 3056 const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 3054 3057 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); 3062 3065 3063 3066 const float oldRenderCost = penaltyOld * pOverall + Limits::Small; 3064 3067 const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 3068 3065 3069 3066 3070 if (splitPlaneFound) … … 3072 3076 Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" 3073 3077 << position << " t=" << (position - minBox) / (maxBox - minBox) 3074 << "\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl;3078 << "\t pb=(" << volBack << ")\t pf=(" << volFront << ")" << endl; 3075 3079 3076 3080 return ratio; … … 3097 3101 3098 3102 // 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) 3100 3105 { 3101 3106 AxisAlignedBox3 box = (*mi)->GetBox(); 3102 3107 3108 // only first event should be sufficient 3109 // but maybe introduces problems with symmetry ... 3103 3110 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)); 3109 3115 } 3110 3116 … … 3113 3119 3114 3120 3115 int OspTree::PrepareHeuristics(Intersectable *object) 3116 { 3117 if (mUseSah) 3121 float OspTree::PrepareHeuristics(Intersectable *object) 3122 { 3123 if (mUseEqualWeightForHeuristics) 3124 { 3125 // like sah: each object has weight one for heuristics 3118 3126 return 1; 3127 } 3119 3128 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 } 3122 3136 } 3123 3137 … … 3129 3143 3130 3144 3131 int OspTree::PrepareHeuristics(const ObjectContainer &objects)3145 float OspTree::PrepareHeuristics(const ObjectContainer &objects) 3132 3146 { 3133 3147 Intersectable::NewMail(); 3134 3148 ViewCell::NewMail(); 3135 3149 3136 int pvsSize= 0;3150 float vol = 0; 3137 3151 3138 3152 ObjectContainer::const_iterator oit, oit_end = objects.end(); 3139 3153 3140 //-- set all pvs as belonging to the front pvs3154 //-- set all view cell volume as belonging to front volume 3141 3155 for (oit = objects.begin(); oit != oit_end; ++ oit) 3142 3156 { 3143 3157 Intersectable *obj = *oit; 3144 pvsSize+= PrepareHeuristics(obj);3145 } 3146 3147 return pvsSize;3158 vol += PrepareHeuristics(obj); 3159 } 3160 3161 return vol; 3148 3162 } 3149 3163 … … 3184 3198 void OspTree::RemoveContriFromPvs(Intersectable *object, int &pvs) const 3185 3199 { 3186 if (mUse Sah)3200 if (mUseEqualWeightForHeuristics) 3187 3201 -- pvs; 3188 3202 else … … 3194 3208 void OspTree::AddContriToPvs(Intersectable *object, int &pvs) const 3195 3209 { 3196 if (mUse Sah)3210 if (mUseEqualWeightForHeuristics) 3197 3211 ++ pvs; 3198 3212 else … … 3282 3296 float OspTree::EvalViewCellPvsIncr(Intersectable *object) const 3283 3297 { 3284 if (mUse Sah)3298 if (mUseEqualWeightForHeuristics) 3285 3299 return 1; 3286 3300 else … … 3784 3798 // makes no sense otherwise because only one kd cell available 3785 3799 // during view space partition 3800 const int savedCountMethod = 3786 3801 mVspTree.mPvsCountMethod = VspTree::PER_OBJECT; 3787 3802 … … 3858 3873 3859 3874 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 3875 3876 mVspTree.mPvsCountMethod = savedCountMethod; 3860 3877 } 3861 3878 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1123 r1129 738 738 ViewCellContainer &viewCells) const; 739 739 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 740 751 /// pointer to the hierarchy of view cells 741 752 ViewCellsTree *mViewCellsTree; 742 743 /** Remove the references of the parent view cell from the kd nodes associated with744 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 752 753 753 754 protected: … … 1548 1549 @returns pvs size of the node 1549 1550 */ 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 */ 1554 1560 void PrepareConstruction(const ObjectContainer &objects, 1555 1561 AxisAlignedBox3 *forcedBoundingBox); … … 1558 1564 vector<SplitCandidate *> &dirtyList); 1559 1565 1566 /** Collect view cells which see this kd leaf. 1567 */ 1560 1568 void CollectViewCells(KdLeaf *leaf, 1561 1569 ViewCellContainer &viewCells); 1570 1562 1571 1563 1572 protected: … … 1627 1636 1628 1637 1629 bool mUse Sah;1638 bool mUseEqualWeightForHeuristics; 1630 1639 1631 1640 /// subdivision stats output file
Note: See TracChangeset
for help on using the changeset viewer.