- Timestamp:
- 11/18/05 20:30:31 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r422 r423 62 62 63 63 Sampling { 64 totalSamples 100000064 totalSamples 300000 65 65 samplesPerPass 3 66 66 } … … 208 208 Termination { 209 209 maxDepth 40 210 minPvs 1211 minRays 50212 minSize 0.00 001210 minPvs 5 211 minRays 100 212 minSize 0.001 213 213 maxCostRatio 0.95 214 maxRayContribution 0. 05214 maxRayContribution 0.1 215 215 } 216 216 217 217 maxTotalMemory 400 218 maxStaticMemory 20 218 maxStaticMemory 200 219 219 220 220 splitType regular -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r422 r423 764 764 cout << "building VSP tree from " << (int)mVspSampleRays.size() << " samples " << endl; 765 765 mVspKdTree = new VspKdTree(); 766 mVspKdTree->Construct(mVspSampleRays );766 mVspKdTree->Construct(mVspSampleRays, &mKdTree->GetBox()); 767 767 768 768 // add contributions of saved samples to PVS -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r422 r423 739 739 (data.mArea <= mTermMinArea) || 740 740 (data.mDepth >= mTermMaxDepth) || 741 (((float)data.mPvs / ((float)data.mRays->size() + Limits::Small)) < 742 mTermMaxRayContribution)); 741 (data.GetAvgRayContribution() < mTermMaxRayContribution)); 743 742 } 744 743 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r422 r423 351 351 int mPvs; 352 352 353 /** Returns average ray contribution. 354 */ 355 float GetAvgRayContribution() const 356 { 357 return (float)mPvs / ((float)mRays->size() + Limits::Small); 358 } 359 360 353 361 BspTraversalData(): 354 362 mNode(NULL), -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r422 r423 118 118 } 119 119 120 void VspKdTreeInterior::ReplaceChildLink(VspKdTreeNode *oldChild, VspKdTreeNode *newChild) 120 void VspKdTreeInterior::ReplaceChildLink(VspKdTreeNode *oldChild, 121 VspKdTreeNode *newChild) 121 122 { 122 123 if (mBack == oldChild) … … 139 140 void VspKdTreeInterior::Print(ostream &s) const 140 141 { 141 if (mAxis == 0) 142 s << "x "; 143 else 144 if (mAxis == 1) 145 s << "y "; 146 else 147 s << "z "; 142 switch (mAxis) 143 { 144 case 0: 145 s << "x "; break; 146 case 1: 147 s << "y "; break; 148 case 2: 149 s << "z "; break; 150 } 151 148 152 s << mPosition << " "; 149 153 … … 268 272 environment->GetStringValue("VspKdTree.splitType", sname); 269 273 string name(sname); 270 271 if (name.compare("regular") == 0) 272 splitType = ESplitRegular; 273 else 274 { 275 if (name.compare("heuristic") == 0) 276 splitType = ESplitHeuristic; 277 else 278 { 279 cerr << "Invalid VspKdTree split type " << name << endl; 280 exit(1); 281 } 282 } 283 274 284 275 Debug << "======= vsp kd tree options ========" << endl; 285 276 Debug << "max depth: "<< mTermMaxDepth << endl; … … 289 280 Debug << "max cost ratio: "<< mTermMaxCostRatio << endl; 290 281 Debug << "min size: "<<mTermMinSize << endl; 282 283 if (name.compare("regular") == 0) 284 { 285 Debug << "using regular split" << endl; 286 splitType = ESplitRegular; 287 } 288 else 289 { 290 if (name.compare("heuristic") == 0) 291 { 292 Debug << "using heuristic split" << endl; 293 splitType = ESplitHeuristic; 294 } 295 else 296 { 297 cerr << "Invalid VspKdTree split type " << name << endl; 298 exit(1); 299 } 300 } 291 301 292 302 mRoot = NULL; … … 415 425 mRoot = new VspKdTreeLeaf(NULL, (int)rays.size()); 416 426 417 // first construct a leaf that will get subdivide 427 // first construct a leaf that will get subdivided 418 428 VspKdTreeLeaf *leaf = dynamic_cast<VspKdTreeLeaf *>(mRoot); 419 429 … … 453 463 454 464 mStat.Print(cout); 455 cout<<"#Total memory=" << GetMemUsage() << endl;465 Debug << "#Total memory=" << GetMemUsage() << endl; 456 466 } 457 467 … … 463 473 464 474 priority_queue<TraversalData> tStack; 465 // 475 //stack<TraversalData> tStack; 466 476 467 477 tStack.push(tdata); … … 471 481 472 482 int lastMem = 0; 483 473 484 while (!tStack.empty()) 474 485 { 475 486 float mem = GetMemUsage(); 476 487 477 if ( lastMem/10 != ((int)mem)/10)488 if (lastMem / 10 != ((int)mem) / 10) 478 489 { 479 490 cout << mem << " MB" << endl; … … 481 492 lastMem = (int)mem; 482 493 483 if (mem > mMaxMemory) 484 { 494 if (1 && mem > mMaxMemory) 495 { 496 Debug << "memory limit reached: " << mem << endl; 485 497 // count statistics on unprocessed leafs 486 498 while (!tStack.empty()) … … 493 505 494 506 TraversalData data = tStack.top(); 495 tStack.pop(); 496 507 tStack.pop(); 497 508 498 509 VspKdTreeNode *node = SubdivideNode((VspKdTreeLeaf *) data.mNode, … … 503 514 if (!node->IsLeaf()) 504 515 { 505 VspKdTreeInterior *interior = (VspKdTreeInterior *) node;516 VspKdTreeInterior *interior = dynamic_cast<VspKdTreeInterior *>(node); 506 517 507 518 // push the children on the stack … … 542 553 pvsBack, 543 554 pvsFront); 544 545 555 } 546 else 547 { 548 if (splitType == ESplitHeuristic) 556 else if (splitType == ESplitHeuristic) 557 { 549 558 costRatio = BestCostRatioHeuristic(leaf, 550 559 axis, … … 554 563 pvsBack, 555 564 pvsFront); 556 else { 557 cerr << "VspKdTree: Unknown split heuristics\n"; 558 exit(1); 559 } 560 } 565 } 566 else 567 { 568 cerr << "VspKdTree: Unknown split heuristics\n"; 569 exit(1); 570 } 561 571 562 572 if (costRatio > mTermMaxCostRatio) 563 573 { 564 cout <<"Too big cost ratio " << costRatio << endl;574 cout << "Too big cost ratio " << costRatio << endl; 565 575 return -1; 566 576 } 567 577 568 578 #if 1 569 cout<<579 Debug << 570 580 "pvs=" << leaf->mPvsSize << 571 581 " rays=" << (int)leaf->mRays.size() << … … 880 890 const AxisAlignedBox3 &box) const 881 891 { 882 return ((leaf->GetPvsSize() < mTermMinPvs) || (leaf->mRays.size() < mTermMinRays) || 892 return ((leaf->GetPvsSize() < mTermMinPvs) || 893 //(leaf->mRays.size() < mTermMinRays) || 883 894 // (leaf->GetAvgRayContribution() > termMaxRayContribution ) || 884 (leaf->mDepth >= mTermMaxDepth) || SqrMagnitude(box.Size()) <= mTermMinSize); 895 (leaf->mDepth >= mTermMaxDepth) || 896 (SqrMagnitude(box.Size()) <= mTermMinSize)); 885 897 } 886 898 … … 893 905 if (TerminationCriteriaMet(leaf, box)) 894 906 { 895 896 #if 1 897 if (leaf->mDepth >= mTermMaxDepth) 898 { 899 Debug << "Warning: max depth reached depth="<<(int)leaf->mDepth<<" rays=" << (int)leaf->mRays.size() << endl; 900 Debug << "Bbox: " << GetBBox(leaf) << endl; 901 } 902 #endif 907 if (1) 908 { 909 if (leaf->mDepth >= mTermMaxDepth) 910 { 911 Debug << "Warning: max depth reached depth=" << (int)leaf->mDepth<<" rays=" << (int)leaf->mRays.size() << endl; 912 Debug << "Bbox: " << GetBBox(leaf) << endl; 913 } 903 914 915 Debug << "depth: " << (int)leaf->mDepth << " pvs: " << leaf->GetPvsSize() << " rays: " << leaf->mRays.size() << endl; 916 } 904 917 return leaf; 905 918 } … … 913 926 914 927 // select subdivision axis 915 int axis = SelectPlane( leaf, box, position, raysBack, raysFront, pvsBack, pvsFront); 916 917 // cout<<"rays back="<<raysBack<<" rays front="<<raysFront<<" pvs back="<<pvsBack<<" pvs front="<< 918 // pvsFront<<endl; 928 int axis = SelectPlane(leaf, box, position, raysBack, raysFront, pvsBack, pvsFront); 929 930 Debug << "rays back=" << raysBack << " rays front=" << raysFront << " pvs back=" << pvsBack << " pvs front=" << pvsFront << endl; 919 931 920 932 if (axis == -1) … … 1040 1052 tstack.push(mRoot); 1041 1053 1042 while (!tstack.empty()) 1054 while (!tstack.empty()) 1043 1055 { 1044 1056 VspKdTreeNode *node = tstack.top(); … … 1078 1090 1079 1091 1080 1081 1082 1092 VspKdTreeNode *VspKdTree::SubdivideLeaf(VspKdTreeLeaf *leaf, 1083 1093 const float sizeThreshold) … … 1095 1105 (SqrMagnitude(leafBBox.Size()) > sizeThreshold) ) 1096 1106 { 1097 // memory check and re alese...1107 // memory check and release 1098 1108 if (GetMemUsage() > mMaxTotalMemory) 1099 1109 ReleaseMemory(pass); … … 1109 1119 1110 1120 1111 void 1112 VspKdTree::UpdateRays(VssRayContainer &remove, 1113 VssRayContainer &add) 1121 void VspKdTree::UpdateRays(VssRayContainer &remove, 1122 VssRayContainer &add) 1114 1123 { 1115 1124 VspKdTreeLeaf::NewMail(); … … 1135 1144 1136 1145 // cout<<"all/inactive"<<remove.size()<<"/"<<inactive<<endl; 1137 1138 for(VssRayContainer::const_iterator ri = add.begin(); ri != add.end(); ++ ri) 1146 for (VssRayContainer::const_iterator ri = add.begin(); ri != add.end(); ++ ri) 1139 1147 { 1140 1148 AddRay(*ri); … … 1256 1264 // find the ray in the leaf and swap it with the last ray 1257 1265 VspKdTreeLeaf *leaf = dynamic_cast<VspKdTreeLeaf *>(data.mNode); 1266 1258 1267 leaf->AddRay(data.mRayData); 1259 1268 ++ mStat.addedRayRefs; … … 1416 1425 1417 1426 #if DEBUG_COLLAPSE 1418 cout <<"Total memory before="<<GetMemUsage()<<endl;1427 cout << "Total memory before=" << GetMemUsage() << endl; 1419 1428 #endif 1420 1429 … … 1537 1546 } 1538 1547 1539 cout<< "sum=" << sumRayContribution << endl;1540 cout<< "leaves=" << leaves << endl;1541 avgRayContribution = sumRayContribution /(float)leaves;1548 Debug << "sum=" << sumRayContribution << endl; 1549 Debug << "leaves=" << leaves << endl; 1550 avgRayContribution = sumRayContribution / (float)leaves; 1542 1551 } 1543 1552 … … 1556 1565 if (node->IsLeaf()) 1557 1566 { 1558 VspKdTreeLeaf *leaf = (VspKdTreeLeaf *)node; 1567 VspKdTreeLeaf *leaf = dynamic_cast<VspKdTreeLeaf *>(node); 1568 1559 1569 float c = leaf->GetAvgRayContribution(); 1560 1570 int num = (int)(c*ratioPerLeaf + 0.5); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r422 r423 327 327 AxisAlignedBox3 mBox; 328 328 int mDepth; 329 float mPriority;329 //float mPriority; 330 330 331 331 TraversalData() {} 332 332 333 333 TraversalData(VspKdTreeNode *n, const float p): 334 mNode(n) , mPriority(p)334 mNode(n)//, mPriority(p) 335 335 {} 336 336 … … 338 338 mNode(n), mBox(b), mDepth(d) {} 339 339 340 // comparator for the 341 struct less_priority : public binary_function<const TraversalData, const TraversalData, bool>340 // comparator for the priority queue 341 /*struct less_priority : public binary_function<const TraversalData, const TraversalData, bool> 342 342 { 343 bool operator()(const TraversalData a, const TraversalData b) 344 { 345 return a.mPriority < b.mPriority; 346 } 347 }; 343 bool operator()(const TraversalData a, const TraversalData b) { 344 return a.mPriority < b.mPriority; } };*/ 348 345 349 346 // ~TraversalData() {} … … 375 372 #if 0 376 373 return 377 leafa->GetPvsSize() / (float)(leafa->rays.size() + 1)374 leafa->GetPvsSize() / (float)(leafa->rays.size() + Limits::Small()) 378 375 > 379 leafb->GetPvsSize() / (float)(leafb->rays.size() + 1);376 leafb->GetPvsSize() / (float)(leafb->rays.size() + Limits::Small()); 380 377 #endif 381 378 #if 0 -
trunk/VUT/Ogre/resources/overlays/VisibilityDemo.overlay
r418 r423 127 127 width 120 128 128 height 30 129 caption [ A] HW Query type129 caption [Q] HW Query type 130 130 } 131 131 element TextArea(Example/Visibility/UseArbQueriesInfo): Example/Visibility/Templates/BasicText … … 425 425 width 180 426 426 height 30 427 caption [ S] Show / hide shadows427 caption [H] Show / hide shadows 428 428 } 429 429 element TextArea(Example/Visibility/Help/Filter): Example/Visibility/Templates/BasicText
Note: See TracChangeset
for help on using the changeset viewer.