Changeset 610
- Timestamp:
- 02/09/06 12:14:11 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
r581 r610 59 59 void NormalizeMaximum(); 60 60 61 /** Merges pvs of a and pvs of binto this pvs.61 /** Merges pvs of a into this pvs. 62 62 */ 63 void Merge(const Pvs<T> &a , const Pvs<T> &b);63 void Merge(const Pvs<T> &a); 64 64 65 65 /** Difference of pvs to pvs b. … … 130 130 131 131 template <typename T> 132 void Pvs<T>::Merge(const Pvs<T> &a , const Pvs<T> &b)132 void Pvs<T>::Merge(const Pvs<T> &a) 133 133 { 134 134 std::map<T, PvsData<T>, LtSample<T> >::const_iterator it; 135 135 136 mEntries = a.mEntries; 137 138 for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) 136 for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it) 139 137 { 140 138 PvsData<T> *data = Find((*it).first); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r608 r610 1286 1286 1287 1287 // compress root node 1288 P ropagateUpVisibility(interior);1288 PullUpVisibility(interior); 1289 1289 } 1290 1290 } … … 1328 1328 1329 1329 1330 void ViewCellsTree::P ropagateUpVisibility(ViewCellInterior *interior)1330 void ViewCellsTree::PullUpVisibility(ViewCellInterior *interior) 1331 1331 { 1332 1332 Intersectable::NewMail((int)interior->mChildren.size()); … … 1536 1536 } 1537 1537 1538 1539 void ViewCellsTree::PropagateUpPvs(ViewCell *vc) 1540 { 1541 while (vc->GetParent()) 1542 { 1543 vc->GetParent()->GetPvs().Merge(vc->GetPvs()); 1544 vc = vc->GetParent(); 1545 } 1546 } 1538 1547 1539 1548 … … 1624 1633 1625 1634 1635 bool ViewCellsTree::Export(ofstream &stream) 1636 { 1637 ExportViewCell(mRoot, stream); 1638 1639 return true; 1640 } 1641 1642 1643 void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ofstream &stream) 1644 { 1645 ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 1646 1647 if (0) // test with empty pvs 1648 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 1649 { 1650 stream << (*it).first->GetId() << " "; 1651 } 1652 1653 stream << "\" />" << endl; 1654 1655 if (viewCell->IsLeaf()) 1656 { 1657 stream << "<Leaf "; 1658 stream << "id=\"" << viewCell->GetId() << "\" "; 1659 stream << "active=\"" << viewCell->mIsActive << "\" "; 1660 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 1661 stream << "pvs=\""; 1662 stream << "</Leaf>" << endl; 1663 } 1664 else 1665 { 1666 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(viewCell); 1667 1668 stream << "<Interior "; 1669 stream << "id=\"" << viewCell->GetId() << "\" "; 1670 stream << "active=\"" << viewCell->mIsActive << "\" "; 1671 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 1672 stream << "pvs=\""; 1673 1674 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1675 1676 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1677 { 1678 ExportViewCell(*it, stream); 1679 } 1680 1681 stream << "</Interior>" << endl; 1682 } 1683 } 1684 1685 1626 1686 1627 1687 /**************************************************************************/ … … 1704 1764 1705 1765 1766 1767 1768 1706 1769 /************************************************************************/ 1707 1770 /* MergeStatistics implementation */ -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r609 r610 351 351 ViewCell *GetActiveViewCell(ViewCell *vc) const; 352 352 353 /** Propagates pvs up the tree to the root. 354 */ 355 void PropagateUpPvs(ViewCell *vc); 356 357 bool Export(ofstream &stream); 358 359 353 360 protected: 354 361 … … 421 428 int UpdateActiveViewCells(ViewCellContainer &viewCells); 422 429 423 void P ropagateUpVisibility(ViewCellInterior *interior);430 void PullUpVisibility(ViewCellInterior *interior); 424 431 425 432 void CompressViewCellsPvs(ViewCell *root); … … 428 435 */ 429 436 float GetMemUsage() const; 437 438 /** 439 Exports single view cell. 440 NOTE: should be in exporter!! 441 */ 442 void ExportViewCell(ViewCell *viewCell, ofstream &stream); 443 430 444 431 445 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r605 r610 50 50 51 51 BspNode::BspNode(): 52 mParent(NULL), mTreeValid(true) 52 mParent(NULL), mTreeValid(true), mTimeStamp(0) 53 53 {} 54 54 … … 216 216 mRoot(NULL), 217 217 mUseAreaForPvs(false), 218 mGenerateViewCells(true) 218 mGenerateViewCells(true), 219 mTimeStamp(0) 219 220 { 220 221 Randomize(); // initialise random generator for heuristics … … 1098 1099 backData.mNode = interior->GetBack(); 1099 1100 1101 frontData.mNode->mTimeStamp = mTimeStamp; 1102 backData.mNode->mTimeStamp = mTimeStamp ++; 1103 1100 1104 //DEL_PTR(leaf); 1101 1105 return interior; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r590 r610 261 261 int mMailbox; 262 262 263 int mTimeStamp; 264 263 265 protected: 264 266 … … 955 957 ViewCellsManager *mViewCellsManager; 956 958 959 int mTimeStamp; 957 960 958 961 private: -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r609 r610 334 334 float ViewCellsManager::GetViewSpaceVolume() 335 335 { 336 return mViewSpaceBox.GetVolume() *(2.0f*sqr((float)M_PI));336 return mViewSpaceBox.GetVolume() * (2.0f * sqr((float)M_PI)); 337 337 } 338 338 … … 544 544 ViewCellInterior *vc = new ViewCellInterior();//GenerateViewCell(); 545 545 546 vc->GetPvs() = left->GetPvs(); 546 547 // merge pvs 547 vc->GetPvs().Merge( left->GetPvs(),right->GetPvs());548 vc->GetPvs().Merge(right->GetPvs()); 548 549 549 550 //-- merge ray sets … … 576 577 { 577 578 // merge pvs 578 vc->GetPvs().Merge( vc->GetPvs(),(*it)->GetPvs());579 vc->GetPvs().Merge((*it)->GetPvs()); 579 580 580 581 vc->SetupChildLink(*it); … … 940 941 941 942 942 void ViewCellsManager::ExportViewCell(ViewCell *viewCell, ofstream &stream) 943 { 944 stream << "<ViewCell id=\"" << viewCell->GetId() << "\" "; 945 stream << "pvs=\""; 946 947 ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 948 if(0) // test with empty pvs 949 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 950 { 951 stream << (*it).first->GetId() << " "; 952 } 953 954 stream << "\" />" << endl; 955 } 943 void ViewCellsManager::CollectViewCells(const int n) 944 { 945 mNumActiveViewCells = n; 946 mViewCells.clear(); 947 CollectViewCells(); 948 } 949 956 950 957 951 … … 1625 1619 //-- load the view cells itself, i.e., the ids and the pvs 1626 1620 stream << "<ViewCells>" << endl; 1621 1622 #if 0 1623 1627 1624 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1625 1628 1626 for (it = mViewCells.begin(); it != it_end; ++ it) 1629 1627 ExportViewCell(*it, stream); 1628 #else 1629 mViewCellsTree->Export(stream); 1630 #endif 1630 1631 1631 1632 stream << "</ViewCells>" << endl; … … 1660 1661 BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*lit); 1661 1662 bspVc->mLeaf->SetViewCell(vc); 1663 } 1664 } 1665 } 1666 1667 1668 void BspViewCellsManager::CreateMergeHierarchy() 1669 { 1670 TraversalQueue tQueue; 1671 1672 tQueue.push(TraversalData(mBspTree->GetRoot(), NULL)); 1673 1674 while (!tQueue.empty()) 1675 { 1676 TraversalData tData = tQueue.top(); 1677 tQueue.pop(); 1678 1679 if (tData.mNode->IsLeaf()) 1680 { 1681 ViewCell *viewCell = dynamic_cast<BspLeaf *>(tData.mNode)->GetViewCell(); 1682 viewCell->SetMergeCost((float)tData.mNode->mTimeStamp); 1683 1684 if (tData.mParentViewCell) 1685 { 1686 tData.mParentViewCell->SetupChildLink(viewCell); 1687 // probagate up pvs 1688 mViewCellsTree->PropagateUpPvs(viewCell); 1689 } 1690 } 1691 else 1692 { 1693 BspInterior *interior = dynamic_cast<BspInterior *>(tData.mNode); 1694 ViewCellInterior *viewCellInterior = new ViewCellInterior(); 1695 viewCellInterior->SetMergeCost((float)tData.mNode->mTimeStamp); 1696 1697 1698 tQueue.push(TraversalData(interior->GetBack(), viewCellInterior)); 1699 tQueue.push(TraversalData(interior->GetFront(), viewCellInterior)); 1700 1701 if (tData.mParentViewCell) 1702 tData.mParentViewCell->SetupChildLink(viewCellInterior); 1662 1703 } 1663 1704 } … … 2791 2832 void VspBspViewCellsManager::CreateMergeHierarchy() 2792 2833 { 2793 2834 TraversalQueue tQueue; 2835 2836 tQueue.push(TraversalData(mVspBspTree->GetRoot(), NULL)); 2837 2838 while (!tQueue.empty()) 2839 { 2840 TraversalData tData = tQueue.top(); 2841 tQueue.pop(); 2842 2843 if (tData.mNode->IsLeaf()) 2844 { 2845 ViewCell *viewCell = dynamic_cast<BspLeaf *>(tData.mNode)->GetViewCell(); 2846 2847 if (tData.mParentViewCell) 2848 { 2849 tData.mParentViewCell->SetupChildLink(viewCell); 2850 // probagate up pvs 2851 mViewCellsTree->PropagateUpPvs(viewCell); 2852 } 2853 } 2854 else 2855 { 2856 BspInterior *interior = dynamic_cast<BspInterior *>(tData.mNode); 2857 ViewCellInterior *viewCellInterior = new ViewCellInterior(); 2858 2859 tQueue.push(TraversalData(interior->GetBack(), viewCellInterior)); 2860 tQueue.push(TraversalData(interior->GetFront(), viewCellInterior)); 2861 2862 if (tData.mParentViewCell) 2863 tData.mParentViewCell->SetupChildLink(viewCellInterior); 2864 } 2865 } 2794 2866 } 2795 2867 … … 3342 3414 //-- load the view cells itself, i.e., the ids and the pvs 3343 3415 stream << "<ViewCells>" << endl; 3416 3417 #if 0 3418 3344 3419 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 3420 3345 3421 for (it = mViewCells.begin(); it != it_end; ++ it) 3346 3422 ExportViewCell(*it, stream); 3423 #else 3424 mViewCellsTree->Export(stream); 3425 #endif 3347 3426 3348 3427 stream << "</ViewCells>" << endl; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r609 r610 6 6 #include "Containers.h" 7 7 #include "ViewCell.h" 8 #include "ViewCellBsp.h" 8 9 9 10 class ViewCell; … … 349 350 vector<MergeCandidate> &candidates) = 0; 350 351 351 352 353 void CollectViewCells(const int n) { 354 mNumActiveViewCells = n; 355 mViewCells.clear(); 356 CollectViewCells(); 357 } 358 359 360 virtual bool EqualToSpatialNode(ViewCell *viewCell) const { return false;} 352 void CollectViewCells(const int n); 353 354 355 virtual void CreateMergeHierarchy() {}; 356 357 virtual bool EqualToSpatialNode(ViewCell *viewCell) const { return false;} 358 359 361 360 protected: 362 361 … … 411 410 void CreateViewCellMeshes(); 412 411 413 /** 414 Exports single view cell. 415 NOTE: should be in exporter!! 416 */ 417 void ExportViewCell(ViewCell *viewCell, ofstream &stream); 418 419 420 /** 421 Takes different measures to prepares the view cells after loading them from disc. 412 413 /** Takes different measures to prepares the view cells after loading them from disc. 422 414 */ 423 415 virtual void PrepareLoadedViewCells() {}; … … 537 529 bool ExportViewCells(const string filename); 538 530 531 void CreateMergeHierarchy(); 532 533 539 534 protected: 535 536 struct TraversalData 537 { 538 ViewCellInterior *mParentViewCell; 539 BspNode *mNode; 540 541 542 TraversalData() {} 543 TraversalData(BspNode *node, ViewCellInterior *vc): 544 mNode(node), mParentViewCell(vc) 545 {} 546 547 bool operator<(const TraversalData &b) const 548 { 549 return mNode->mTimeStamp < b.mNode->mTimeStamp; 550 } 551 }; 552 553 typedef priority_queue<TraversalData> TraversalQueue; 540 554 541 555 /** HACK … … 754 768 protected: 755 769 770 struct TraversalData 771 { 772 ViewCellInterior *mParentViewCell; 773 BspNode *mNode; 774 775 776 TraversalData() {} 777 TraversalData(BspNode *node, ViewCellInterior *vc): 778 mNode(node), mParentViewCell(vc) 779 {} 780 781 bool operator<(const TraversalData &b) const 782 { 783 return mNode->mTimeStamp < b.mNode->mTimeStamp; 784 } 785 }; 786 787 typedef priority_queue<TraversalData> TraversalQueue; 788 789 /** Returns node of the spatial hierarchy corresponding to the view cell 790 if such a node exists. 791 */ 756 792 BspNode *GetSpatialNode(ViewCell *viewCell) const; 793 757 794 /** HACK 758 795 */ … … 778 815 void PrepareLoadedViewCells(); 779 816 780 817 void CreateMergeHierarchy(); 781 818 /// the view space partition BSP tree. 782 819 VspBspTree *mVspBspTree; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r609 r610 68 68 mStoreRays(false), 69 69 mRenderCostWeight(0.5), 70 mUseRandomAxis(false) 70 mUseRandomAxis(false), 71 mTimeStamp(0) 71 72 { 72 73 bool randomize = false; … … 87 88 //-- max cost ratio for early tree termination 88 89 environment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 89 mTermMinPolygons = 25; 90 91 // HACK 92 mTermMinPolygons = 25; 93 90 94 //-- factors for bsp tree split plane heuristics 91 95 environment->GetFloatValue("VspBspTree.Factor.balancedRays", mBalancedRaysFactor); … … 729 733 frontData.mNode = interior->GetFront(); 730 734 backData.mNode = interior->GetBack(); 735 736 frontData.mNode->mTimeStamp = mTimeStamp; 737 backData.mNode->mTimeStamp = mTimeStamp ++; 731 738 732 739 //DEL_PTR(leaf); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r607 r610 716 716 bool mUsePolygonSplitIfAvailable; 717 717 718 int mTimeStamp; 719 718 720 private: 719 721
Note: See TracChangeset
for help on using the changeset viewer.