- Timestamp:
- 10/17/06 20:32:06 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 3 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1624 r1633 509 509 510 510 const float renderCostDecr = oldRenderCost - newRenderCost; 511 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate); 512 511 513 512 #ifdef _DEBUG 514 513 Debug << "old render cost: " << oldRenderCost << endl; … … 516 515 Debug << "render cost decrease: " << renderCostDecr << endl; 517 516 #endif 518 519 splitCandidate.SetRenderCostDecrease(renderCostDecr);520 splitCandidate.SetPvsEntriesIncr(EvalPvsEntriesIncr(splitCandidate));521 517 522 518 #if 1 … … 529 525 #endif 530 526 527 splitCandidate.SetRenderCostDecrease(renderCostDecr); 528 529 // increase in pvs entries 530 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate); 531 splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr); 532 531 533 // compute global decrease in render cost 532 534 splitCandidate.SetPriority(priority); 535 } 536 537 538 float BvHierarchy::EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const 539 { 540 BvhLeaf *leaf = splitCandidate.mParentData.mNode; 541 542 const float oldRenderCost = EvalRenderCost(leaf->mObjects); 543 544 // compute global decrease in render cost 545 const float newRenderCost = 546 EvalRenderCost(splitCandidate.mFrontObjects) + 547 EvalRenderCost(splitCandidate.mBackObjects); 548 549 const float renderCostDecr = oldRenderCost - newRenderCost; 550 551 #ifdef _DEBUG 552 Debug << "old render cost: " << oldRenderCost << endl; 553 Debug << "new render cost: " << newRenderCost << endl; 554 Debug << "render cost decrease: " << renderCostDecr << endl; 555 #endif 556 557 #if 1 558 // take render cost of node into account 559 // otherwise danger of being stuck in a local minimum!! 560 const float factor = mRenderCostDecreaseWeight; 561 const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 562 #else 563 const float priority = (float)-splitCandidate.mParentData.mDepth; 564 #endif 565 566 return priority; 533 567 } 534 568 … … 569 603 ); 570 604 571 if (1 && terminationCriteriaMet) 605 #ifdef _DEBUG 606 if (terminationCriteriaMet) 572 607 { 573 608 Debug << "bvh global termination criteria met:" << endl; … … 575 610 Debug << "leaves: " << mBvhStats.Leaves() << " " << mTermMaxLeaves << endl; 576 611 } 577 612 #endif 578 613 return terminationCriteriaMet; 579 614 } … … 1529 1564 1530 1565 void BvHierarchy::CollectDirtyCandidates(BvhSubdivisionCandidate *sc, 1531 vector<SubdivisionCandidate *> &dirtyList) 1566 vector<SubdivisionCandidate *> &dirtyList, 1567 const bool onlyUnmailed) 1532 1568 { 1533 1569 BvhTraversalData &tData = sc->mParentData; … … 1535 1571 1536 1572 ViewCellContainer viewCells; 1537 CollectViewCells(node->mObjects, viewCells); 1573 ViewCell::NewMail(); 1574 CollectViewCells(node->mObjects, viewCells, true); 1575 1538 1576 if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 1539 1577 1540 1578 // split candidates handling 1541 1579 // these view cells are thrown into dirty list … … 1544 1582 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1545 1583 { 1546 1584 VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 1547 1585 VspLeaf *leaf = vc->mLeaves[0]; 1586 1548 1587 SubdivisionCandidate *candidate = leaf->GetSubdivisionCandidate(); 1549 1588 1550 if (candidate) // is this leaf still a split candidate? 1551 { 1589 // is this leaf still a split candidate? 1590 if (candidate && (!onlyUnmailed || !candidate->Mailed())) 1591 { 1592 candidate->Mail(); 1552 1593 dirtyList.push_back(candidate); 1553 1594 } -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1632 r1633 403 403 int Type() const { return OBJECT_SPACE; } 404 404 405 void EvalPriority( )405 void EvalPriority(bool computeSplitplane = true) 406 406 { 407 sBvHierarchy->EvalSubdivisionCandidate(*this); 407 if (computeSplitplane) 408 sBvHierarchy->EvalSubdivisionCandidate(*this); 409 else 410 mPriority = sBvHierarchy->EvalPriority(*this); 408 411 } 409 412 410 /*bool Apply(SplitQueue *queue, bool terminationCriteriaMet)413 bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) 411 414 { 412 415 BvhNode *n = sBvHierarchy->Subdivide(splitQueue, this, terminationCriteriaMet); 413 416 // local or global termination criteria failed 414 417 return !n->IsLeaf(); 415 }*/ 418 } 419 420 void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, 421 const bool onlyUnmailed) 422 { 423 sBvHierarchy->CollectDirtyCandidates(this, dirtyList, onlyUnmailed); 424 } 416 425 417 426 bool GlobalTerminationCriteriaMet() const … … 710 719 float PrepareHeuristics(const BvhTraversalData &tData, const int axis); 711 720 721 /** Reevaluates the priority of this split candidate 722 @returns priority 723 */ 724 float EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const; 725 712 726 //////////////////////////////////////////////// 713 727 … … 725 739 void CollectDirtyCandidates( 726 740 BvhSubdivisionCandidate *sc, 727 vector<SubdivisionCandidate *> &dirtyList); 741 vector<SubdivisionCandidate *> &dirtyList, 742 const bool onlyUnmailed); 728 743 729 744 /** Collect view cells which see this bvh leaf. -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1613 r1633 2526 2526 "4"); 2527 2527 2528 2529 RegisterOption("Hierarchy.Construction.recomputeSplitPlaneOnRepair", 2530 optBool, 2531 "hierarchy_construction_recompute_split_on_repair=", 2532 "true"); 2533 2528 2534 ///////////////////////////////////////////////////////////////// 2529 2535 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1632 r1633 113 113 mSubdivisionStats.open(subdivisionStatsLog); 114 114 115 //mMinRenderCostDecrease = -1; 115 Environment::GetSingleton()->GetBoolValue( 116 "Hierarchy.Construction.recomputeSplitPlaneOnRepair", mRecomputeSplitPlaneOnRepair); 116 117 117 118 Debug << "******** Hierachy Manager Parameters ***********" << endl; … … 122 123 Debug << "repair queue: " << mRepairQueue << endl; 123 124 Debug << "number of multilevels: " << mNumMultiLevels << endl; 125 Debug << "recompute split plane on repair: " << mRecomputeSplitPlaneOnRepair << endl; 124 126 125 127 switch (mConstructionType) … … 259 261 (0 260 262 || (mHierarchyStats.Leaves() >= mTermMaxLeaves) 261 || (mHierarchyStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance)263 //|| (mHierarchyStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 262 264 || (candidate->GlobalTerminationCriteriaMet()) 263 265 //|| (mHierarchyStats.mRenderCostDecrease < mMinRenderCostDecrease) … … 316 318 // compute view space bounding box 317 319 mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 320 321 SplitQueue objectSpaceQueue; 322 SplitQueue viewSpaceQueue; 318 323 319 324 // use sah for evaluating osp tree construction … … 324 329 mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 325 330 326 SplitQueue objectSpaceQueue;327 SplitQueue viewSpaceQueue;328 329 331 // number of initial splits 330 332 int maxSteps = 200; 331 333 float renderCostDecr = 0; 334 335 SubdivisionCandidate *osc = 336 PrepareObjectSpaceSubdivision(sampleRays, objects); 337 338 objectSpaceQueue.Push(osc); 339 340 ///////////////////////// 341 // calulcate initial object space splits 342 343 SubdivisionCandidateContainer dirtyVspList; 344 345 // subdivide object space first 346 // for first round, use sah splits. Once view space partition 347 // has started, use render cost heuristics instead 348 const int ospSteps = 349 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, maxSteps); 350 351 cout << ospSteps << " object space partition steps taken" << endl; 352 353 SubdivisionCandidate *vsc = 354 PrepareViewSpaceSubdivision(sampleRays, objects); 355 356 viewSpaceQueue.Push(vsc); 357 358 // view space subdivision was constructed 359 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 360 361 // don't terminate on max steps 362 //maxSteps = mTermMaxLeaves; 332 363 333 364 // This method subdivides view space / object space … … 337 368 // and vice versa until iteration depth is reached. 338 369 339 while (1) 340 { 341 // subdivide object space first 342 // for first round, use sah splits. Once view space partition 343 // has started, use render cost heuristics instead 344 SubdivisionCandidate *osc = 345 ResetObjectSpaceSubdivision(sampleRays, objects); 346 objectSpaceQueue.Push(osc); 347 348 // process object space candidates using render queue for 349 // objects until slope of previous subdivision is reached 350 SubdivisionCandidateContainer ospContainer; 351 352 const int ospSteps = 353 RunConstruction(objectSpaceQueue, ospContainer, renderCostDecr, maxSteps); 354 cout << ospSteps << " object space partition steps taken" << endl; 355 356 // use splits of one kind until rendercost slope is reached 357 renderCostDecr = mHierarchyStats.mRenderCostDecrease; 370 while (!(viewSpaceQueue.Empty() && objectSpaceQueue.Empty())) 371 { 372 // should view or object space be subdivided further? 373 if (viewSpaceQueue.Empty() || 374 (!objectSpaceQueue.Empty() && 375 (objectSpaceQueue.Top()->GetPriority() > viewSpaceQueue.Top()->GetPriority()))) 376 { 377 // use splits of one kind until rendercost slope is reached 378 renderCostDecr = mHierarchyStats.mRenderCostDecrease; 379 380 // dirtied view space candidates 381 SubdivisionCandidateContainer dirtyVspList; 382 383 // subdivide object space first 384 // for first round, use sah splits. Once view space partition 385 // has started, use render cost heuristics instead 386 const int ospSteps = 387 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, maxSteps); 388 389 cout << ospSteps << " object space partition steps taken" << endl; 358 390 359 // object space subdivision constructed 360 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 361 362 /// Repair split queue 363 cout << "repairing queue ... " << endl; 364 365 vector<SubdivisionCandidate *> dirtyList; 366 367 CollectDirtyCandidates(ospContainer, dirtyList); 368 //RepairQueue(dirtyList, viewSpaceQueue); 369 370 cout << "finished repairing queue ... " << endl; 371 372 CLEAR_CONTAINER(ospContainer); 373 374 ///////////////// 375 // subdivide view space with respect to the objects 376 377 SubdivisionCandidate *vsc = 378 ResetViewSpaceSubdivision(sampleRays, objects); 379 viewSpaceQueue.Push(vsc); 380 381 SubdivisionCandidateContainer vspContainer; 382 // process view space candidates 383 const int vspSteps = 384 RunConstruction(viewSpaceQueue, vspContainer, renderCostDecr, maxSteps); 385 386 cout << vspSteps << " view space partition steps taken" << endl; 387 388 // view space subdivision constructed 389 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 390 391 // use splits of one kind until rendercost slope is reached 392 renderCostDecr = mHierarchyStats.mRenderCostDecrease; 393 394 /// Repair split queue 395 cout << "repairing queue ... " << endl; 396 397 CollectDirtyCandidates(vspContainer, dirtyList); 398 //RepairQueue(dirtyList, objectSpaceQueue); 399 400 cout << "finished repairing queue ... " << endl; 401 402 CLEAR_CONTAINER(vspContainer); 403 } 404 391 // object space subdivision constructed 392 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 393 394 /// Repair split queue 395 cout << "repairing queue ... " << endl; 396 RepairQueue(dirtyVspList, viewSpaceQueue, true); 397 cout << "repaired " << dirtyVspList.size() << " candidates" << endl; 398 } 399 else 400 { 401 // use splits of one kind until rendercost slope is reached 402 renderCostDecr = mHierarchyStats.mRenderCostDecrease; 403 404 ///////////////// 405 // subdivide view space with respect to the objects 406 407 SubdivisionCandidateContainer dirtyOspList; 408 409 // process view space candidates 410 const int vspSteps = 411 RunConstruction(viewSpaceQueue, dirtyOspList, renderCostDecr, maxSteps); 412 413 cout << vspSteps << " view space partition steps taken" << endl; 414 415 // view space subdivision constructed 416 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 417 418 /// Repair split queue 419 cout << "repairing queue ... " << endl; 420 RepairQueue(dirtyOspList, objectSpaceQueue, true); 421 cout << "repaired " << dirtyOspList.size() << " candidates" << endl; 422 } 423 } 424 405 425 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 406 426 … … 432 452 mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 433 453 434 // use objects for evaluating vsp tree construction in the first levels435 // of the subdivision454 // use objects for evaluating vsp tree construction in the 455 // first levels of the subdivision 436 456 mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 437 457 mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; … … 557 577 const bool repairQueue) 558 578 { 559 // test if global termination criteria were met before this split560 579 const bool terminationCriteriaMet = GlobalTerminationCriteriaMet(sc); 561 const bool vspSplit = (sc->Type() == SubdivisionCandidate::VIEW_SPACE); 562 563 bool success = false; 564 565 switch (sc->Type()) 566 { 567 case SubdivisionCandidate::VIEW_SPACE: 568 { 569 VspNode *n = mVspTree->Subdivide(splitQueue, sc, terminationCriteriaMet); 570 571 // check if terminated 572 success = !n->IsLeaf(); 573 } 574 break; 575 case SubdivisionCandidate::OBJECT_SPACE: 576 { 577 if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 578 { 579 KdNode *n = mOspTree->Subdivide(splitQueue, sc, terminationCriteriaMet); 580 581 // local or global termination criteria failed 582 success = !n->IsLeaf(); 583 } 584 else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 585 { 586 BvhNode *n = mBvHierarchy->Subdivide(splitQueue, sc, terminationCriteriaMet); 587 588 // local or global termination criteria failed 589 success = !n->IsLeaf(); 590 } 591 } 592 break; 593 default: 594 cerr << "unknown subdivision type" << endl; 595 break; 596 } 580 581 const bool success = sc->Apply(splitQueue, terminationCriteriaMet); 597 582 598 583 if (!success) // split was not taken … … 635 620 // this would be object space splits and other way round 636 621 vector<SubdivisionCandidate *> dirtyList; 637 CollectDirtyCandidates(sc, dirtyList);638 639 RepairQueue(dirtyList, splitQueue );622 sc->CollectDirtyCandidates(dirtyList, false); 623 624 RepairQueue(dirtyList, splitQueue, mRecomputeSplitPlaneOnRepair); 640 625 } 641 626 … … 766 751 //////// 767 752 //-- subdivide leaf node of either type 768 769 753 ApplySubdivisionCandidate(sc, mTQueue, repairQueue); 770 771 754 DEL_PTR(sc); 772 755 } … … 775 758 776 759 int HierarchyManager::RunConstruction(SplitQueue &splitQueue, 777 SubdivisionCandidateContainer & chosenCandidates,760 SubdivisionCandidateContainer &dirtyCandidates, 778 761 const float minRenderCostDecr, 779 762 const int maxSteps) 780 763 { 781 764 int steps = 0; 765 SubdivisionCandidate::NewMail(); 782 766 783 767 // main loop 784 while (!splitQueue.Empty() && ( (steps ++)< maxSteps))768 while (!splitQueue.Empty() && (steps < maxSteps)) 785 769 { 786 770 SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue); 787 771 788 772 // minimum slope reached 789 if (sc->GetRenderCostDecrease() < minRenderCostDecr) 790 break; 773 //if (sc->GetRenderCostDecrease() < minRenderCostDecr) break; 791 774 792 775 //////// … … 794 777 795 778 const bool repairQueue = false; 796 bool success = ApplySubdivisionCandidate(sc, splitQueue, repairQueue);779 const bool success = ApplySubdivisionCandidate(sc, splitQueue, repairQueue); 797 780 798 781 if (success) 799 782 { 800 chosenCandidates.push_back(sc); 783 sc->CollectDirtyCandidates(dirtyCandidates, true); 784 //cout << "collected " << dirtyCandidates.size() << "dirty candidates" << endl; 785 ++ steps; 801 786 } 802 787 } … … 826 811 827 812 firstCandidate = mBvHierarchy->Reset(sampleRays, objects); 828 cout << "here4" << endl;813 829 814 mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 830 815 … … 835 820 // evaluate stats before first subdivision 836 821 EvalSubdivisionStats(); 837 cout << "here5" << endl;838 822 } 839 823 break; … … 845 829 break; 846 830 } 847 cout << "here6" << endl; 831 848 832 return firstCandidate; 849 833 } … … 990 974 991 975 992 void HierarchyManager::CollectObjectSpaceDirtyList(SubdivisionCandidate *sc,993 SubdivisionCandidateContainer &dirtyList)994 {995 switch (mObjectSpaceSubdivisionType)996 {997 case KD_BASED_OBJ_SUBDIV:998 {999 OspTree::OspSubdivisionCandidate *ospSc =1000 dynamic_cast<OspTree::OspSubdivisionCandidate *>(sc);1001 1002 mOspTree->CollectDirtyCandidates(ospSc, dirtyList);1003 break;1004 }1005 case BV_BASED_OBJ_SUBDIV:1006 {1007 BvHierarchy::BvhSubdivisionCandidate *bvhSc =1008 dynamic_cast<BvHierarchy::BvhSubdivisionCandidate *>(sc);1009 1010 mBvHierarchy->CollectDirtyCandidates(bvhSc, dirtyList);1011 break;1012 }1013 default:1014 break;1015 }1016 }1017 1018 1019 void HierarchyManager::CollectViewSpaceDirtyList(SubdivisionCandidate *sc,1020 SubdivisionCandidateContainer &dirtyList)1021 {1022 VspTree::VspSubdivisionCandidate *vspSc =1023 dynamic_cast<VspTree::VspSubdivisionCandidate *>(sc);1024 1025 mVspTree->CollectDirtyCandidates(vspSc, dirtyList);1026 }1027 1028 1029 void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidate *sc,1030 SubdivisionCandidateContainer &dirtyList)1031 {1032 // we have either a object space or view space split1033 if (sc->Type() == SubdivisionCandidate::VIEW_SPACE)1034 {1035 CollectViewSpaceDirtyList(sc, dirtyList);1036 }1037 else // object space split1038 {1039 CollectObjectSpaceDirtyList(sc, dirtyList);1040 }1041 }1042 1043 1044 976 void HierarchyManager::CollectDirtyCandidates(const SubdivisionCandidateContainer &chosenCandidates, 1045 977 SubdivisionCandidateContainer &dirtyList) 1046 978 { 1047 979 SubdivisionCandidateContainer::const_iterator sit, sit_end = chosenCandidates.end(); 980 SubdivisionCandidate::NewMail(); 1048 981 1049 982 for (sit = chosenCandidates.begin(); sit != sit_end; ++ sit) 1050 983 { 1051 // we have either a object space or view space split 1052 if ((*sit)->Type() == SubdivisionCandidate::VIEW_SPACE) 1053 { 1054 CollectViewSpaceDirtyList(*sit, dirtyList); 1055 } 1056 else // object space split 1057 { 1058 CollectObjectSpaceDirtyList(*sit, dirtyList); 1059 } 1060 } 1061 } 1062 1063 1064 void HierarchyManager::RepairQueue(const vector<SubdivisionCandidate *> &dirtyList, 1065 SplitQueue &splitQueue) 984 (*sit)->CollectDirtyCandidates(dirtyList, true); 985 } 986 } 987 988 989 void HierarchyManager::RepairQueue(const SubdivisionCandidateContainer &dirtyList, 990 SplitQueue &splitQueue, 991 const bool recomputeSplitPlaneOnRepair) 1066 992 { 1067 993 // for each update of the view space partition: … … 1097 1023 1098 1024 splitQueue.Erase(sc); // erase from queue 1099 sc->EvalPriority( ); // reevaluate1025 sc->EvalPriority(recomputeSplitPlaneOnRepair); // reevaluate 1100 1026 1101 1027 #ifdef _DEBUG … … 1113 1039 mHierarchyStats.mRepairTime += timeDiff; 1114 1040 1115 if ( 1) cout << "repaired in " << timeDiff * 1e-3f << " secs" << endl;1041 if (0) cout << "repaired in " << timeDiff * 1e-3f << " secs" << endl; 1116 1042 } 1117 1043 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1627 r1633 106 106 107 107 108 typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue;109 110 108 /** This class implements a structure holding two different hierarchies, 111 109 one for object space partitioning and one for view space partitioning. … … 290 288 list of entries is given in the dirty list. 291 289 */ 292 void RepairQueue(const vector<SubdivisionCandidate *> &dirtyList, SplitQueue &splitQueue); 290 void RepairQueue(const SubdivisionCandidateContainer &dirtyList, 291 SplitQueue &splitQueue, 292 const bool recomputeSplitPlaneOnRepair); 293 293 294 294 /** Collect subdivision candidates which were affected by the splits from the … … 297 297 void CollectDirtyCandidates(const SubdivisionCandidateContainer &chosenCandidates, 298 298 SubdivisionCandidateContainer &dirtyList); 299 300 /** Collect the list of dirty candidates after the current301 subdivision candidate split.302 */303 void CollectDirtyCandidates(SubdivisionCandidate *sc,304 vector<SubdivisionCandidate *> &dirtyList);305 299 306 300 /** Evaluate subdivision stats for log. … … 497 491 /// number of iteration steps for multilevel approach 498 492 int mNumMultiLevels; 493 /** if split plane should be recomputed for the repair. 494 Otherwise only the priority is recomputed, the 495 split plane itself stays the same 496 */ 497 bool mRecomputeSplitPlaneOnRepair; 499 498 }; 500 499 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1594 r1633 1200 1200 1201 1201 MeshInstance dummyInst(NULL); 1202 //Debug << "objects size: " << size << endl; 1203 1202 1204 1203 // read object ids 1204 // note: could also do this geometrically 1205 1205 for (int i = 0; i < size; ++ i) 1206 1206 { … … 1331 1331 /////////////////////////// 1332 1332 //-- compute bounding box of object space 1333 1333 1334 for (oit = objects.begin(); oit != oit_end; ++ oit) 1334 1335 { … … 1433 1434 1434 1435 1435 } 1436 void KdTree::InsertObjects(KdNode *node, const ObjectContainer &objects) 1437 {/* 1438 stack<KdObjectsTraversalData> tStack; 1439 1440 while (!tStack.empty()) 1441 { 1442 KdObjectsTraversalData tData = tStack.top(); 1443 tStack.pop(); 1444 1445 KdNode *node = tData.node; 1446 1447 if (node->IsLeaf()) 1448 { 1449 KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 1450 1451 ObjectContainer::const_iterator oit, oit_end = tData.objects->end(); 1452 1453 for (oit = tData.objects->begin(); oit != oit_end; ++ oit) 1454 { 1455 leaf->mObjects.push_back(*oit); 1456 } 1457 } 1458 else // interior 1459 { 1460 KdObjectsTraversalData frontData, backData; 1461 KdInterior *interior = dynamic_cast<KdInterior *>(node); 1462 1463 frontData.objects = new ObjectContainer(); 1464 backData.objects = new ObjectContainer(); 1465 1466 ObjectContainer::const_iterator oit, oit_end = tData.objects->end(); 1467 1468 for (oit = tData.objects->begin(); oit != oit_end; ++ oit) 1469 { 1470 Intersectable *object = *oit; 1471 1472 // determine the side of this ray with respect to the plane 1473 const AxisAlignedBox3 box = object->GetBox(); 1474 1475 if (box.Max(interior->mAxis) >= interior->mPosition) 1476 { 1477 frontData.objects->push_back(object); 1478 } 1479 1480 if (box.Min(interior->mAxis) < interior->mPosition) 1481 { 1482 backData.objects->push_back(object); 1483 } 1484 } 1485 1486 tStack.push(backData); 1487 tStack.push(frontData); 1488 } 1489 1490 DEL_PTR(tData.objects); 1491 }*/ 1492 } 1493 1494 } -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r1614 r1633 575 575 KdInterior *ImportBinInterior(IN_STREAM &stream, KdInterior *parent); 576 576 KdNode *LoadNextNode(IN_STREAM &stream, KdInterior *parent, const ObjectContainer &objects); 577 578 /** Adds this objects to the kd leaf objects. 579 @warning: Can corrupt the tree 580 */ 581 void InsertObjects(KdNode *node, const ObjectContainer &objects); 577 582 578 583 int mTermMaxNodes; -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r1615 r1633 1547 1547 1548 1548 void OspTree::CollectDirtyCandidates(OspSubdivisionCandidate *sc, 1549 vector<SubdivisionCandidate *> &dirtyList) 1549 vector<SubdivisionCandidate *> &dirtyList, 1550 const bool onlyUnmailed) 1550 1551 { 1551 1552 OspTraversalData &tData = sc->mParentData; … … 1578 1579 } 1579 1580 1580 1581 // split candidates holding this view cells 1582 // are thrown into dirty list 1581 // andidates holding this view cells are thrown into dirty list 1583 1582 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1584 1583 … … 1588 1587 1589 1588 VspLeaf *leaf = vc->mLeaves[0]; 1590 dirtyList.push_back(leaf->GetSubdivisionCandidate()); 1589 1590 SubdivisionCandidate *dsc = leaf->GetSubdivisionCandidate(); 1591 if (dsc && (!onlyUnmailed || !dsc->Mailed())) 1592 { 1593 dsc->Mail(); 1594 dirtyList.push_back(dsc); 1595 } 1591 1596 } 1592 1597 } … … 1968 1973 ViewCell *vc, 1969 1974 float &contribution, 1970 bool only Mailed) const1975 bool onlyUnmailed) const 1971 1976 { 1972 1977 contribution = 0; // todo … … 1977 1982 vdata = obj->mViewCellPvs.AddSample2(vc, 1); 1978 1983 } 1979 else if (!only Mailed || !vdata->Mailed())1984 else if (!onlyUnmailed || !vdata->Mailed()) 1980 1985 { 1981 1986 obj->mViewCellPvs.AddSample(vc, 1); -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
r1594 r1633 12 12 #include "SubdivisionCandidate.h" 13 13 #include "IntersectableWrapper.h" 14 #include "KdTree.h" 14 15 15 16 … … 39 40 class SubdivisionCandidate; 40 41 class HierarchyManager; 41 42 class KdNode; 42 43 43 44 … … 136 137 137 138 138 139 140 /** View Space Partitioning tree. 139 /** Object Space Partitioning Kd tree. 141 140 */ 142 141 class OspTree … … 251 250 int Type() const { return OBJECT_SPACE; } 252 251 253 void EvalPriority( )252 void EvalPriority(bool computeSplitplane = true) 254 253 { 255 sOspTree->EvalSubdivisionCandidate(*this); 254 if (computeSplitplane) 255 sOspTree->EvalSubdivisionCandidate(*this); 256 // else TODO 256 257 } 257 258 … … 261 262 } 262 263 264 bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) 265 { 266 KdNode *n = sOspTree->Subdivide(splitQueue ,this, terminationCriteriaMet); 267 268 // local or global termination criteria failed 269 return !n->IsLeaf(); 270 } 271 272 void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, 273 const bool onlyUnmailed) 274 { 275 sOspTree->CollectDirtyCandidates(this, dirtyList, onlyUnmailed); 276 } 263 277 264 278 OspSubdivisionCandidate(const AxisAlignedPlane &plane, const OspTraversalData &tData): … … 643 657 644 658 void CollectDirtyCandidates(OspSubdivisionCandidate *sc, 645 vector<SubdivisionCandidate *> &dirtyList); 659 vector<SubdivisionCandidate *> &dirtyList, 660 const bool onlyUnmailed); 646 661 647 662 /** Collect view cells which see this kd leaf. … … 703 718 ViewCell *vc, 704 719 float &contribution, 705 bool only Mailed) const;720 bool onlyUnmailed) const; 706 721 707 722 int ClassifyRays( -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1627 r1633 617 617 { 618 618 mKdTree = new KdTree(); 619 619 620 return mKdTree->LoadBinTree(filename.c_str(), mObjects); 620 621 } … … 820 821 bool Preprocessor::InitRayCast(const string externKdTree, const string internKdTree) 821 822 { 823 // always try to load the kd tree 822 824 bool loadKdTree = true; 823 825 //Environment::GetSingleton()->GetBoolValue("Preprocessor.loadKdTree", loadKdTree); 824 825 826 826 827 if (!loadKdTree) 827 { ///////// 828 //-- build new kd tree from scene geometry 829 828 { 829 // build new kd tree from scene geometry 830 830 BuildKdTree(); 831 KdTreeStatistics(cout);832 831 } 833 832 else 834 833 { 835 long startTime = GetTime();836 834 cout << "loading kd tree file " << internKdTree << " ... "; 837 835 838 836 if (!LoadKdTree(internKdTree)) 839 837 { 840 cout << "error loading kd tree with filename " << internKdTree << ", rebuilding it instead ..." << endl; 841 838 cout << "error loading kd tree with filename " << internKdTree << ", rebuilding it instead ... " << endl; 842 839 BuildKdTree(); 843 KdTreeStatistics(cout); 844 } 845 846 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 847 848 if (0) 849 { 850 Exporter *exporter = Exporter::GetExporter("dummykd.x3d"); 840 } 841 842 // export kd tree? 843 const long startTime = GetTime(); 844 cout << "exporting kd tree ... "; 845 846 if (!ExportKdTree(internKdTree)) 847 { 848 cout << " error exporting kd tree with filename " << internKdTree << endl; 849 } 850 else 851 { 852 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 853 } 854 } 855 856 KdTreeStatistics(cout); 857 cout << mKdTree->GetBox() << endl; 858 859 if (0) 860 { 861 Exporter *exporter = Exporter::GetExporter("dummykd.x3d"); 851 862 852 if (exporter) 853 { 854 exporter->ExportKdTree(*mKdTree, true); 855 delete exporter; 856 } 857 } 858 859 // export kd tree? 860 startTime = GetTime(); 861 cout << "exporting kd tree ... "; 862 863 if (!ExportKdTree(internKdTree)) 864 { 865 cout << " error exporting kd tree with filename " << internKdTree << endl; 866 } 867 else 868 { 869 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 870 } 871 } 863 if (exporter) 864 { 865 exporter->ExportKdTree(*mKdTree, true); 866 delete exporter; 867 } 868 869 /*ofstream objstr("objects.txt"); 870 871 vector<KdLeaf *> leaves; 872 mKdTree->CollectLeaves(leaves); 873 874 vector<KdLeaf *>::const_iterator lit, lit_end = leaves.end(); 875 for (lit = leaves.begin(); lit != lit_end; ++ lit) 876 { 877 objstr << "objects: " << (*lit)->mObjects.size() << " bb " << mKdTree->GetBox(*lit) << endl; 878 }*/ 879 } 880 872 881 873 882 int rayCastMethod; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r1545 r1633 647 647 </File> 648 648 <File 649 RelativePath=".\SubdivisionCandidate.cpp"> 650 </File> 651 <File 649 652 RelativePath=".\SubdivisionCandidate.h"> 650 653 </File> -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1632 r1633 8 8 9 9 namespace GtpVisibilityPreprocessor { 10 11 class SubdivisionCandidate; 12 13 typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer; 14 typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue; 10 15 11 16 /** Candidate for a view space / object space split. … … 20 25 21 26 virtual ~SubdivisionCandidate() {}; 22 virtual void EvalPriority( ) = 0;27 virtual void EvalPriority(bool computeSplitplane = true) = 0; 23 28 virtual int Type() const = 0; 24 //virtual bool Apply() = 0;29 virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0; 25 30 virtual bool GlobalTerminationCriteriaMet() const = 0; 31 32 virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, 33 const bool onlyUnmailed) = 0; 26 34 27 35 /** Set render cost decrease achieved through this split. … … 70 78 } 71 79 80 ////////// 81 //-- mailing stuff 82 83 static void NewMail(const int reserve = 1) 84 { 85 sMailId += sReservedMailboxes; 86 sReservedMailboxes = reserve; 87 } 88 89 void Mail() { mMailbox = sMailId; } 90 bool Mailed() const { return mMailbox == sMailId; } 91 92 void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 93 bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 94 95 int IncMail() { return ++ mMailbox - sMailId; } 96 97 98 // last mail id -> warning not thread safe! 99 // both mailId and mailbox should be unique for each thread!!! 100 static int sMailId; 101 static int sReservedMailboxes; 102 72 103 protected: 73 104 … … 80 111 /// the decrease of the number of pvs entries 81 112 int mPvsEntriesIncr; 113 114 int mMailbox; 82 115 }; 83 116 84 typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue;85 typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer;86 117 87 118 } 88 119 89 // FLEXIBLEHEAP_H120 // SUBDIVISIONCANDIDATE_H 90 121 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1622 r1633 34 34 myless<vector<ViewCell *>::value_type> > TraversalQueue; 35 35 36 int ViewCell::sMailId = 1 ;//2147483647;36 int ViewCell::sMailId = 10000;//2147483647; 37 37 int ViewCell::sReservedMailboxes = 1; 38 38 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1632 r1633 264 264 { 265 265 SimpleRayContainer simpleRays; 266 constlong startTime = GetTime();266 long startTime = GetTime(); 267 267 268 268 mPreprocessor->GenerateRays(samplesPerPass, sampleType, simpleRays); 269 Debug << "generated " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 270 269 cout << "generated " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 270 271 startTime = GetTime(); 271 272 // shoot simple ray and add it to importance samples 272 273 mPreprocessor->CastRays(simpleRays, passSamples, true); 273 Debug<< "cast " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;274 cout << "cast " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 274 275 275 276 return (int)passSamples.size(); … … 323 324 324 325 long startTime = GetTime(); 325 cout << "view cell construction: casting " << mInitialSamples << " initial samples ... " ;326 cout << "view cell construction: casting " << mInitialSamples << " initial samples ... " << endl; 326 327 327 328 // cast initial samples … … 482 483 if (mShowVisualization) 483 484 { 484 VssRayContainer visualizationSamples; 485 486 //////// 485 /////////////// 487 486 //-- visualization rays, e.g., to show some samples in the scene 488 CastPassSamples(mVisualizationSamples, 489 SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, 490 visualizationSamples); 487 488 VssRayContainer visSamples; 489 int numSamples = CastPassSamples(mVisualizationSamples, 490 mSamplingType, 491 visSamples); 491 492 492 493 if (SAMPLE_AFTER_SUBDIVISION) 493 ComputeSampleContributions(vis ualizationSamples, true, storeViewCells);494 ComputeSampleContributions(visSamples, true, storeViewCells); 494 495 495 496 // various visualizations 496 Visualize(preprocessor->mObjects, vis ualizationSamples);497 498 disposeRays(vis ualizationSamples, outRays);497 Visualize(preprocessor->mObjects, visSamples); 498 499 disposeRays(visSamples, outRays); 499 500 } 500 501 … … 5128 5129 GetRaySets(sampleRays, mVisualizationSamples, visRays); 5129 5130 5130 if (1) 5131 { 5132 //////////// 5133 //-- export final view cells 5134 5131 //////////// 5132 //-- export final view cells 5133 5134 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 5135 5136 if (exporter) 5137 { 5135 5138 // hack color code (show pvs size) 5136 5139 const int savedColorCode = mColorCode; 5137 5140 mColorCode = 0; 5138 5139 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 5140 5141 if (exporter) 5142 { 5143 const long starttime = GetTime(); 5144 cout << "exporting final view cells (after initial construction + post process) ... "; 5145 5146 // matt: hack for clamping scene 5147 AxisAlignedBox3 bbox = mViewSpaceBox; 5148 bbox.Scale(Vector3(0.5, 1, 0.5)); 5149 if (CLAMP_TO_BOX) 5150 { 5151 exporter->SetWireframe(); 5152 exporter->ExportBox(bbox); 5153 exporter->SetFilled(); 5154 } 5155 5156 if (0 && mExportGeometry) 5157 { 5158 exporter->ExportGeometry(objects, true, CLAMP_TO_BOX ? &bbox : NULL); 5159 } 5160 5161 if (0 && mExportRays) 5162 { 5163 exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 5164 } 5165 5166 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL, false); 5167 ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, GetClipPlane()); 5168 5169 delete exporter; 5170 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 5171 } 5172 5141 5142 const long starttime = GetTime(); 5143 cout << "exporting final view cells (after initial construction + post process) ... "; 5144 5145 // matt: hack for clamping scene 5146 AxisAlignedBox3 bbox = mViewSpaceBox; 5147 bbox.Scale(Vector3(0.5, 1, 0.5)); 5148 if (CLAMP_TO_BOX) 5149 { 5150 exporter->SetWireframe(); 5151 exporter->ExportBox(bbox); 5152 exporter->SetFilled(); 5153 } 5154 5155 if (0 && mExportGeometry) 5156 { 5157 exporter->ExportGeometry(objects, true, CLAMP_TO_BOX ? &bbox : NULL); 5158 } 5159 5160 if (1 && mExportRays) 5161 { 5162 exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 5163 } 5164 5165 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL, false); 5166 ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, GetClipPlane()); 5167 5168 delete exporter; 5169 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 5173 5170 mColorCode = savedColorCode; 5174 5171 } 5175 5172 5176 if (1) 5177 { 5178 // export final object partition 5179 Exporter *exporter = Exporter::GetExporter("final_object_partition.wrl"); 5180 5181 if (exporter) 5182 { 5183 const long starttime = GetTime(); 5184 5185 // matt: hack for making visualization smaller in size 5186 AxisAlignedBox3 bbox = mHierarchyManager->GetObjectSpaceBox(); 5187 bbox.Scale(Vector3(0.5, 1, 0.5)); 5188 5189 cout << "exporting object space hierarchy ... "; 5190 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL); 5191 5192 delete exporter; 5193 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 5194 } 5195 } 5196 5173 // export final object partition 5174 exporter = Exporter::GetExporter("final_object_partition.wrl"); 5175 5176 if (exporter) 5177 { 5178 const long starttime = GetTime(); 5179 5180 // matt: hack for making visualization smaller in size 5181 AxisAlignedBox3 bbox = mHierarchyManager->GetObjectSpaceBox(); 5182 bbox.Scale(Vector3(0.5, 1, 0.5)); 5183 5184 cout << "exporting object space hierarchy ... "; 5185 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL); 5186 5187 delete exporter; 5188 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 5189 } 5190 5191 5192 // visualization of the view cells 5193 if (0) ExportMergedViewCells(objects); 5194 5197 5195 // export some view cell 5198 5196 int leafOut; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1623 r1633 161 161 { 162 162 // for a spatial subdivision, it is not necessary to store 163 // the objects with the leaves, they can be classified now 163 // the objects with the leaves, they can be classified 164 // geometrically 164 165 mHierarchyManager->mOspTree->InsertObjects( 165 166 mHierarchyManager->mOspTree->mRoot, *mObjects); -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1610 r1633 694 694 if (!LocalTerminationCriteriaMet(tData) && !globalCriteriaMet) 695 695 { 696 /////////// 696 697 //-- continue subdivision 698 697 699 VspTraversalData tFrontData; 698 700 VspTraversalData tBackData; … … 714 716 if (1) EvalSubdivisionStats(*sc); 715 717 718 ///////////// 716 719 //-- evaluate new split candidates for global greedy cost heuristics 717 720 … … 728 731 tQueue.Push(frontCandidate); 729 732 tQueue.Push(backCandidate); 730 731 // delete old leaf node732 // DEL_PTR(tData.mNode);733 734 // note: leaf is not destroyed because it is needed to collect 735 // dirty candidates in hierarchy manager 733 736 } 734 737 … … 825 828 826 829 splitCandidate.SetPriority(priority); 830 } 831 832 833 float VspTree::EvalPriority(const VspSubdivisionCandidate &splitCandidate) const 834 { 835 // compute global decrease in render cost 836 float oldRenderCost; 837 const float renderCostDecr = EvalRenderCostDecrease(splitCandidate.mSplitPlane, 838 splitCandidate.mParentData, 839 oldRenderCost); 840 841 #if 0 842 const float priority = (float)-splitCandidate.mParentData.mDepth; 843 #else 844 // take render cost of node into account 845 // otherwise danger of being stuck in a local minimum!! 846 const float factor = mRenderCostDecreaseWeight; 847 const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 848 #endif 849 850 return priority; 827 851 } 828 852 … … 2872 2896 void VspTree::CollectDirtyCandidate(const VssRay &ray, 2873 2897 const bool isTermination, 2874 vector<SubdivisionCandidate *> &dirtyList) const 2898 vector<SubdivisionCandidate *> &dirtyList, 2899 const bool onlyUnmailed) const 2875 2900 { 2876 2901 … … 2882 2907 2883 2908 if (!obj) return; 2884 2909 2910 SubdivisionCandidate *candidate = NULL; 2911 2885 2912 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 2886 2913 { … … 2892 2919 { 2893 2920 leaf->Mail(); 2894 dirtyList.push_back(leaf->mSubdivisionCandidate);2921 candidate = leaf->mSubdivisionCandidate; 2895 2922 } 2896 2923 break; … … 2903 2930 { 2904 2931 leaf->Mail(); 2905 // a candidate still attached to this node 2906 if (leaf->GetSubdivisionCandidate()) 2907 { 2908 dirtyList.push_back(leaf->GetSubdivisionCandidate()); 2909 } 2932 candidate = leaf->GetSubdivisionCandidate(); 2910 2933 } 2911 2934 break; 2912 2935 } 2913 2936 default: 2937 cerr << "not implemented yet" << endl; 2938 candidate = NULL; 2914 2939 break; 2915 2940 } 2941 2942 // is this leaf still a split candidate? 2943 if (candidate && (!onlyUnmailed || !candidate->Mailed())) 2944 { 2945 candidate->Mail(); 2946 dirtyList.push_back(candidate); 2947 } 2916 2948 } 2917 2949 2918 2950 2919 2951 void VspTree::CollectDirtyCandidates(VspSubdivisionCandidate *sc, 2920 vector<SubdivisionCandidate *> &dirtyList) 2952 vector<SubdivisionCandidate *> &dirtyList, 2953 const bool onlyUnmailed) 2921 2954 { 2922 2955 VspTraversalData &tData = sc->mParentData; … … 2933 2966 VssRay *ray = (*rit).mRay; 2934 2967 2935 CollectDirtyCandidate(*ray, true, dirtyList );2936 CollectDirtyCandidate(*ray, false, dirtyList);2968 CollectDirtyCandidate(*ray, true, dirtyList, onlyUnmailed); 2969 CollectDirtyCandidate(*ray, false, dirtyList, onlyUnmailed); 2937 2970 } 2938 2971 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1576 r1633 457 457 int Type() const { return VIEW_SPACE; } 458 458 459 void EvalPriority( )459 void EvalPriority(bool computeSplitplane = true) 460 460 { 461 sVspTree->EvalSubdivisionCandidate(*this); 461 if (computeSplitplane) 462 sVspTree->EvalSubdivisionCandidate(*this); 463 else 464 mPriority = sVspTree->EvalPriority(*this); 462 465 } 463 466 … … 467 470 } 468 471 469 VspSubdivisionCandidate( 470 const AxisAlignedPlane &plane, 471 const VspTraversalData &tData): 472 bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) 473 { 474 VspNode *n = sVspTree->Subdivide(splitQueue, this, terminationCriteriaMet); 475 476 // local or global termination criteria failed 477 return !n->IsLeaf(); 478 } 479 480 void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, 481 const bool onlyUnmailed) 482 { 483 sVspTree->CollectDirtyCandidates(this, dirtyList, onlyUnmailed); 484 } 485 486 VspSubdivisionCandidate(const AxisAlignedPlane &plane, const VspTraversalData &tData): 472 487 mSplitPlane(plane), mParentData(tData) 473 488 {} … … 833 848 int PrepareHeuristics(KdLeaf *leaf); 834 849 850 /** Reevaluates the priority of this split candidate 851 @returns priority 852 */ 853 float EvalPriority(const VspSubdivisionCandidate &splitCandidate) const; 854 835 855 ///////////////////////////////////////////////////////////////////////////// 836 856 … … 939 959 */ 940 960 void ProcessViewCellObjects(ViewCell *parent, 941 ViewCell *front,942 ViewCell *back) const;961 ViewCell *front, 962 ViewCell *back) const; 943 963 944 964 void CreateViewCell(VspTraversalData &tData, const bool updatePvs); … … 947 967 and must be reevaluated. 948 968 */ 949 void CollectDirtyCandidates(VspSubdivisionCandidate *sc, vector<SubdivisionCandidate *> &dirtyList); 950 951 void CollectDirtyCandidate( 952 const VssRay &ray, 953 const bool isTermination, 954 vector<SubdivisionCandidate *> &dirtyList) const; 969 void CollectDirtyCandidates(VspSubdivisionCandidate *sc, 970 vector<SubdivisionCandidate *> &dirtyList, 971 const bool onlyUnmailed); 972 973 void CollectDirtyCandidate(const VssRay &ray, 974 const bool isTermination, 975 vector<SubdivisionCandidate *> &dirtyList, 976 const bool onlyUnmailed) const; 955 977 956 978 /** Rays will be clipped to the bounding box. -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1627 r1633 76 76 { 77 77 //Environment::GetSingleton()->GetStringValue("Preprocessor.kdTreeFilename", internKdTree); 78 78 string suffix; 79 80 if (preprocessor->mLoadMeshes) 81 { 82 suffix = ".kdm"; 83 } 84 else 85 { 86 suffix = ".kdt"; 87 } 88 79 89 // hack! should take any extension 80 90 if (strstr(filename.c_str(), ".x3d")) 81 91 { 82 return ReplaceSuffix(filename, ".x3d", ".kd");92 return ReplaceSuffix(filename, ".x3d", suffix); 83 93 } 84 94 else if (strstr(filename.c_str(), ".dat")) 85 95 { 86 return ReplaceSuffix(filename, ".dat", ".kd");96 return ReplaceSuffix(filename, ".dat", suffix); 87 97 } 88 98 else if (strstr(filename.c_str(), ".obj")) 89 99 { 90 return ReplaceSuffix(filename, ".dat", ".kd");100 return ReplaceSuffix(filename, ".dat", suffix); 91 101 } 92 102
Note: See TracChangeset
for help on using the changeset viewer.