Changeset 452 for trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
- Timestamp:
- 12/05/05 20:33:53 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r449 r452 180 180 /**************************************************************/ 181 181 VspKdTreeLeaf::VspKdTreeLeaf(VspKdTreeInterior *p, const int nRays): 182 VspKdTreeNode(p), mRays(), mPvsSize(0), mValidPvs(false) 182 VspKdTreeNode(p), mRays(), mPvsSize(0), mValidPvs(false), mViewCell(NULL) 183 183 { 184 184 mRays.reserve(nRays); … … 447 447 VspKdTree::Construct(const VssRayContainer &rays, 448 448 AxisAlignedBox3 *forcedBoundingBox) 449 { Debug << "here888" << endl;449 { 450 450 mStat.Start(); 451 Debug << "here1000" << endl;451 452 452 mMaxMemory = mMaxStaticMemory; 453 Debug << "here1" << endl;454 453 DEL_PTR(mRoot); 455 454 … … 461 460 mStat.nodes = 1; 462 461 mBox.Initialize(); 463 Debug << "here2" << endl; 462 464 463 //-- compute bounding box 465 464 if (forcedBoundingBox) … … 468 467 for (VssRayContainer::const_iterator ri = rays.begin(); ri != rays.end(); ++ ri) 469 468 { 470 mBox.Include((*ri)->GetOrigin()); 471 mBox.Include((*ri)->GetTermination()); 469 if ((*ri)->mOriginObject) 470 mBox.Include((*ri)->GetOrigin()); 471 if ((*ri)->mTerminationObject) 472 mBox.Include((*ri)->GetTermination()); 472 473 } 473 474 … … 676 677 } 677 678 678 float ratio = 0;679 680 679 if (0) 681 680 { … … 702 701 const float oldCost = (float)pvsSize; 703 702 704 float ratio = newCost / oldCost; 705 } 706 707 return ratio; 703 return newCost / oldCost; 704 } 708 705 } 709 706 … … 731 728 if (!mOnlyDrivingAxis || axis == sAxis) 732 729 { 730 733 731 nPosition[axis] = (sBox.Min()[axis] + sBox.Max()[axis]) * 0.5f; 734 732 … … 740 738 nPvsBack[axis], 741 739 nPvsFront[axis]); 740 if (bestAxis == -1) 741 { 742 bestAxis = axis; 743 } 744 else if (nCostRatio[axis] < nCostRatio[bestAxis]) 745 { 746 /*Debug << "pvs front " << nPvsBack[axis] 747 << " pvs back " << nPvsFront[axis] 748 << " overall pvs " << leaf->GetPvsSize() << endl;*/ 749 bestAxis = axis; 750 } 742 751 743 if (bestAxis == -1)744 bestAxis = axis;745 else746 if (nCostRatio[axis] < nCostRatio[bestAxis])747 {748 Debug << "pvs front " << nPvsBack[axis]749 << " pvs back " << nPvsFront[axis]750 << " overall pvs " << leaf->GetPvsSize() << endl;751 bestAxis = axis;752 }753 752 } 754 753 } … … 1786 1785 } 1787 1786 } 1787 1788 int VspKdTree::FindNeighbors(VspKdTreeLeaf *n, 1789 vector<VspKdTreeLeaf *> &neighbors, 1790 bool onlyUnmailed) 1791 { 1792 stack<VspKdTreeNode *> nodeStack; 1793 1794 nodeStack.push(mRoot); 1795 1796 AxisAlignedBox3 box = GetBBox(n); 1797 1798 while (!nodeStack.empty()) 1799 { 1800 VspKdTreeNode *node = nodeStack.top(); 1801 nodeStack.pop(); 1802 1803 if (node->IsLeaf()) 1804 { 1805 VspKdTreeLeaf *leaf = dynamic_cast<VspKdTreeLeaf *>(node); 1806 1807 if (leaf != n && (!onlyUnmailed || !leaf->Mailed())) 1808 neighbors.push_back(leaf); 1809 } 1810 else 1811 { 1812 VspKdTreeInterior *interior = dynamic_cast<VspKdTreeInterior *>(node); 1813 1814 if (interior->mPosition > box.Max(interior->mAxis)) 1815 nodeStack.push(interior->mBack); 1816 else 1817 { 1818 if (interior->mPosition < box.Min(interior->mAxis)) 1819 nodeStack.push(interior->mFront); 1820 else 1821 { 1822 // random decision 1823 nodeStack.push(interior->mBack); 1824 nodeStack.push(interior->mFront); 1825 } 1826 } 1827 } 1828 } 1829 1830 return (int)neighbors.size(); 1831 } 1832 1833 void VspKdTree::MergeLeaves() 1834 { 1835 vector<VspKdTreeLeaf *> leaves; 1836 priority_queue<LeafPair> mergeCandidates; 1837 vector<VspKdTreeLeaf *> neighbors; 1838 1839 CollectLeaves(leaves); 1840 1841 VspKdTreeLeaf::NewMail(); 1842 1843 vector<VspKdTreeLeaf *>::const_iterator it, it_end = leaves.end(); 1844 1845 1846 for (it = leaves.begin(); it != it_end; ++ it) 1847 { 1848 VspKdTreeLeaf *leaf = *it; 1849 1850 if (!leaf->Mailed()) 1851 { 1852 FindNeighbors(leaf, neighbors, true); 1853 1854 vector<VspKdTreeLeaf *>::const_iterator nit, nit_end = neighbors.end(); 1855 1856 for (nit = neighbors.begin(); nit != neighbors.end(); ++ nit) 1857 mergeCandidates.push(LeafPair(leaf, *nit)); 1858 1859 leaf->Mail(); 1860 } 1861 } 1862 } 1863 1864 1865 1866 /*********************************************************************/ 1867 /* MergeCandidate implementation */ 1868 /*********************************************************************/ 1869 1870 1871 MergeCandidate::MergeCandidate(VspKdTreeLeaf *l1, VspKdTreeLeaf *l2): 1872 mLeaf1(l1), mLeaf2(l2) 1873 {} 1874 1875 int MergeCandidate::ComputePvsDifference() const 1876 { 1877 return 0; 1878 } 1879 1880 float MergeCandidate::EvaluateMergeCost() const 1881 { 1882 return 0; 1883 }
Note: See TracChangeset
for help on using the changeset viewer.