Changeset 1297 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 08/30/06 04:39:53 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1294 r1297 26 26 static float debugVol = 0; 27 27 28 int BvhNode::sMailId = 2147483647;28 int BvhNode::sMailId = 10000;//2147483647; 29 29 int BvhNode::sReservedMailboxes = 1; 30 30 … … 44 44 /***************************************************************/ 45 45 46 BvhNode::BvhNode(): mParent(NULL) 46 BvhNode::BvhNode(): mParent(NULL), mMailbox(0) 47 47 { 48 48 } 49 49 50 50 BvhNode::BvhNode(const AxisAlignedBox3 &bbox): 51 mParent(NULL), mBoundingBox(bbox) 51 mParent(NULL), mBoundingBox(bbox), mMailbox(0) 52 52 { 53 53 } … … 55 55 56 56 BvhNode::BvhNode(const AxisAlignedBox3 &bbox, BvhInterior *parent): 57 mBoundingBox(bbox), mParent(parent) 57 mBoundingBox(bbox), mParent(parent), mMailbox(0) 58 58 { 59 59 } … … 217 217 218 218 //-- factors for bsp tree split plane heuristics 219 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.ct_div_ci", mCtDivCi);220 221 //-- partition criteria222 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.epsilon", mEpsilon);223 219 224 220 // if only the driving axis is used for axis aligned split … … 227 223 Environment::GetSingleton()->GetBoolValue("BvHierarchy.useCostHeuristics", mUseCostHeuristics); 228 224 229 230 225 char subdivisionStatsLog[100]; 231 226 Environment::GetSingleton()->GetStringValue("BvHierarchy.subdivisionStats", subdivisionStatsLog); 232 227 mSubdivisionStats.open(subdivisionStatsLog); 233 228 234 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.splitBorder", mSplitBorder);235 229 Environment::GetSingleton()->GetFloatValue( 236 230 "BvHierarchy.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); … … 240 234 241 235 Debug << "******* Bvh hierarchy options ******** " << endl; 242 243 236 Debug << "max depth: " << mTermMaxDepth << endl; 244 237 Debug << "min probabiliy: " << mTermMinProbability<< endl; … … 247 240 Debug << "miss tolerance: " << mTermMissTolerance << endl; 248 241 Debug << "max leaves: " << mTermMaxLeaves << endl; 249 250 242 Debug << "randomize: " << randomize << endl; 251 252 243 Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 253 244 Debug << "global cost miss tolerance: " << mTermGlobalCostMissTolerance << endl; … … 387 378 EvalSubdivisionCandidate(*frontCandidate); 388 379 EvalSubdivisionCandidate(*backCandidate); 380 381 // cross reference 382 tFrontData.mNode->SetSubdivisionCandidate(frontCandidate); 383 tBackData.mNode->SetSubdivisionCandidate(backCandidate); 389 384 390 385 tQueue.Push(frontCandidate); … … 397 392 398 393 //-- terminate traversal 399 if (newNode->IsLeaf()) 400 { 394 if (newNode->IsLeaf()) 395 { 396 //-- store additional info 401 397 EvaluateLeafStats(tData); 402 398 403 const bool mStoreRays= true; 404 405 //-- store additional info 399 const bool mStoreRays = true; 406 400 if (mStoreRays) 407 401 { … … 429 423 430 424 // cost ratio violated? 431 const bool maxCostRatioViolated = ratio < mTermMaxCostRatio;425 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 432 426 433 427 splitCandidate.mMaxCostMisses = maxCostRatioViolated ? 434 splitCandidate.mParentData.mMaxCostMisses :435 splitCandidate.mParentData.mMaxCostMisses + 1;428 splitCandidate.mParentData.mMaxCostMisses + 1 : 429 splitCandidate.mParentData.mMaxCostMisses; 436 430 437 431 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); … … 451 445 splitCandidate.SetRenderCostDecrease(renderCostDecr); 452 446 453 #if 1447 #if 0 454 448 const float priority = (float)-splitCandidate.mParentData.mDepth; 455 449 #else … … 520 514 521 515 516 #if 0 522 517 float BvHierarchy::EvalLocalObjectPartition(const BvhTraversalData &tData, 523 518 const int axis, … … 535 530 { 536 531 Intersectable *obj = *oit; 537 AxisAlignedBox3 box = obj->GetBox();532 const AxisAlignedBox3 box = obj->GetBox(); 538 533 539 534 const float objMid = (box.Max(axis) + box.Min(axis)) * 0.5f; … … 553 548 return ratio; 554 549 } 550 551 #else 552 553 float BvHierarchy::EvalLocalObjectPartition(const BvhTraversalData &tData, 554 const int axis, 555 ObjectContainer &objectsFront, 556 ObjectContainer &objectsBack) 557 { 558 SortSubdivisionCandidates(tData, axis); 559 560 vector<SortableEntry>::const_iterator cit, cit_end = mSubdivisionCandidates->end(); 561 562 int i = 0; 563 const int border = (int)tData.mNode->mObjects.size() / 2; 564 565 for (cit = mSubdivisionCandidates->begin(); cit != cit_end; ++ cit, ++ i) 566 { 567 Intersectable *obj = (*cit).mObject; 568 569 // object mailed => belongs to back objects 570 if (i < border) 571 objectsBack.push_back(obj); 572 else 573 objectsFront.push_back(obj); 574 } 575 576 const float oldRenderCost = tData.mProbability * (float)tData.mNode->mObjects.size(); 577 const float newRenderCost = 578 EvalRenderCost(tData, objectsFront, objectsBack); 579 580 const float ratio = newRenderCost / oldRenderCost; 581 return ratio; 582 } 583 #endif 555 584 556 585 … … 719 748 // mail view cells on the left side 720 749 ViewCell::NewMail(); 721 722 750 // mail the objects on the left side 723 751 Intersectable::NewMail(); … … 762 790 // => add volume to left node 763 791 volLeft += vol; 764 //volRight -= vol;765 792 } 766 793 … … 815 842 { 816 843 if (mUseCostHeuristics) 817 { 844 {cout << "h"; 818 845 //-- partition objects using heuristics 819 846 nCostRatio[axis] = … … 825 852 } 826 853 else 827 { 854 {cout << "m"; 828 855 nCostRatio[axis] = 829 856 EvalLocalObjectPartition( … … 1072 1099 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1073 1100 1101 Debug << "collecting " << (int)viewCells.size() << " dirty candidates" << endl; 1074 1102 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1075 1103 { 1076 1104 VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 1077 1078 1105 VspLeaf *leaf = vc->mLeaf; 1106 SubdivisionCandidate *candidate = leaf->GetSubdivisionCandidate(); 1107 1079 1108 dirtyList.push_back(leaf->GetSubdivisionCandidate()); 1080 1109 } … … 1108 1137 { 1109 1138 // rather use the simple version 1110 if (object->mBvhLeaf) 1111 { 1112 return object->mBvhLeaf; 1113 } 1114 1139 if (!object) return NULL; 1140 return object->mBvhLeaf; 1141 1115 1142 /////////////////////////////////////// 1116 1143 // start from root of tree 1144 1117 1145 if (node == NULL) 1118 {1119 1146 node = mRoot; 1120 } 1121 1147 1122 1148 vector<BvhLeaf *> leaves; 1123 1149 … … 1182 1208 1183 1209 1184 /*1185 int BvHierarchy::UpdateViewCellsPvs(BvhLeaf *leaf,1186 const RayInfoContainer &rays) const1187 1188 {1189 MailablePvsData::NewMail();1190 1191 ViewCellContainer touchedViewCells;1192 CollectTouchedViewCells(rays, touchedViewCells);1193 1194 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end();1195 1196 for (oit = leaf->mObjects.begin(); oit < oit_end; ++ oit)1197 {1198 Intersectable *obj = *oit;1199 ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end();1200 1201 // traverse through view cells and classify them according1202 // to them being seen from to back / front / front and back node1203 for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit)1204 {1205 ViewCell *vc = *vit;1206 float contri;1207 AddViewCellToObjectPvs(obj, vc, contri, true);1208 }1209 }1210 1211 return 0;1212 }1213 1214 1215 int BvHierarchy::RemoveParentViewCellsPvs(BvhLeaf *leaf,1216 const RayInfoContainer &rays1217 ) const1218 1219 {1220 MailablePvsData::NewMail();1221 1222 ViewCellContainer touchedViewCells;1223 CollectTouchedViewCells(rays, touchedViewCells);1224 1225 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end();1226 1227 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit)1228 {1229 Intersectable *obj = *oit;1230 1231 // traverse through view cells and classify them according1232 // to them being seen from to back / front / front and back node1233 ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end();1234 1235 for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit)1236 {1237 ViewCell *vc = *vit;1238 1239 MailablePvsData *vdata = obj->mViewCellPvs.Find(vc);1240 1241 if (vdata && !vdata->Mailed())1242 {1243 vdata->Mail();1244 obj->mViewCellPvs.RemoveSample(vc, 1);1245 }1246 }1247 }1248 1249 return 0;1250 }1251 */1252 1253 1210 bool BvHierarchy::Export(OUT_STREAM &stream) 1254 1211 { -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1294 r1297 35 35 class VspTree; 36 36 class ViewCellsContainer; 37 class BvhSubdivisionCandidate; 38 37 39 38 40 /** View space partition statistics. … … 45 47 // number of splits 46 48 int splits; 47 48 49 // maximal reached depth 49 50 int maxDepth; 50 51 // minimal depth 51 52 int minDepth; 52 53 53 // max depth nodes 54 54 int maxDepthNodes; … … 123 123 enum {Interior, Leaf}; 124 124 125 BvhNode ::BvhNode();125 BvhNode(); 126 126 BvhNode(const AxisAlignedBox3 &bbox); 127 127 BvhNode(const AxisAlignedBox3 &bbox, BvhInterior *parent); … … 183 183 /// the bounding box of the node 184 184 AxisAlignedBox3 mBoundingBox; 185 186 185 /// parent of this node 187 186 BvhInterior *mParent; … … 246 245 bool IsLeaf() const; 247 246 248 SubdivisionCandidate *GetSubdivisionCandidate() const247 SubdivisionCandidate *GetSubdivisionCandidate()// const 249 248 { 250 249 return mSubdivisionCandidate; 251 250 } 252 251 252 void SetSubdivisionCandidate(SubdivisionCandidate *candidate) 253 { 254 mSubdivisionCandidate = candidate; 255 } 256 253 257 public: 254 258 255 259 /// Rays piercing this leaf. 256 260 VssRayContainer mVssRays; 257 258 261 /// objects 259 262 ObjectContainer mObjects; 260 261 263 /// universal counter 262 264 int mCounter; 263 264 265 265 266 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1294 r1297 2316 2316 2317 2317 2318 /********************************************************************** */2319 /* Bounding Volume Hierarchy related options 2320 /********************************************************************** */2318 /**********************************************************************/ 2319 /* Bounding Volume Hierarchy related options */ 2320 /**********************************************************************/ 2321 2321 2322 2322 RegisterOption("BvHierarchy.Construction.randomize", … … 2365 2365 "4"); 2366 2366 2367 RegisterOption("BvHierarchy.Termination.ct_div_ci",2368 optFloat,2369 "bvh_term_ct_div_ci=",2370 "0");2371 2372 RegisterOption("BvHierarchy.Construction.epsilon",2373 optFloat,2374 "bvh_construction_epsilon=",2375 "0.00001");2376 2377 2367 // if only the driving axis is used for axis aligned split 2378 2368 RegisterOption("BvHierarchy.splitUseOnlyDrivingAxis", … … 2395 2385 "bvh_subdivision_stats=", 2396 2386 "bvhSubdivisionStats.log"); 2397 2398 RegisterOption("BvHierarchy.Construction.splitBorder",2399 optFloat,2400 "bvh_construction_split_border=",2401 "0.01");2402 2387 2403 2388 RegisterOption("BvHierarchy.Construction.renderCostDecreaseWeight", -
GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h
r1233 r1297 214 214 215 215 Swap(i, (int)mBuffer.size() - 1); 216 216 217 217 mBuffer.pop_back(); 218 218 t->NotInHeap(); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1295 r1297 163 163 osc = mOspTree->PrepareConstruction(sampleRays, objects, objectSpaceRays); 164 164 mTQueue.Push(osc); 165 }166 break;165 break; 166 } 167 167 case BV_BASED_OBJ_SUBDIV: 168 168 { … … 176 176 osc = mBvHierarchy->PrepareConstruction(sampleRays, objects); 177 177 mTQueue.Push(osc); 178 }179 break;178 break; 179 } 180 180 default: 181 181 break; … … 183 183 184 184 mTotalCost = (float)objects.size(); 185 Debug << " 185 Debug << "setting total cost to " << mTotalCost << endl; 186 186 } 187 187 … … 273 273 const long startTime = GetTime(); 274 274 275 const bool repairQueue = true; 276 275 const bool repairQueue = false; 277 276 // process object space candidates 278 277 RunConstruction(repairQueue); … … 306 305 307 306 const long startTime = GetTime(); 307 308 308 const bool repairQueue = false; 309 // process object space candidates 310 RunConstruction(repairQueue); 309 311 310 312 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 340 342 const long startTime = GetTime(); 341 343 344 const bool repairQueue = false; 345 // process object space candidates 346 RunConstruction(repairQueue); 347 342 348 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 343 344 349 mOspTree->mOspStats.Stop(); 345 350 … … 348 353 349 354 const float rc = mOspTree->EvalRenderCost(sampleRays); 350 351 355 Debug << "My render cost evalulation: " << rc << endl; 352 356 } … … 472 476 void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList) 473 477 { 474 Debug << "here65" << endl;475 478 // we have either a object space or view space split 476 479 if (mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 477 480 { 478 Debug << "collected view space candidate" << endl;479 481 CollectViewSpaceDirtyList(dirtyList); 480 482 } 481 483 else // object space split 482 484 { 483 Debug << "collecting object space candidate" << endl;484 485 CollectObjectSpaceDirtyList(dirtyList); 485 486 } … … 515 516 for (sit = dirtyList.begin(); sit != sit_end; ++ sit) 516 517 { 517 Debug << "here4423" << endl;518 518 SubdivisionCandidate* sc = *sit; 519 519 // erase from queue 520 520 mTQueue.Erase(sc); 521 522 521 // reevaluate 523 522 sc->EvalPriority(); 524 525 523 // reinsert 526 524 mTQueue.Push(sc); … … 668 666 mVspTree->mVspStats.Start(); 669 667 670 int i = 0;671 672 668 // all objects can be seen from everywhere 673 669 mTotalCost = (float)dynamic_cast<VspTree::VspSubdivisionCandidate *>(vsc)->mParentData.mPvs; 674 670 675 671 const bool repairQueue = false; 676 677 672 // process view space candidates 678 673 RunConstruction(repairQueue); … … 705 700 break; 706 701 } 707 708 // process object space candidates 709 RunConstruction(repairQueue); 710 } 711 712 713 } 702 } 703 704 705 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1292 r1297 9 9 bool MeshDebug = false; 10 10 11 int Intersectable::sMailId = 2147483647;11 int Intersectable::sMailId = 1;//2147483647; 12 12 int Intersectable::sReservedMailboxes = 1; 13 13 -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r1294 r1297 643 643 float sum = (float)totalVol * sizeBox; 644 644 645 Debug << " here82render cost: " << renderCost / viewSpaceVol << endl;645 Debug << "total render cost: " << renderCost / viewSpaceVol << endl; 646 646 647 647 ///////////////////////////////// … … 690 690 { 691 691 float currentPos; 692 Debug << " here29: " << minRenderCost / viewSpaceVol << endl;692 Debug << "current min: " << minRenderCost / viewSpaceVol << endl; 693 693 694 694 // HACK: current positition is BETWEEN visibility events … … 895 895 } 896 896 897 Debug << "here32 " << (int)touchedViewCells.size() << endl;898 897 return renderCost; 899 898 } … … 1386 1385 if (!vdata) 1387 1386 { 1388 Debug << " here86 error!!"<<endl;1387 Debug << "error!!" << endl; 1389 1388 continue; 1390 1389 } … … 1793 1792 } 1794 1793 } 1795 Debug << " here65" << (int)touchedObjects.size() << endl;1794 Debug << "touched view cells: " << (int)touchedObjects.size() << endl; 1796 1795 ObjectContainer::const_iterator it, it_end = touchedObjects.end(); 1797 1796 for (it = touchedObjects.begin(); it != it_end; ++ it) 1798 1797 { 1799 Debug << "\n here94 obj: " << (*it) << "size: " << (*it)->mViewCellPvs.GetSize() << endl << endl;1798 Debug << "\nobj: " << (*it) << " vc pvs size: " << (*it)->mViewCellPvs.GetSize() << endl << endl; 1800 1799 ViewCellPvsMap::const_iterator mit, mit_end = (*it)->mViewCellPvs.mEntries.end(); 1801 1800 1802 1801 for (mit = (*it)->mViewCellPvs.mEntries.begin(); mit != mit_end; ++ mit) 1803 1802 { 1804 Debug << "new sumpdf: " << (*mit).second.mSumPdf << endl;1803 Debug << "new sumpdf: " << (*mit).second.mSumPdf << endl; 1805 1804 } 1806 1805 } -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1292 r1297 695 695 696 696 CastRays(rays, tmpVssRays); 697 castRays += rays.size();697 castRays += (int)rays.size(); 698 698 #if ADD_RAYS_IN_PLACE 699 699 contributions[0] = mViewCellsManager->ComputeSampleContributions(tmpVssRays, true, false); -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1280 r1297 103 103 mPreprocessor.mViewCellsManager->GetViewPoint(origin); 104 104 105 const float alpha = RandomValue(0.0f, 2.0f * M_PI);106 const float beta = RandomValue( -M_PI * 0.5f,M_PI * 0.5f);105 const float alpha = RandomValue(0.0f, 2.0f * (float)M_PI); 106 const float beta = RandomValue((float)-M_PI * 0.5f, (float)M_PI * 0.5f); 107 107 108 108 direction = VssRay::GetDirection(alpha, beta); -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1259 r1297 46 46 } 47 47 48 /** Position in queue. 49 */ 50 int GetPosition() const 51 { 52 return mPosition; 53 } 54 48 55 protected: 49 56 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1287 r1297 32 32 myless<vector<ViewCell *>::value_type> > TraversalQueue; 33 33 34 int ViewCell::sMailId = 2147483647;34 int ViewCell::sMailId = 1;//2147483647; 35 35 int ViewCell::sReservedMailboxes = 1; 36 36 … … 112 112 mEntriesInPvs(0), 113 113 mPvsSizeValid(false) 114 //mMailbox(0) 114 115 { 115 116 } … … 124 125 mPvsSize(0), 125 126 mPvsSizeValid(false) 127 //mMailbox(0) 126 128 { 127 129 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1286 r1297 233 233 234 234 //////////////////////////////////////////// 235 // 235 //-- mailing stuff 236 236 237 237 … … 255 255 static int sMailId; 256 256 static int sReservedMailboxes; 257 257 //int mMailbox; 258 258 259 259 protected: … … 261 261 /// parent view cell in the view cell hierarchy 262 262 ViewCellInterior *mParent; 263 264 263 /// the potentially visible objects 265 264 ObjectPvs mPvs; 266 265 /// the volume of this view cell 267 266 float mVolume; 267 268 268 float mArea; 269 269 /// the cost that were paid for merging this view cells from two others. … … 271 271 /// if the view cell is valid view space 272 272 bool mValid; 273 274 273 /// color used for consistent visualization 275 274 RgbColor mColor; 276 277 275 /// store pvs size, used for evaluation purpose when pvss are stored only in the leaves 278 276 int mPvsSize; 277 279 278 /** stores number of entries in pvs 280 279 this variable has the same value as mPvsSize for object pvs, … … 283 282 int mEntriesInPvs; 284 283 285 /// if the pvs size scalar (+ entries into pvs) 286 /// is up to date and corresponding to the real pvs size 284 /** if the pvs size scalar (+ entries into pvs) 285 is up to date and corresponding to the real pvs size 286 */ 287 287 bool mPvsSizeValid; 288 288 289 }; 289 290 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1294 r1297 164 164 mHierarchyManager->mOspTree->mRoot, *mObjects); 165 165 } 166 else167 cout << "here209" << endl;168 169 166 } 170 167 … … 1237 1234 for (int i = 0; i < len; ++ i) 1238 1235 { 1239 cout << "here5" << endl;1240 1236 string attrName(StrX(attributes.getName(i)).LocalForm()); 1241 1237 StrX attrValue(attributes.getValue(i)); … … 1256 1252 if (mCurrentBvhNode) // replace NULL child of parent with current node 1257 1253 { 1258 cout << "here8" << endl;1259 1254 BvhInterior *parent = dynamic_cast<BvhInterior *>(mCurrentBvhNode); 1260 1255 parent->ReplaceChildLink(NULL, interior); -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1294 r1297 535 535 ); 536 536 537 if ( 0&& localTerminationCriteriaMet)537 if (1 && localTerminationCriteriaMet) 538 538 { 539 539 Debug << "********local termination *********" << endl; … … 628 628 { 629 629 // todo remove dynamic cast 630 VspSubdivisionCandidate *sc = dynamic_cast<VspSubdivisionCandidate *>(splitCandidate); 630 VspSubdivisionCandidate *sc = 631 dynamic_cast<VspSubdivisionCandidate *>(splitCandidate); 631 632 VspTraversalData &tData = sc->mParentData; 632 633 633 634 VspNode *newNode = tData.mNode; 634 635 635 636 636 if (!LocalTerminationCriteriaMet(tData) && !globalCriteriaMet) 637 637 { 638 //-- continue subdivision 638 639 VspTraversalData tFrontData; 639 640 VspTraversalData tBackData; 640 641 //-- continue subdivision642 641 643 642 // create new interior node and two leaf node 644 643 const AxisAlignedPlane splitPlane = sc->mSplitPlane; 644 const int maxCostMisses = sc->mMaxCostMisses; 645 645 646 newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData); 646 647 647 const int maxCostMisses = sc->mMaxCostMisses;648 649 650 648 // how often was max cost ratio missed in this branch? 651 649 tFrontData.mMaxCostMisses = maxCostMisses; … … 666 664 EvalSubdivisionCandidate(*backCandidate); 667 665 666 // cross reference 667 tFrontData.mNode->SetSubdivisionCandidate(frontCandidate); 668 tBackData.mNode->SetSubdivisionCandidate(backCandidate); 669 668 670 tQueue.Push(frontCandidate); 669 671 tQueue.Push(backCandidate); 670 672 671 // delete old view cell672 delete tData.mNode->mViewCell;673 674 673 // delete old leaf node 675 674 //DEL_PTR(tData.mNode); … … 689 688 #if 0 690 689 //-- store pvs optained from rays 691 692 690 AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); 693 691 … … 734 732 backProb); 735 733 736 const bool success = ratio < mTermMaxCostRatio;734 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 737 735 738 736 // max cost threshold violated? 739 737 splitCandidate.mMaxCostMisses = 740 success ? splitCandidate.mParentData.mMaxCostMisses : splitCandidate.mParentData.mMaxCostMisses + 1; 738 maxCostRatioViolated ? 739 splitCandidate.mParentData.mMaxCostMisses + 1: 740 splitCandidate.mParentData.mMaxCostMisses; 741 741 742 742 float oldRenderCost; … … 749 749 splitCandidate.SetRenderCostDecrease(renderCostDecr); 750 750 751 #if 1751 #if 0 752 752 const float priority = (float)-splitCandidate.mParentData.mDepth; 753 753 #else … … 783 783 *frontData.mRays, 784 784 *backData.mRays); 785 786 //Debug << "f: " << frontData.mRays->size() << " b: " << backData.mRays->size() << "d: " << tData.mRays->size() << endl;787 785 788 786 //-- compute pvs … … 790 788 backData.mPvs = EvalPvsSize(*backData.mRays); 791 789 790 Debug << "f pvs: " << frontData.mPvs << " b pvs: " << backData.mPvs << " pvs " << tData.mPvs << endl; 791 792 792 // split front and back node geometry and compute area 793 tData.mBoundingBox.Split(splitPlane.mAxis, splitPlane.mPosition, 794 frontData.mBoundingBox, backData.mBoundingBox); 795 793 tData.mBoundingBox.Split(splitPlane.mAxis, 794 splitPlane.mPosition, 795 frontData.mBoundingBox, 796 backData.mBoundingBox); 796 797 797 798 frontData.mProbability = frontData.mBoundingBox.GetVolume(); 798 799 backData.mProbability = tData.mProbability - frontData.mProbability; 799 800 800 801 801 802 /////////////////////////////////////////// 802 803 // subdivide further … … 805 806 if (tData.mDepth > mVspStats.maxDepth) 806 807 { 807 Debug << "max depth increases to " << tData.mDepth << " at " << mVspStats.Leaves() << " leaves" << endl; 808 Debug << "max depth increases to " << tData.mDepth 809 << " at " << mVspStats.Leaves() << " leaves" << endl; 808 810 mVspStats.maxDepth = tData.mDepth; 809 811 } … … 1054 1056 Intersectable::NewMail(); 1055 1057 KdNode::NewMail(); 1056 Bvh Node::NewMail();1058 BvhLeaf::NewMail(); 1057 1059 1058 1060 int pvsSize = 0; … … 1366 1368 float totalPvs = 0; 1367 1369 1368 // probability that view point lies in back / front node1369 float pOverall = data.mProbability;1370 float pFront = 0;1371 float pBack = 0;1372 1373 1370 const float viewSpaceVol = mBoundingBox.GetVolume(); 1374 1371 … … 1376 1373 Intersectable::NewMail(3); 1377 1374 KdLeaf::NewMail(3); 1375 //for (int i=0;i<25;++i) BvhLeaf::NewMail(); 1378 1376 BvhLeaf::NewMail(3); 1379 1377 … … 1394 1392 // evaluate contribution of ray endpoint to front and back pvs 1395 1393 // with respect to the classification 1396 UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs); 1394 //Debug << "mail1: " << BvhLeaf::sMailId << endl; 1395 UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs); 1396 //Debug << "mail2: " << BvhLeaf::sMailId << endl; 1397 1397 UpdateContributionsToPvs(*ray, false, cf, pvsFront, pvsBack, totalPvs); 1398 //Debug << "mail3: " << BvhLeaf::sMailId << endl; 1398 1399 } 1399 1400 … … 1404 1405 data.mBoundingBox.Split(candidatePlane.mAxis, candidatePlane.mPosition, frontBox, backBox); 1405 1406 1406 pFront = frontBox.GetVolume(); 1407 pBack = pOverall - pFront; 1407 // probability that view point lies in back / front node 1408 float pOverall = data.mProbability; 1409 float pFront = pFront = frontBox.GetVolume(); 1410 float pBack = pOverall - pFront; 1411 1408 1412 1409 1413 //-- pvs rendering heuristics 1410 1411 1414 const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 1412 1415 const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); … … 1449 1452 // create unique ids for pvs heuristics 1450 1453 Intersectable::NewMail(3); 1454 BvhLeaf::NewMail(3); 1455 KdLeaf::NewMail(3); 1451 1456 1452 1457 const int pvsSize = data.mPvs; … … 1563 1568 { 1564 1569 frontPvs += renderCost; 1565 1570 1566 1571 // already in back pvs => in both pvss 1567 1572 if (leaf->Mailed(1)) … … 1580 1585 // already in front pvs => in both pvss 1581 1586 if (leaf->Mailed()) 1587 { 1582 1588 leaf->Mail(2); 1589 } 1583 1590 else 1584 1591 leaf->Mail(1); … … 2061 2068 Intersectable::NewMail(); 2062 2069 KdNode::NewMail(); 2063 Bvh Node::NewMail();2070 BvhLeaf::NewMail(); 2064 2071 2065 2072 RayInfoContainer::const_iterator rit, rit_end = rays.end(); … … 2627 2634 Debug << "rays size: " << (int)rays.size() << endl; 2628 2635 2629 2630 2636 //-- prepare view space partition 2631 2637 const float prop = mBoundingBox.GetVolume(); … … 2642 2648 2643 2649 #if WORK_WITH_VIEWCELL_PVS 2644 2645 2650 // add first view cell to all the objects view cell pvs 2646 2651 ObjectPvsMap::const_iterator oit, … … 2951 2956 BvhLeaf *bvhleaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 2952 2957 2953 if ( bvhleaf &&!bvhleaf->Mailed())2958 if (!bvhleaf->Mailed()) 2954 2959 { 2955 2960 bvhleaf->Mail(); -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1294 r1297 37 37 class KdTreeStatistics; 38 38 class SubdivisionCandidate; 39 39 class VspSubdivisionCandidate; 40 40 41 41 /** View space partition statistics. … … 161 161 */ 162 162 virtual bool IsRoot() const; 163 164 163 /** Returns parent node. 165 164 */ 166 165 VspInterior *GetParent(); 167 168 166 /** Sets parent node. 169 167 */ 170 168 void SetParent(VspInterior *parent); 171 172 169 /** Returns true if this node is a sibling of node n. 173 170 */ 174 171 bool IsSibling(VspNode *n) const; 175 176 172 /** returns depth of the node. 177 173 */ 178 174 int GetDepth() const; 179 180 175 /** returns true if the whole subtree is valid 181 176 */ … … 297 292 */ 298 293 ViewCellLeaf *GetViewCell() const; 299 300 294 /** Sets pointer to view cell. 301 295 */ 302 296 void SetViewCell(ViewCellLeaf *viewCell); 303 297 304 SubdivisionCandidate *GetSubdivisionCandidate() const298 SubdivisionCandidate *GetSubdivisionCandidate() 305 299 { 306 300 return mSubdivisionCandidate; 307 301 } 308 302 303 void SetSubdivisionCandidate(SubdivisionCandidate *candidate) 304 { 305 mSubdivisionCandidate = candidate; 306 } 307 308 309 309 public: 310 310 311 311 /// Rays piercing this leaf. 312 312 VssRayContainer mVssRays; 313 314 313 /// leaf pvs 315 314 ObjectPvs *mPvs; 316 317 315 /// Probability that the view point lies in this leaf 318 316 float mProbability; … … 322 320 /// pointer to a split plane candidate splitting this leaf 323 321 SubdivisionCandidate *mSubdivisionCandidate; 324 325 322 /// if NULL this does not correspond to feasible viewcell 326 323 ViewCellLeaf *mViewCell; … … 400 397 { 401 398 DEL_PTR(mRays); 402 DEL_PTR(mNode); 399 400 if (mNode) 401 { 402 // delete old view cell 403 delete mNode->GetViewCell(); 404 delete mNode; 405 mNode = NULL; 406 } 403 407 } 404 408 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp
r1233 r1297 543 543 float sum = pvsBack*(position - minBox) + pvsFront*(maxBox - position); 544 544 float newCost = ct_div_ci + sum/sizeBox; 545 float oldCost = pvsSize;545 float oldCost = (float)pvsSize; 546 546 ratio = newCost/oldCost; 547 547 548 } else { 548 549 // importance based cost … … 559 560 #else 560 561 #if 1 561 float newCost = raysBack*pvsBack + raysFront*pvsFront;562 float newCost = float(raysBack*pvsBack + raysFront*pvsFront); 562 563 float oldCost = (float)leaf->rays.size()*pvsSize; 563 564 ratio = newCost/oldCost; … … 807 808 float maxBand = minBox + 0.9*(maxBox - minBox); 808 809 809 float minRatio = 1e20 ;810 float minRatio = 1e20f; 810 811 811 812 Intersectable::NewMail(); … … 1663 1664 VssTreeLeaf *leaf = (VssTreeLeaf *)node; 1664 1665 float c = leaf->GetImportance(); 1665 int num = (c*ratioPerLeaf + 0.5 );1666 int num = (c*ratioPerLeaf + 0.5f); 1666 1667 // cout<<num<<" "; 1667 1668 … … 1720 1721 { 1721 1722 int nrays = (int)leaf->rays.size(); 1722 for (int i =0; i < numberOfRays; i++) {1723 for (int i = 0; i < numberOfRays; ++ i) { 1723 1724 // pickup 3 random rays 1724 int r1 = (int)RandomValue(0, nrays-1);1725 int r2 = (int)RandomValue(0, nrays-1);1726 int r3 = (int)RandomValue(0, nrays-1);1725 int r1 = (int)RandomValue(0, (float)(nrays-1)); 1726 int r2 = (int)RandomValue(0, (float)(nrays-1)); 1727 int r3 = (int)RandomValue(0, (float)(nrays-1)); 1727 1728 1728 1729 Vector3 o1 = leaf->rays[r1].Extrap(RandomValue(leaf->rays[r1].GetMinT(),
Note: See TracChangeset
for help on using the changeset viewer.