Changeset 1679 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/25/06 20:29:41 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh
r1676 r1679 13 13 #SCENE=vsposp_typical 14 14 #SCENE=soda5_vsposp 15 SCENE=soda_vsposp16 #SCENE=vienna_vsposp15 #SCENE=soda_vsposp 16 SCENE=vienna_vsposp 17 17 #SCENE=arena_vsposp 18 18 #SCENE=vsposp_citymodel … … 60 60 61 61 ################################################################################## 62 MEMCONST= 0.863 METHOD=gradient-mem -$MEMCONST64 echo "$SCENE $METHOD" 65 66 $PROGRAM $ENVIRONMENT \ 67 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 68 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 69 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 70 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 71 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 72 -hierarchy_construction_type=2 \ 73 -hierarchy_construction_consider_memory =true \62 MEMCONST=1.0 63 METHOD=gradient-mem2-$MEMCONST 64 echo "$SCENE $METHOD" 65 66 $PROGRAM $ENVIRONMENT \ 67 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 68 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 69 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 70 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 71 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 72 -hierarchy_construction_type=2 \ 73 -hierarchy_construction_consider_memory2=true \ 74 74 -bvh_construction_render_cost_decrease_weight=0.99 \ 75 75 -vsp_construction_render_cost_decrease_weight=0.99 \ … … 83 83 ################################################################################## 84 84 MEMCONST=0.5 85 METHOD=gradient-mem -$MEMCONST86 echo "$SCENE $METHOD" 87 88 $PROGRAM $ENVIRONMENT \ 89 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 90 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 91 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 92 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 93 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 94 -hierarchy_construction_type=2 \ 95 -hierarchy_construction_consider_memory =true \85 METHOD=gradient-mem2-$MEMCONST 86 echo "$SCENE $METHOD" 87 88 $PROGRAM $ENVIRONMENT \ 89 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 90 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 91 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 92 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 93 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 94 -hierarchy_construction_type=2 \ 95 -hierarchy_construction_consider_memory2=true \ 96 96 -bvh_construction_render_cost_decrease_weight=0.99 \ 97 97 -vsp_construction_render_cost_decrease_weight=0.99 \ … … 104 104 ################################################################################## 105 105 MEMCONST=0.2 106 METHOD=gradient-mem -$MEMCONST107 echo "$SCENE $METHOD" 108 109 $PROGRAM $ENVIRONMENT \ 110 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 111 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 112 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 113 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 114 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 115 -hierarchy_construction_type=2 \ 116 -hierarchy_construction_consider_memory =true \106 METHOD=gradient-mem2-$MEMCONST 107 echo "$SCENE $METHOD" 108 109 $PROGRAM $ENVIRONMENT \ 110 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 111 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 112 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 113 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 114 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 115 -hierarchy_construction_type=2 \ 116 -hierarchy_construction_consider_memory2=true \ 117 117 -bvh_construction_render_cost_decrease_weight=0.99 \ 118 118 -vsp_construction_render_cost_decrease_weight=0.99 \ … … 126 126 127 127 ############################################################################ 128 NODES=1000 128 NODES=10000 129 129 130 130 METHOD=sequential-$NODES 131 131 echo "$SCENE $METHOD" 132 132 133 #$PROGRAM $ENVIRONMENT \133 $PROGRAM $ENVIRONMENT \ 134 134 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 135 135 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 144 144 ############################################################################ 145 145 146 NODES= 10000146 NODES=70000 147 147 148 148 METHOD=sequential-$NODES 149 149 echo "$SCENE $METHOD" 150 150 151 #$PROGRAM $ENVIRONMENT \151 $PROGRAM $ENVIRONMENT \ 152 152 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 153 153 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 168 168 echo "$SCENE $METHOD" 169 169 170 # $PROGRAM $ENVIRONMENT \ 171 # -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 172 # -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 173 # -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 174 # -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 175 # -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 176 # -hierarchy_construction_type=0 \ 177 # -bvh_term_max_leaves=$NODES 170 $PROGRAM $ENVIRONMENT \ 171 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 172 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 173 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 174 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 175 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 176 -hierarchy_construction_type=0 \ 177 -bvh_term_max_leaves=$NODES 178 179 sh movefiles.sh $LOG_PREFIX-$METHOD 180 181 182 ############################################################################ 183 184 NODES=100000 185 186 METHOD=sequential-$NODES 187 echo "$SCENE $METHOD" 188 189 $PROGRAM $ENVIRONMENT \ 190 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 191 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 192 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 193 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 194 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 195 -hierarchy_construction_type=0 \ 196 -bvh_term_max_leaves=$NODES 197 198 sh movefiles.sh $LOG_PREFIX-$METHOD 199 200 201 ################################################################################## 202 MEMCONST=1.0 203 METHOD=gradient-multi-$MEMCONST 204 echo "$SCENE $METHOD" 205 206 $PROGRAM $ENVIRONMENT \ 207 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 208 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 209 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 210 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 211 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 212 -hierarchy_construction_type=2 \ 213 -hierarchy_construction_consider_memory2=true \ 214 -bvh_construction_render_cost_decrease_weight=0.99 \ 215 -vsp_construction_render_cost_decrease_weight=0.99 \ 216 -hierarchy_construction_multilevel=true \ 217 -hierarchy_construction_levels=4 \ 218 -hierarchy_term_memory_const=$MEMCONST \ 219 -hierarchy_construction_recompute_split_on_repair=true 178 220 179 221 sh movefiles.sh $LOG_PREFIX-$METHOD -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1676 r1679 44 44 /***************************************************************/ 45 45 46 BvhNode::BvhNode(): mParent(NULL), mMailbox(0) 46 BvhNode::BvhNode(): 47 mParent(NULL), 48 mMailbox(0), 49 mRenderCostDecr(0), 50 mMemoryIncr(0), 51 mPvsEntriesIncr(0), 52 mTimeStamp(0) 47 53 { 48 54 } 49 55 50 56 BvhNode::BvhNode(const AxisAlignedBox3 &bbox): 51 mParent(NULL), mBoundingBox(bbox), mMailbox(0) 57 mParent(NULL), 58 mBoundingBox(bbox), 59 mMailbox(0), 60 mMemoryIncr(0), 61 mPvsEntriesIncr(0), 62 mTimeStamp(0) 52 63 { 53 64 } … … 55 66 56 67 BvhNode::BvhNode(const AxisAlignedBox3 &bbox, BvhInterior *parent): 57 mBoundingBox(bbox), mParent(parent), mMailbox(0) 68 mBoundingBox(bbox), 69 mParent(parent), 70 mMailbox(0), 71 mMemoryIncr(0), 72 mPvsEntriesIncr(0), 73 mTimeStamp(0) 58 74 { 59 75 } … … 400 416 backData.mMaxCostMisses = sc.GetMaxCostMisses(); 401 417 418 // set the time stamp so the order of traversal can be reconstructed 419 node->mTimeStamp = mHierarchyManager->mTimeStamp ++; 420 cout << "here4 " << node->mTimeStamp << endl; 421 node->mRenderCostDecr = sc.GetRenderCostDecrease(); 422 node->mPvsEntriesIncr = sc.GetPvsEntriesIncr(); 423 402 424 // assign the objects in sorted order 403 425 if (mUseGlobalSorting) … … 491 513 if (computeSplitPlane) 492 514 { 493 const bool sufficientSamples = splitCandidate.mParentData.mNumRays <mMinRaysForVisibility;515 const bool sufficientSamples = splitCandidate.mParentData.mNumRays > mMinRaysForVisibility; 494 516 495 517 const bool useVisibiliyBasedHeuristics = 496 518 !mUseSah && 497 !(mHierarchyManager->GetViewSpaceSubdivisionType() == HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) &&519 (mHierarchyManager->GetViewSpaceSubdivisionType() == HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) && 498 520 sufficientSamples; 499 521 … … 1259 1281 if (useVisibilityBasedHeuristics) 1260 1282 { 1283 //cout << "v"; 1261 1284 /////////// 1262 1285 //-- heuristics using objects weighted by view cells volume 1263 1286 nCostRatio[axis] = 1264 EvalLocalCostHeuristics( 1265 tData, 1266 axis, 1267 nFrontObjects[axis], 1268 nBackObjects[axis]); 1287 EvalLocalCostHeuristics(tData, axis, nFrontObjects[axis], nBackObjects[axis]); 1269 1288 } 1270 1289 else 1271 { 1290 {//cout << "e"; 1272 1291 ////////////////// 1273 1292 //-- view cells not constructed yet => use surface area heuristic 1274 1293 nCostRatio[axis] = 1275 EvalSah( 1276 tData, 1277 axis, 1278 nFrontObjects[axis], 1279 nBackObjects[axis]); 1294 EvalSah(tData, axis, nFrontObjects[axis], nBackObjects[axis]); 1280 1295 } 1281 1296 } … … 1284 1299 //-- split objects using some simple criteria 1285 1300 nCostRatio[axis] = 1286 EvalLocalObjectPartition( 1287 tData, 1288 axis, 1289 nFrontObjects[axis], 1290 nBackObjects[axis]); 1301 EvalLocalObjectPartition(tData, axis, nFrontObjects[axis], nBackObjects[axis]); 1291 1302 } 1292 1303 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1677 r1679 198 198 { mBoundingBox = boundingBox; } 199 199 200 201 float GetMergeCost() {return 0.0f; }; 200 /** Cost of mergin this node. 201 */ 202 float GetMergeCost() {return (float)-mTimeStamp; } 203 204 int mTimeStamp; 205 206 int mPvsEntriesIncr; 207 float mMemoryIncr; 208 float mRenderCostDecr; 202 209 203 210 ///////////////////////////////////// … … 262 269 return s << A.mBoundingBox; 263 270 } 264 virtual void CollectObjects(ObjectContainer &objects); 271 272 virtual void CollectObjects(ObjectContainer &objects); 265 273 protected: 266 274 … … 444 452 if (hm->ConsiderMemory()) 445 453 { 446 //const float rc = mRenderCostDecrease / hm->GetHierarchyStats().mTotalCost; 447 const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 454 const float rc = mRenderCostDecrease / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 455 //const float mc = mMemoryIncr / / hm->GetHierarchyStats().mMemory; 456 //const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 457 const float mc = (float)mPvsEntriesIncr / (float)hm->GetHierarchyStats().mPvsEntries; 458 448 459 //cout << "\np: " << mPriority << " i: " << hm->mInitialRenderCost << " t: " << hm->GetHierarchyStats().mTotalCost << endl; 449 //const float mc = mMemoryIncr / / hm->GetHierarchyStats().mMemory; 450 const float mc = (float)mPvsEntriesIncr / (float)hm->GetHierarchyStats().mPvsEntries; 451 cout << "osp rc: " << rc << " mc: " << mc << endl; 460 //cout << "osp rc: " << rc << " mc: " << mc << endl; 461 452 462 return hm->GetMemoryConst() * rc - (1.0f - hm->GetMemoryConst()) * mc; 453 463 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1677 r1679 319 319 AxisAlignedBox3 *forcedViewSpace) 320 320 { 321 mTimeStamp = 1; 322 321 323 switch (mConstructionType) 322 324 { … … 422 424 // then optimizate view space partition for the current osp 423 425 // and vice versa until iteration depth is reached. 424 426 bool lastSplitWasOsp = true; 425 427 while (!(viewSpaceQueue.Empty() && objectSpaceQueue.Empty())) 426 428 { … … 432 434 433 435 // should view or object space be subdivided further? 434 if (ospPriority >= vspPriority) 435 { 436 //if (ospPriority >= vspPriority) 437 if (!lastSplitWasOsp) 438 { 439 lastSplitWasOsp = true; 436 440 cout << "osp" << endl; 437 441 // dirtied view space candidates … … 456 460 else 457 461 { 462 lastSplitWasOsp = false; 458 463 cout << "vsp" << endl; 459 464 … … 912 917 const float threshold = oldCandidate ? oldCandidate->GetPriority() : 1e20; 913 918 SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue); 914 //cout << "here2 " << sc->GetPriority() << " " << threshold << endl; 919 //cout << "here2 " << sc->GetRenderCostDecrease() << " " << threshold << endl; 920 float rc = (float)sc->GetRenderCostDecrease() / (mInitialRenderCost - mHierarchyStats.mTotalCost + 1.0f); 921 float mc = (float)sc->GetPvsEntriesIncr() / (float)mHierarchyStats.mPvsEntries; 922 923 //cout << "dRc: " << sc->GetRenderCostDecrease() << " dMem: " << sc->GetPvsEntriesIncr() << " ratio1 " << rc << " ratio2 " << mc << " const: " << 1.0f - GetMemoryConst() << endl; 915 924 916 925 // minimum slope reached … … 1505 1514 1506 1515 1507 void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects, const bool removeRayRefs) const 1516 void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects, 1517 const bool removeRayRefs) const 1508 1518 { 1509 1519 switch (mObjectSpaceSubdivisionType) -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1677 r1679 544 544 bool mConsiderMemory2; 545 545 546 int mTimeStamp; 546 547 friend VspTree; 547 548 friend OspTree; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1667 r1679 238 238 /// parent view cell in the view cell hierarchy 239 239 ViewCellInterior *mParent; 240 241 240 /// the potentially visible objects 242 241 ObjectPvs mPvs; 243 244 242 /// the volume of this view cell 245 243 float mVolume; 246 247 244 /// the area of this view cell 248 245 float mArea; 249 250 246 /// the cost that were paid for merging this view cells from two others. 251 247 float mMergeCost; 252 253 248 /// if the view cell is valid view space 254 249 bool mValid; 255 256 250 /// color used for consistent visualization 257 251 RgbColor mColor; 258 259 252 /// store pvs size, used for evaluation purpose when pvss are stored only in the leaves 260 253 int mPvsSize; 261 262 254 /** stores number of entries in pvs 263 255 this variable has the same value as mPvsSize for object pvs, … … 265 257 */ 266 258 int mEntriesInPvs; 267 268 259 /** if the pvs size scalar (+ entries into pvs) 269 260 is up to date and corresponding to the real pvs size -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1676 r1679 615 615 { 616 616 //vm->ResetViewCells(); 617 //hack618 vm->mViewCells.clear();619 620 vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves);621 622 ViewCellContainer::const_iterator it, it_end = leaves.end();623 624 for (it = leaves.begin(); it != it_end; ++ it)625 {626 vm->mViewCells.push_back(*it);627 }617 //hack 618 vm->mViewCells.clear(); 619 ViewCellContainer leaves; 620 vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 621 622 ViewCellContainer::const_iterator it, it_end = leaves.end(); 623 624 for (it = leaves.begin(); it != it_end; ++ it) 625 { 626 vm->mViewCells.push_back(*it); 627 } 628 628 vm->mViewCellsFinished = true; 629 629 vm->mMaxPvsSize = (int)objects->size(); … … 856 856 857 857 858 void ViewCellsManager::ExportStats(const string &fileName) 859 { 860 mViewCellsTree->ExportStats(fileName); 861 } 862 863 858 864 void ViewCellsManager::EvalViewCellPartition() 859 865 { … … 949 955 string fileName = string(statsPrefix) + string(str); 950 956 951 mViewCellsTree->ExportStats(fileName);957 ExportStats(fileName); 952 958 953 959 timeDiff = TimeDiff(startTime, GetTime()); … … 2285 2291 //Vector3 center = viewCell->GetBox().Center(); 2286 2292 // Vector3 center = m->mBox.Center(); 2287 2288 2289 2293 2294 // AxisAlignedBox3 box(center - Vector3(viewSpaceFilterSize/2), 2295 // center + Vector3(viewSpaceFilterSize/2)); 2290 2296 if (!ViewCellsConstructed()) 2291 2297 return; 2292 2298 2293 2294 2295 2296 2297 2298 AxisAlignedBox3 box = GetViewCellBox(viewCell);2299 box.Enlarge(Vector3(viewSpaceFilterSize/2));2300 2301 ViewCellContainer viewCells;2302 ComputeBoxIntersections(box, viewCells);2303 2304 2305 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end();2306 2307 int i;2308 for (i=0; it != it_end; ++ it, ++ i) {2309 2310 2311 }2312 2313 PrVs prvs;2314 AxisAlignedBox3 box = GetViewCellBox(viewCell);2315 2316 // mViewCellsManager->SetMaxFilterSize(1);2317 GetPrVS(box.Center(), prvs, viewSpaceFilterSize);2318 pvs = prvs.mViewCell->GetPvs();2319 DeleteLocalMergeTree(prvs.mViewCell);2320 2321 2322 pvs = viewCell->GetPvs();2323 2324 2325 ApplySpatialFilter(kdTree, spatialFilterSize, pvs);2326 2299 if (viewSpaceFilterSize >= 0.0f) { 2300 2301 const bool usePrVS = false; 2302 2303 if (!usePrVS) { 2304 AxisAlignedBox3 box = GetViewCellBox(viewCell); 2305 box.Enlarge(Vector3(viewSpaceFilterSize/2)); 2306 2307 ViewCellContainer viewCells; 2308 ComputeBoxIntersections(box, viewCells); 2309 2310 // cout<<"box="<<box<<endl; 2311 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 2312 2313 int i; 2314 for (i=0; it != it_end; ++ it, ++ i) { 2315 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 2316 pvs.Merge((*it)->GetPvs()); 2317 } 2318 } else { 2319 PrVs prvs; 2320 AxisAlignedBox3 box = GetViewCellBox(viewCell); 2321 2322 // mViewCellsManager->SetMaxFilterSize(1); 2323 GetPrVS(box.Center(), prvs, viewSpaceFilterSize); 2324 pvs = prvs.mViewCell->GetPvs(); 2325 DeleteLocalMergeTree(prvs.mViewCell); 2326 } 2327 } else 2328 pvs = viewCell->GetPvs(); 2329 2330 if (spatialFilterSize >=0.0f) 2331 ApplySpatialFilter(kdTree, spatialFilterSize, pvs); 2332 2327 2333 } 2328 2334 … … 2339 2345 return; 2340 2346 2341 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 2342 2343 ObjectPvs *newPvs; 2344 newPvs = new ObjectPvs[mViewCells.size()]; 2345 2346 float viewSpaceFilterSize = Magnitude(mViewSpaceBox.Size())*relViewSpaceFilterSize; 2347 float spatialFilterSize = Magnitude(kdTree->GetBox().Size())*relSpatialFilterSize; 2348 2349 int i; 2350 for (i=0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 2351 ApplyFilter(*it, 2352 kdTree, 2353 viewSpaceFilterSize, 2354 spatialFilterSize, 2355 newPvs[i] 2356 ); 2357 } 2358 2359 // now replace all pvss 2360 for (i = 0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 2361 2362 ObjectPvs &pvs = (*it)->GetPvs(); 2363 pvs.Clear(); 2364 pvs = newPvs[i]; 2365 newPvs[i].Clear(); 2366 } 2367 2368 delete [] newPvs; 2369 } 2370 2371 2347 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 2348 2349 ObjectPvs *newPvs; 2350 newPvs = new ObjectPvs[mViewCells.size()]; 2351 2352 float viewSpaceFilterSize = Magnitude(mViewSpaceBox.Size())*relViewSpaceFilterSize; 2353 float spatialFilterSize = Magnitude(kdTree->GetBox().Size())*relSpatialFilterSize; 2354 2355 int i; 2356 for (i=0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 2357 ApplyFilter(*it, 2358 kdTree, 2359 viewSpaceFilterSize, 2360 spatialFilterSize, 2361 newPvs[i] 2362 ); 2363 } 2364 2365 // now replace all pvss 2366 for (i = 0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 2367 2368 ObjectPvs &pvs = (*it)->GetPvs(); 2369 pvs.Clear(); 2370 pvs = newPvs[i]; 2371 newPvs[i].Clear(); 2372 } 2373 2374 delete [] newPvs; 2375 } 2372 2376 2373 2377 … … 2379 2383 ) 2380 2384 { 2381 2382 2383 2384 2385 2386 2385 // now compute a new Pvs by including also objects intersecting the 2386 // extended boxes of visible objects 2387 Intersectable::NewMail(); 2388 2389 ObjectPvsMap::const_iterator oi; 2390 2387 2391 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++ oi) 2388 2392 { … … 5619 5623 5620 5624 typedef priority_queue<BvhNode *, vector<BvhNode *>, 5621 myless<vector<BvhNode *>::value_type> > ObjectsQueue; 5622 5625 myless<vector<BvhNode *>::value_type> > BvhQueue; 5626 5627 typedef priority_queue<VspNode *, vector<VspNode *>, 5628 myless<vector<VspNode *>::value_type> > VspQueue; 5629 5630 static void UpdateStats(ofstream &stats, 5631 const int splits, 5632 const float totalRenderCost, 5633 const int entriesInPvs, 5634 const float memoryCost, 5635 const bool vsp) 5636 { 5637 stats << "#Pass\n" << 0 << endl 5638 << "#Splits\n" << splits << endl 5639 << "#TotalRenderCost\n" << totalRenderCost << endl 5640 << "#TotalEntriesInPvs\n" << entriesInPvs << endl 5641 << "#Memory\n" << memoryCost << endl 5642 << "#Vsp\n" << (vsp ? 1 : 0) << endl 5643 << endl; 5644 } 5645 5646 /* 5623 5647 void VspOspViewCellsManager::ExportStats(const string &mergeStats) 5624 5648 { … … 5626 5650 stats.open(mergeStats.c_str()); 5627 5651 5628 ObjectsQueue objectsQueue; 5629 ViewCellsQueue viewCellsQueue; 5630 5631 objectsQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 5632 viewCellsQueue.push(mViewCellsTree->GetRoot()); 5633 5634 int numViewCells = 1; 5652 BvhQueue bvhQueue; 5653 VspQueue vspQueue; 5654 //ViewCellsQueue viewCellsQueue; 5655 5656 bvhQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 5657 vspQueue.push(mHierarchyManager->GetVspTree()->GetRoot()); 5658 5659 int numSteps = 1; 5635 5660 5636 5661 const AxisAlignedBox3 box = mViewSpaceBox; 5637 5662 const float vol = box.GetVolume(); 5638 5663 5639 const int rootPvs = mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 5640 const int rootEntries = mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 5641 5642 cout << "exporting stats ... " << endl; 5643 5644 float totalRenderCost, avgRenderCost, expectedCost; 5645 5646 float deviation = 0; 5647 int totalPvs = rootPvs; 5648 int entriesInPvs = rootEntries; 5649 5650 totalRenderCost = avgRenderCost = expectedCost = (float)rootPvs; 5651 5664 float totalRenderCost = (float)mPreprocessor->mObjects.size();//(float)mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 5665 int entriesInPvs = 1;//mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 5666 5667 cout << "exporting vsposp stats ... " << endl; 5652 5668 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 5653 5669 5654 5670 ///////////// 5655 5671 //-- first view cell 5656 5657 /* mViewCellsTree->UpdateStats(stats, 5658 0, 5659 numViewCells, 5660 0, 5661 totalRenderCost, 5662 rootPvs, 5663 expectedCost, 5664 avgRenderCost, 5665 deviation, 5666 totalPvs, 5667 entriesInPvs, 5668 memoryCost, 5669 0, 5670 mRoot->GetVolume()); 5671 */ 5672 UpdateStats(stats, 2, totalRenderCost, entriesInPvs, memoryCost, true); 5672 5673 5673 5674 //-- go through tree in the order of render cost decrease … … 5675 5676 //-- or the reverse order of subdivision for subdivision-only 5676 5677 //-- view cell hierarchies. 5677 5678 while (!(objectsQueue.empty() && viewCellsQueue.empty())) 5679 { 5680 ViewCell *viewCell = viewCellsQueue.top(); 5681 BvhNode *bvhNode = objectsQueue.top(); 5682 5683 if (viewCell->GetMergeCost() < bvhNode->GetMergeCost()) 5684 { 5685 viewCellsQueue.pop(); 5686 /* 5687 if (!vc->IsLeaf()) 5678 int i = 0; 5679 while (!(bvhQueue.empty() && vspQueue.empty())) 5680 { 5681 const float vspCost = !vspQueue.empty() ? vspQueue.top()->GetMergeCost() : -99999999.0; 5682 const float ospCost = !bvhQueue.empty() ? bvhQueue.top()->GetMergeCost() : -99999999.0; 5683 5684 if (vspCost > ospCost) 5685 { 5686 cout << "vsp: " << (int)-vspCost << endl; 5687 cout << "v"; 5688 VspNode *vspNode = vspQueue.top(); 5689 5690 if (!vspNode) 5691 { 5692 cerr << "big error!" << endl; 5693 break; 5694 } 5695 vspQueue.pop(); 5696 5697 if (!vspNode->IsLeaf()) 5688 5698 { 5689 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 5690 5691 const int parentPvs = GetPvsSize(interior); 5692 const int parentPvsEntries = GetPvsEntries(interior); 5693 const float parentCost = (float)parentPvs * interior->GetVolume(); 5694 5695 float childCost = 0; 5696 int childPvs = 0; 5697 int childPvsEntries = 0; 5698 5699 -- numViewCells; 5700 5701 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 5702 5703 for (it = interior->mChildren.begin(); it != it_end; ++ it) 5704 { 5705 ViewCell *vc = *it; 5706 5707 const int pvsSize = GetPvsSize(vc); 5708 const int pvsEntries = GetPvsEntries(vc); 5709 5710 childCost += (float) pvsSize * vc->GetVolume(); 5711 childPvs += pvsSize; 5712 childPvsEntries += pvsEntries; 5713 5714 tqueue.push(vc); 5715 ++ numViewCells; 5716 } 5717 5718 // update stats for this view cell 5719 const float costDecr = (parentCost - childCost) / vol; 5720 5721 totalRenderCost -= costDecr; 5722 totalPvs += childPvs - parentPvs; 5723 entriesInPvs += childPvsEntries - parentPvsEntries; 5724 5725 expectedCost = totalRenderCost / (float)numViewCells; 5726 avgRenderCost = (float)totalPvs / (float)numViewCells; 5727 5728 const float memoryCost = (float)entriesInPvs * 5729 (float)ObjectPvs::GetEntrySize(); 5730 5731 mViewCellsTree->UpdateStats(stats, 5732 0, 5733 numViewCells, 5734 costDecr, 5735 totalRenderCost, 5736 parentPvs, 5737 expectedCost, 5738 avgRenderCost, 5739 deviation, 5740 totalPvs, 5741 entriesInPvs, 5742 memoryCost, 5743 childPvs - parentPvs, 5744 vc->GetVolume()); 5745 */ 5699 totalRenderCost -= vspNode->mRenderCostDecr; 5700 entriesInPvs += vspNode->mPvsEntriesIncr; 5701 5702 i ++; 5703 5704 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 5705 UpdateStats(stats, i, totalRenderCost, entriesInPvs, memoryCost, true); 5706 5707 VspNode *front = dynamic_cast<VspInterior *>(vspNode)->GetFront(); 5708 VspNode *back= dynamic_cast<VspInterior *>(vspNode)->GetBack(); 5709 5710 if (!front->IsLeaf()) 5711 vspQueue.push(front); 5712 if (!back->IsLeaf()) 5713 vspQueue.push(back); 5746 5714 } 5747 else // object space split 5715 } 5716 else // object space split 5717 { 5718 cout << "o"; 5719 BvhNode *bvhNode = bvhQueue.top(); 5720 cout << "bvh: " << (int)-ospCost << endl; 5721 if (!bvhNode) 5748 5722 { 5723 cerr << "big error!" << endl; 5724 break; 5749 5725 } 5726 bvhQueue.pop(); 5727 5728 if (!bvhNode->IsLeaf()) 5729 { 5730 totalRenderCost -= bvhNode->mRenderCostDecr; 5731 entriesInPvs += bvhNode->mPvsEntriesIncr; 5732 5733 i ++; 5734 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 5735 UpdateStats(stats, i, totalRenderCost, entriesInPvs, memoryCost, false); 5736 5737 BvhNode *front = dynamic_cast<BvhInterior *>(bvhNode)->GetFront(); 5738 BvhNode *back= dynamic_cast<BvhInterior *>(bvhNode)->GetBack(); 5739 5740 if (!front->IsLeaf()) 5741 bvhQueue.push(front); 5742 if (!back->IsLeaf()) 5743 bvhQueue.push(back); 5744 } 5745 } 5746 cout << i << endl; 5747 5750 5748 } 5751 5749 5752 5750 stats.close(); 5753 5751 } 5754 5752 */ 5755 5753 5756 5754 #if TEST_EVALUATION -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1676 r1679 634 634 void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 635 635 636 virtual void ExportStats(const string &mergeStats); 636 637 637 638 … … 1132 1133 void ExportPvs(const ObjectContainer &objects, const VssRayContainer &rays); 1133 1134 1134 void ExportStats(const string &mergeStats);1135 //void ExportStats(const string &mergeStats); 1135 1136 1136 1137 ///////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1673 r1679 179 179 180 180 VspNode::VspNode(): 181 mParent(NULL), mTreeValid(true), mTimeStamp(0) 181 mParent(NULL), 182 mTreeValid(true), 183 mTimeStamp(0), 184 mRenderCostDecr(0), 185 mMemoryIncr(0), 186 mPvsEntriesIncr(0) 182 187 {} 183 188 184 189 185 190 VspNode::VspNode(VspInterior *parent): 186 mParent(parent), mTreeValid(true) 191 mParent(parent), 192 mTreeValid(true), 193 mMemoryIncr(0), 194 mPvsEntriesIncr(0), 195 mTimeStamp(0) 187 196 {} 188 197 … … 334 343 335 344 336 VspLeaf::VspLeaf(): mViewCell(NULL), mPvs(NULL), mSubdivisionCandidate(NULL) 345 VspLeaf::VspLeaf(): 346 mViewCell(NULL), mPvs(NULL), mSubdivisionCandidate(NULL) 337 347 { 338 348 } … … 711 721 tBackData.mMaxCostMisses = maxCostMisses; 712 722 723 newNode->mRenderCostDecr = sc->GetRenderCostDecrease(); 724 newNode->mPvsEntriesIncr = sc->GetPvsEntriesIncr(); 725 713 726 mTotalCost -= sc->GetRenderCostDecrease(); 714 727 mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; … … 966 979 967 980 // set the time stamp so the order of traversal can be reconstructed 968 interior->mTimeStamp = m TimeStamp ++;969 981 interior->mTimeStamp = mHierarchyManager->mTimeStamp ++; 982 cout << "here6 " << interior->mTimeStamp << endl; 970 983 return interior; 971 984 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1677 r1679 147 147 public: 148 148 149 // types of vsp nodes149 /// types of vsp nodes 150 150 enum {Interior, Leaf}; 151 151 … … 165 165 */ 166 166 virtual bool IsRoot() const; 167 167 168 /** Returns parent node. 168 169 */ 169 170 VspInterior *GetParent(); 171 170 172 /** Sets parent node. 171 173 */ 172 174 void SetParent(VspInterior *parent); 175 173 176 /** Returns true if this node is a sibling of node n. 174 177 */ 175 178 bool IsSibling(VspNode *n) const; 179 176 180 /** returns depth of the node. 177 181 */ 178 182 int GetDepth() const; 183 179 184 /** returns true if the whole subtree is valid 180 185 */ … … 182 187 183 188 void SetTreeValid(const bool v); 184 189 190 /** Cost of mergin this node. 191 */ 192 float GetMergeCost() {return (float)-mTimeStamp; } 193 194 ///////// 185 195 //-- mailing options 186 196 … … 195 205 int mTimeStamp; 196 206 207 int mPvsEntriesIncr; 208 float mMemoryIncr; 209 float mRenderCostDecr; 210 197 211 protected: 198 212 199 213 /// if this sub tree is a completely valid view space region 200 214 bool mTreeValid; 215 201 216 /// parent of this node 202 217 VspInterior *mParent; … … 209 224 { 210 225 public: 226 211 227 /** Standard contructor taking split plane as argument. 212 228 */ … … 214 230 215 231 ~VspInterior(); 232 216 233 /** @return false since it is an interior node 217 234 */ … … 315 332 /// Rays piercing this leaf. 316 333 VssRayContainer mVssRays; 334 317 335 /// leaf pvs 318 336 ObjectPvs *mPvs; 337 319 338 /// Probability that the view point lies in this leaf 320 339 float mProbability; … … 324 343 /// pointer to a split plane candidate splitting this leaf 325 344 SubdivisionCandidate *mSubdivisionCandidate; 345 326 346 /// if NULL this does not correspond to feasible viewcell 327 347 ViewCellLeaf *mViewCell; … … 492 512 if (hm->ConsiderMemory()) 493 513 { 494 //const float rc = mRenderCostDecrease / hm->GetHierarchyStats().mTotalCost; 495 const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 514 const float rc = mRenderCostDecrease / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 496 515 //const float mc = mMemoryIncr / / hm->GetHierarchyStats().mMemory; 516 //const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 497 517 const float mc = (float)mPvsEntriesIncr / (float)hm->GetHierarchyStats().mPvsEntries; 498 cout << "vsp rc: " << rc << " mc: " << mc << endl; 518 519 //cout << "\np: " << mPriority << " i: " << hm->mInitialRenderCost << " t: " << hm->GetHierarchyStats().mTotalCost << endl; 520 //cout << "vsp rc: " << rc << " mc: " << mc << endl; 521 499 522 return hm->GetMemoryConst() * rc - (1.0f - hm->GetMemoryConst()) * mc; 500 523 }
Note: See TracChangeset
for help on using the changeset viewer.