Changeset 557 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 01/19/06 23:36:01 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
r547 r557 1759 1759 } 1760 1760 1761 1761 1762 bool AxisAlignedBox3::GetRaySegment(const Ray &ray, 1762 1763 float &minT, 1763 1764 float &maxT) const 1764 1765 { 1765 maxT = 1e 6;1766 maxT = 1e15; 1766 1767 minT = 0; 1767 1768 1768 // test with 1769 // test with bounding box 1769 1770 if (!GetMinMaxT(ray, &minT, &maxT)) 1770 1771 return false; 1771 1772 1772 if (minT < 0) // start ray from origin1773 if (minT < 0) 1773 1774 minT = 0; 1774 1775 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r556 r557 139 139 140 140 141 float ViewCellsManager::GetViewSpaceVolume() 142 { 143 return mViewSpaceBox.GetVolume()*(2.0f*sqr(M_PI)); 144 } 145 146 141 147 bool ViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 142 148 { … … 428 434 //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 429 435 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 430 return;436 return; 431 437 432 438 Vector3 origin = hray.Extrap(tmin); … … 679 685 { 680 686 // compute view cell area as subsititute for probability 681 #if 0682 return Get Area(viewCell) / GetViewSpaceBox().SurfaceArea();687 #if 1 688 return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 683 689 #else 684 690 return GetArea(viewCell) / GetAccVcArea(); … … 835 841 cout << "exporting view cells after merge ... "; 836 842 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 843 837 844 838 845 if (exporter) … … 1888 1895 VssRayContainer savedRays; 1889 1896 1890 Debug << "construction samples: " << mConstructionSamples << " rays: " << rays.size() << endl;1897 Debug << "construction samples: " << mConstructionSamples << " rays: " << (int)rays.size() << endl; 1891 1898 GetRaySets(rays, mConstructionSamples, constructionRays, &savedRays); 1892 1899 … … 2176 2183 exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 2177 2184 } 2178 2185 2179 2186 ExportViewCellsForViz(exporter); 2180 2187 delete exporter; 2181 2188 } 2189 } 2190 2191 // export shuffled view cells 2192 if (1) 2193 { 2194 cout << "exporting shuffled view cells ..."; 2195 2196 Exporter *exporter = Exporter::GetExporter("shuffled_view_cells.x3d"); 2197 if (exporter) 2198 { 2199 if (1) 2200 { 2201 exporter->SetWireframe(); 2202 exporter->ExportBox(mViewSpaceBox); 2203 exporter->SetFilled(); 2204 } 2205 2206 if (mExportGeometry) 2207 { 2208 exporter->ExportGeometry(objects); 2209 } 2210 2211 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 2212 2213 Material vm, lm; 2214 2215 for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 2216 { 2217 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 2218 2219 vm = RandomMaterial(); 2220 2221 lm = vm; 2222 2223 vm.mDiffuseColor.r -= 0.3f; 2224 vm.mDiffuseColor.g -= 0.3f; 2225 vm.mDiffuseColor.b -= 0.3f; 2226 2227 vector<BspLeaf *>::const_iterator lit, lit_end = vc->mLeaves.end(); 2228 2229 for (lit = vc->mLeaves.begin(); lit != lit_end; ++ lit) 2230 { 2231 BspLeaf *leaf = *lit; 2232 2233 if (leaf->Mailed()) 2234 exporter->SetForcedMaterial(lm); 2235 else 2236 exporter->SetForcedMaterial(vm); 2237 2238 BspNodeGeometry geom; 2239 mVspBspTree->ConstructGeometry(leaf, geom); 2240 exporter->ExportPolygons(geom.mPolys); 2241 } 2242 } 2243 2244 delete exporter; 2245 } 2246 2182 2247 2183 2248 cout << "finished" << endl; … … 2375 2440 importance = (float)bspVc->mLeaves.size() / 2376 2441 (float)mViewCellsStats.maxLeaves; 2377 2378 if (CheckValid(vc))2379 m.mDiffuseColor.b = 1.0f;2380 m.mDiffuseColor.r = importance;2381 m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r;2382 2442 } 2383 2443 break; … … 2387 2447 (float)(mVspBspTree->GetStatistics().maxDepth * 2); 2388 2448 2389 if (CheckValid(vc))2390 m.mDiffuseColor.b = 1.0f;2391 m.mDiffuseColor.r = importance;2392 m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r;2393 2449 } 2394 2450 break; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r556 r557 301 301 302 302 303 virtual float GetViewSpaceVolume() { 304 return mViewSpaceBox.GetVolume()*(2.0f*sqr(M_PI)); 305 } 303 virtual float GetViewSpaceVolume(); 304 306 305 /** Creates meshes from the view cells. 307 306 */ -
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()); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r556 r557 275 275 /** Merge view cells of leaves l1 and l2. 276 276 */ 277 bool MergeViewCells(BspLeaf *l1, BspLeaf *l2) 277 bool MergeViewCells(BspLeaf *l1, BspLeaf *l2); //const; 278 278 279 279 /** Returns true if this view point is in a valid view space, … … 721 721 private: 722 722 723 ViewCellContainer mOldViewCells; 724 ViewCellContainer mNewViewCells; 725 723 726 static const float sLeastRaySplitsTable[5]; 724 727 /** Evaluates split plane classification with respect to the plane's -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r556 r557 678 678 679 679 // cast view cell samples 680 while (1) { 680 while (samples < mVssSamples) 681 { 682 681 683 int num = mVssSamplesPerPass; 682 684 SimpleRayContainer rays; … … 720 722 721 723 // test if we really have enough rays 722 //if (constructionRays.size() >= nSamples) 724 //if (constructionRays.size() >= nSamples) 723 725 mViewCellsManager->Construct(mObjects, constructionRays); 724 726 } … … 743 745 cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 744 746 cout<<"*****************************\n"; 745 if (samples >= mVssSamples) 746 break; 747 pass++; 747 // if (samples >= mVssSamples) break; 748 pass ++; 748 749 } 749 750
Note: See TracChangeset
for help on using the changeset viewer.