Changeset 557 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
- Timestamp:
- 01/19/06 23:36:01 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r556 r557 38 38 bool BspMergeCandidate::sUseArea = false; 39 39 40 40 41 /********************************************************************/ 41 42 /* class VspBspTree implementation */ 42 43 /********************************************************************/ 44 43 45 44 46 VspBspTree::VspBspTree(): … … 498 500 499 501 mStat.contributingSamples += conSamp; 500 mStat.sampleContributions += sampCon;502 mStat.sampleContributions +=(int) sampCon; 501 503 502 504 //-- store additional info … … 1915 1917 typedef pair<BspNode *, BspNodeGeometry *> bspNodePair; 1916 1918 1919 1917 1920 int VspBspTree::FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors, 1918 1921 const bool onlyUnmailed) const … … 1925 1928 // split planes from the root to this node 1926 1929 // needed to verify that we found neighbor leaf 1930 // TODO: really needed? 1927 1931 vector<Plane3> halfSpaces; 1928 1932 ExtractHalfSpaces(n, halfSpaces); … … 1934 1938 nodeStack.push(bspNodePair(mRoot, rgeom)); 1935 1939 1940 Debug << "here77" << endl; 1936 1941 1937 1942 while (!nodeStack.empty()) … … 1942 1947 nodeStack.pop(); 1943 1948 1944 bool isAdjacent = true; 1945 1946 1949 if (node->IsLeaf()) 1950 { 1951 Debug << "here22" << endl; 1952 // test if this leaf is in valid view space 1953 if (node->TreeValid() && 1954 (node != n) && 1955 (!onlyUnmailed || !node->Mailed())) 1956 { 1957 Debug << "here" << endl; 1958 bool isAdjacent = true; 1947 1959 #if 1 1948 // test all planes of current node if still adjacent 1949 for (int i = 0; (i < halfSpaces.size()) && isAdjacent && (node != n); ++ i) 1950 { 1951 const int cf = 1952 Polygon3::ClassifyPlane(geom->mPolys, 1953 halfSpaces[i], 1954 mEpsilon); 1955 1956 if (cf == Polygon3::BACK_SIDE) 1957 { 1958 isAdjacent = false; 1959 } 1960 } 1961 #else 1962 // test all planes of current node if still adjacent 1963 for (int i = 0; i < nodeGeom.size()) && isAdjacent && (node != n); ++ i) 1964 { 1965 Polygon3 *poly = nodeGeom->mPolys[i]; 1966 1967 const int cf = 1968 Polygon3::ClassifyPlane(geom->mPolys, 1969 poly->GetSupportingPlane(), 1970 mEpsilon); 1971 1972 if (cf == Polygon3::BACK_SIDE) 1973 { 1974 isAdjacent = false; 1975 } 1976 } 1960 1961 // test all planes of current node if still adjacent 1962 for (int i = 0; (i < halfSpaces.size()) && isAdjacent; ++ i) 1963 { 1964 const int cf = 1965 Polygon3::ClassifyPlane(geom->mPolys, 1966 halfSpaces[i], 1967 mEpsilon); 1968 1969 if (cf == Polygon3::BACK_SIDE) 1970 { 1971 isAdjacent = false; 1972 } 1973 } 1974 #else // TODO: why is this wrong?? 1975 // test all planes of current node if still adjacent 1976 for (int i = 0; (i < (int)nodeGeom.mPolys.size()) && isAdjacent; ++ i) 1977 { 1978 Debug << "here33" << endl; 1979 Polygon3 *poly = nodeGeom.mPolys[i]; 1980 1981 const int cf = 1982 Polygon3::ClassifyPlane(geom->mPolys, 1983 poly->GetSupportingPlane(), 1984 mEpsilon); 1985 1986 if (cf == Polygon3::BACK_SIDE) 1987 { 1988 isAdjacent = false; 1989 } 1990 } 1977 1991 #endif 1978 if (isAdjacent) 1979 { 1980 1981 if (node->IsLeaf()) 1982 { 1983 // test if this leaf is in valid view space 1984 if (node->TreeValid() && 1985 node != n && 1986 (!onlyUnmailed || !node->Mailed())) 1987 { 1988 // neighbor was found 1992 Debug << "here2" << endl; 1993 // neighbor was found 1994 if (isAdjacent) 1989 1995 neighbors.push_back(dynamic_cast<BspLeaf *>(node)); 1990 }1991 1996 } 1992 1997 else … … 2505 2510 2506 2511 2507 bool VspBspTree::MergeViewCells(BspLeaf *l1, BspLeaf *l2) const2512 bool VspBspTree::MergeViewCells(BspLeaf *l1, BspLeaf *l2) //const 2508 2513 { 2509 2514 //-- change pointer to view cells of all leaves associated … … 2545 2550 2546 2551 // clean up old view cells 2547 DEL_PTR(fVc); 2548 DEL_PTR(bVc); 2552 if (0) 2553 { 2554 DEL_PTR(fVc); 2555 DEL_PTR(bVc); 2556 } 2557 else // throw them into old view cells container 2558 { 2559 fVc->mMailbox = -1; 2560 bVc->mMailbox = -1; 2561 2562 mOldViewCells.push_back(fVc); 2563 mOldViewCells.push_back(bVc); 2564 2565 mNewViewCells.push_back(vc); 2566 } 2549 2567 2550 2568 return true; … … 2764 2782 BspMergeCandidate::sUseArea = mUseAreaForPvs; 2765 2783 2784 // the current view cells are kept in this container 2785 ViewCellContainer viewCells; 2786 ViewCell::NewMail(); 2787 CollectViewCells(mRoot, true, viewCells, true); 2788 ViewCell::NewMail(); 2789 2766 2790 MergeStatistics mergeStats; 2767 2791 mergeStats.Start(); 2768 2792 // TODO: REMOVE LATER for performance! 2769 const bool showMergeStats = false;2793 const bool showMergeStats = true; 2770 2794 //BspMergeCandidate::sOverallCost = mBox.SurfaceArea() * mStat.maxPvs; 2771 2795 long startTime = GetTime(); … … 2846 2870 2847 2871 cout << "exporting view cells ... "; 2848 ViewCellContainer viewCells; 2849 CollectViewCells(mRoot, false, viewCells); 2850 2851 2872 2873 2874 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 2875 2876 Debug << "here2111 " << viewCells.size() << endl; 2877 for (int i = 0; i < viewCells.size(); ++ i) 2878 { 2879 while (!viewCells.empty() && (viewCells.back()->mMailbox == -1)) 2880 { 2881 Debug << "here244" << endl; 2882 viewCells.pop_back(); 2883 } 2884 2885 // already merged view cell, put it to end of vector 2886 if ((i < viewCells.size()) && (viewCells[i]->mMailbox == -1)) 2887 { 2888 Debug << "here2" << endl; 2889 swap(viewCells[i], viewCells.back()); 2890 } 2891 } 2892 2893 cout << "finished" << endl; 2894 // not part of any leaf 2895 CLEAR_CONTAINER(mOldViewCells); 2896 2897 int newVcSize = (int)mNewViewCells.size(); 2898 // add new view cells to container 2899 while (!mNewViewCells.empty()) 2900 { 2901 viewCells.push_back(mNewViewCells.back()); 2902 mNewViewCells.pop_back(); 2903 } 2904 2852 2905 char s[64]; 2853 2906 sprintf(s, "merged_viewcells%07d.x3d", nViewCells); … … 2860 2913 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 2861 2914 2915 int i = (int)viewCells.size(); 2862 2916 for (it = viewCells.begin(); it != it_end; ++ it) 2863 2917 { 2918 Material m = RandomMaterial(); 2919 if (i-- == newVcSize) 2920 { 2921 m.mDiffuseColor.r = 1; 2922 m.mDiffuseColor.g = 0; 2923 m.mDiffuseColor.b = 0; 2924 } 2925 exporter->SetForcedMaterial(m); 2864 2926 mViewCellsManager->ExportVcGeometry(exporter, *it); 2865 2927 } … … 2882 2944 } 2883 2945 } 2946 2947 2884 2948 cout << "finished merge" << endl; 2885 2949 mergeStats.mergeTime = TimeDiff(startTime, GetTime());
Note: See TracChangeset
for help on using the changeset viewer.