Changeset 2198
- Timestamp:
- 03/06/07 17:37:28 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2187 r2198 366 366 ObjectContainer::const_iterator oit, oit_end = objects.end(); 367 367 368 // warning: not exact number (there can be rays counted twice) 369 // otherwise we would have to traverse trough all rays 368 370 for (oit = objects.begin(); oit != oit_end; ++ oit) 369 371 { … … 373 375 return nRays; 374 376 } 377 375 378 376 379 float BvHierarchy::GetViewSpaceVolume() const … … 384 387 BvhTraversalData &backData) 385 388 { 389 // fill view cells cache 386 390 mNodeTimer.Entry(); 391 392 #if STORE_VIEWCELLS_WITH_BVH 393 AssociateViewCellsWithObjects(sc.mFrontObjects); 394 AssociateViewCellsWithObjects(sc.mBackObjects); 395 #endif 387 396 const BvhTraversalData &tData = sc.mParentData; 388 397 BvhLeaf *leaf = tData.mNode; … … 400 409 // add the new nodes to the tree 401 410 BvhInterior *node = new BvhInterior(parentBox, leaf->GetParent()); 402 411 403 412 404 413 ////////////////// … … 480 489 AssignSortedObjects(sc, frontData, backData); 481 490 } 482 491 492 #if STORE_VIEWCELLS_WITH_BVH 493 ReleaseViewCells(sc.mFrontObjects); 494 ReleaseViewCells(sc.mBackObjects); 495 #endif 496 483 497 mNodeTimer.Exit(); 484 498 … … 615 629 bool computeSplitPlane) 616 630 { 617 mEvalTimer.Entry(); 631 mPlaneTimer.Entry(); 632 633 #if STORE_VIEWCELLS_WITH_BVH 634 // fill view cells cache 635 AssociateViewCellsWithObjects(*splitCandidate.mParentData.mSortedObjects[3]); 636 #endif 637 618 638 if (computeSplitPlane) 619 639 { … … 640 660 previousMisses + 1 : previousMisses); 641 661 } 642 662 mPlaneTimer.Exit(); 663 664 mEvalTimer.Entry(); 643 665 644 666 const BvhTraversalData &tData = splitCandidate.mParentData; … … 705 727 // compute global decrease in render cost 706 728 splitCandidate.SetPriority(priority); 729 730 #if STORE_VIEWCELLS_WITH_BVH 731 ReleaseViewCells(*splitCandidate.mParentData.mSortedObjects[3]); 732 #endif 733 707 734 mEvalTimer.Exit(); 708 735 } … … 710 737 711 738 int BvHierarchy::EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, 712 const float avgRayContri) const739 const float avgRayContri) //const 713 740 { 714 741 const float oldPvsSize = (float)CountViewCells(splitCandidate.mParentData.mNode->mObjects); … … 991 1018 992 1019 SortableEntryContainer::reverse_iterator rcit = 993 mSubdivisionCandidates->rbegin(), rcit_end = 994 mSubdivisionCandidates->rend(); 1020 mSubdivisionCandidates->rbegin(), rcit_end = mSubdivisionCandidates->rend(); 995 1021 996 1022 vector<float>::reverse_iterator rbit = bordersRight.rbegin(); … … 1406 1432 void BvHierarchy::PrepareLocalSubdivisionCandidates(const BvhTraversalData &tData, 1407 1433 const int axis) 1408 { 1434 {mSort2Timer.Entry(); 1409 1435 //-- insert object queries 1410 1436 ObjectContainer *objects = mUseGlobalSorting ? … … 1412 1438 1413 1439 CreateLocalSubdivisionCandidates(*objects, &mSubdivisionCandidates, !mUseGlobalSorting, axis); 1440 mSort2Timer.Exit(); 1414 1441 } 1415 1442 … … 1472 1499 ViewCellContainer viewCells; 1473 1500 1474 const int numRays = CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 1501 const bool setCounter = true; 1502 const bool onlyUnmailed = true; 1503 1504 const int numRays = CollectViewCells(tData.mNode->mObjects, 1505 viewCells, 1506 setCounter, 1507 onlyUnmailed); 1508 1475 1509 //cout << "number of rays: " << numRays << endl; 1476 1510 … … 1781 1815 1782 1816 1783 float BvHierarchy::EvalRenderCost(const ObjectContainer &objects) const1817 float BvHierarchy::EvalRenderCost(const ObjectContainer &objects)// const 1784 1818 { 1785 1819 /////////////// … … 1793 1827 1794 1828 return objRenderCost * p; 1795 }1796 1797 1798 float BvHierarchy::EvalProb(const ObjectContainer &objects) const1799 {1800 ///////////////1801 //-- render cost heuristics1802 1803 const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume();1804 1805 // probability that view point lies in a view cell which sees this node1806 return EvalViewCellsVolume(objects) / viewSpaceVol;1807 1829 } 1808 1830 … … 1890 1912 ViewCellContainer &viewCells, 1891 1913 const bool setCounter, 1892 const bool onlyUnmailedRays) const1914 const bool onlyUnmailedRays)// const 1893 1915 { 1894 1916 ViewCell::NewMail(); 1917 1895 1918 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1919 1920 // use mailing to avoid dublicates 1921 const bool useMailBoxing = true; 1896 1922 1897 1923 int numRays = 0; … … 1899 1925 for (oit = objects.begin(); oit != oit_end; ++ oit) 1900 1926 { 1901 // always use only mailed objects1902 numRays += CollectViewCells(*oit, viewCells, true, setCounter, onlyUnmailedRays);1927 // use mailing to avoid duplicates 1928 numRays += CollectViewCells(*oit, viewCells, useMailBoxing, setCounter, onlyUnmailedRays); 1903 1929 } 1904 1930 1905 1931 return numRays; 1932 } 1933 1934 1935 #if STORE_VIEWCELLS_WITH_BVH 1936 1937 1938 void BvHierarchy::ReleaseViewCells(const ObjectContainer &objects) 1939 { 1940 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1941 1942 for (oit = objects.begin(); oit != oit_end; ++ oit) 1943 { 1944 (*oit)->DelViewCells(); 1945 } 1946 } 1947 1948 1949 void BvHierarchy::AssociateViewCellsWithObjects(const ObjectContainer &objects) const 1950 { 1951 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1952 1953 const bool useMailBoxing = true; 1954 for (oit = objects.begin(); oit != oit_end; ++ oit) 1955 { 1956 ViewCell::NewMail(); 1957 // use mailing to avoid duplicates 1958 AssociateViewCellsWithObject(*oit, useMailBoxing); 1959 } 1960 } 1961 1962 1963 int BvHierarchy::AssociateViewCellsWithObject(Intersectable *obj, const bool useMailBoxing) const 1964 { 1965 if (!obj->GetOrCreateViewCells()->empty()) 1966 { 1967 cerr << "AssociateViewCellsWithObject: view cells cache not working" << endl; 1968 } 1969 1970 ViewCellContainer *objViewCells = obj->GetOrCreateViewCells(); 1971 VssRayContainer *vssRays = obj->GetOrCreateRays(); 1972 1973 VssRayContainer::const_iterator rit, rit_end = vssRays->end(); 1974 1975 // fill cache 1976 for (rit = vssRays->begin(); rit < rit_end; ++ rit) 1977 { 1978 VssRay *ray = (*rit); 1979 1980 // if (onlyUnmailedRays && ray->Mailed()) 1981 // continue; 1982 mHierarchyManager->mVspTree->GetViewCells(*ray, *objViewCells); 1983 } 1984 1985 return (int)vssRays->size(); 1986 } 1987 1988 1989 1990 int BvHierarchy::CountViewCells(Intersectable *obj) //const 1991 { 1992 ViewCellContainer *viewCells = obj->GetOrCreateViewCells(); 1993 1994 if (obj->GetOrCreateViewCells()->empty()) 1995 { 1996 //cerr << "h";//CountViewCells: view cells empty, view cells cache not working" << endl; 1997 return CountViewCellsFromRays(obj); 1998 } 1999 2000 int result = 0; 2001 2002 ViewCellContainer::const_iterator vit, vit_end = viewCells->end(); 2003 2004 for (vit = viewCells->begin(); vit != vit_end; ++ vit) 2005 { 2006 ViewCell *vc = *vit; 2007 2008 // store view cells 2009 if (!vc->Mailed()) 2010 { 2011 vc->Mail(); 2012 ++ result; 2013 } 2014 } 2015 2016 return result; 1906 2017 } 1907 2018 … … 1911 2022 const bool useMailBoxing, 1912 2023 const bool setCounter, 1913 const bool onlyUnmailedRays) const 1914 { 2024 const bool onlyUnmailedRays)// const 2025 { 2026 if (obj->GetOrCreateViewCells()->empty()) 2027 { 2028 //cerr << "g";//CollectViewCells: view cells empty, view cells cache not working" << endl; 2029 return CollectViewCellsFromRays(obj, viewCells, useMailBoxing, setCounter, onlyUnmailedRays); 2030 } 2031 2032 mCollectTimer.Entry(); 2033 2034 ViewCellContainer *objViewCells = obj->GetOrCreateViewCells(); 2035 2036 /////////// 2037 //-- use view cells cache 2038 2039 // fastest way: just copy to the end 2040 //if (!useMailBoxing) viewCells.insert(viewCells.end(), objViewCells->begin(), objViewCells->end()); 2041 2042 // loop through view cells 2043 // matt: probably slow to insert view cells one by one 2044 ViewCellContainer::const_iterator vit, vit_end = objViewCells->end(); 2045 2046 for (vit = objViewCells->begin(); vit != vit_end; ++ vit) 2047 { 2048 ViewCell *vc = *vit; 2049 2050 // store view cells 2051 if (!useMailBoxing || !vc->Mailed()) 2052 { 2053 if (useMailBoxing) 2054 { 2055 // view cell not mailed 2056 vc->Mail(); 2057 2058 if (setCounter) 2059 vc->mCounter = 0; 2060 //viewCells.push_back(vc); 2061 } 2062 2063 viewCells.push_back(vc); 2064 } 2065 2066 if (setCounter) 2067 ++ vc->mCounter; 2068 } 2069 2070 mCollectTimer.Exit(); 2071 2072 return (int)objViewCells->size(); 2073 } 2074 2075 2076 int BvHierarchy::CollectViewCellsFromRays(Intersectable *obj, 2077 ViewCellContainer &viewCells, 2078 const bool useMailBoxing, 2079 const bool setCounter, 2080 const bool onlyUnmailedRays) 2081 { 2082 mCollectTimer.Entry(); 1915 2083 VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 1916 2084 … … 1922 2090 1923 2091 if (onlyUnmailedRays && ray->Mailed()) 1924 {1925 2092 continue; 1926 } 1927 2093 1928 2094 ++ numRays; 1929 2095 … … 1945 2111 vc->Mail(); 1946 2112 if (setCounter) 1947 {1948 2113 vc->mCounter = 0; 1949 }1950 2114 } 1951 2115 … … 1954 2118 1955 2119 if (setCounter) 1956 {1957 2120 ++ vc->mCounter; 1958 1959 1960 } 1961 2121 } 2122 } 2123 2124 mCollectTimer.Exit(); 1962 2125 return numRays; 1963 2126 } 1964 2127 1965 2128 1966 int BvHierarchy::CountViewCells (Intersectable *obj)const2129 int BvHierarchy::CountViewCellsFromRays(Intersectable *obj) //const 1967 2130 { 1968 2131 int result = 0; … … 1994 2157 } 1995 2158 1996 1997 int BvHierarchy::CountViewCells(const ObjectContainer &objects) const 2159 #else 2160 2161 int BvHierarchy::CountViewCells(Intersectable *obj) //const 2162 { 2163 int result = 0; 2164 2165 VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 2166 2167 for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 2168 { 2169 VssRay *ray = (*rit); 2170 ViewCellContainer tmpViewCells; 2171 2172 mHierarchyManager->mVspTree->GetViewCells(*ray, tmpViewCells); 2173 2174 ViewCellContainer::const_iterator vit, vit_end = tmpViewCells.end(); 2175 for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 2176 { 2177 ViewCell *vc = *vit; 2178 2179 // store view cells 2180 if (!vc->Mailed()) 2181 { 2182 vc->Mail(); 2183 ++ result; 2184 } 2185 } 2186 } 2187 2188 return result; 2189 } 2190 2191 2192 int BvHierarchy::CollectViewCells(Intersectable *obj, 2193 ViewCellContainer &viewCells, 2194 const bool useMailBoxing, 2195 const bool setCounter, 2196 const bool onlyUnmailedRays) 2197 { 2198 mCollectTimer.Entry(); 2199 VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 2200 2201 int numRays = 0; 2202 2203 for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 2204 { 2205 VssRay *ray = (*rit); 2206 2207 if (onlyUnmailedRays && ray->Mailed()) 2208 continue; 2209 2210 ++ numRays; 2211 2212 ViewCellContainer tmpViewCells; 2213 mHierarchyManager->mVspTree->GetViewCells(*ray, tmpViewCells); 2214 2215 // matt: probably slow to allocate memory for view cells every time 2216 ViewCellContainer::const_iterator vit, vit_end = tmpViewCells.end(); 2217 2218 for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 2219 { 2220 ViewCell *vc = *vit; 2221 2222 // store view cells 2223 if (!useMailBoxing || !vc->Mailed()) 2224 { 2225 if (useMailBoxing) // => view cell not mailed 2226 { 2227 vc->Mail(); 2228 if (setCounter) 2229 vc->mCounter = 0; 2230 } 2231 2232 viewCells.push_back(vc); 2233 } 2234 2235 if (setCounter) 2236 ++ vc->mCounter; 2237 } 2238 } 2239 2240 mCollectTimer.Exit(); 2241 return numRays; 2242 } 2243 #endif 2244 2245 2246 int BvHierarchy::CountViewCells(const ObjectContainer &objects)// const 1998 2247 { 1999 2248 int nViewCells = 0; 2000 ViewCell::NewMail(); 2249 2250 //ViewCell::NewMail(); 2001 2251 ObjectContainer::const_iterator oit, oit_end = objects.end(); 2002 2252 … … 2179 2429 2180 2430 2181 float BvHierarchy::EvalViewCellsVolume(const ObjectContainer &objects) const2431 float BvHierarchy::EvalViewCellsVolume(const ObjectContainer &objects)// const 2182 2432 { 2183 2433 float vol = 0; … … 2257 2507 //cout << "using " << nRays << " of " << (int)sampleRays.size() << " rays" << endl; 2258 2508 2509 #if STORE_VIEWCELLS_WITH_BVH 2510 AssociateViewCellsWithObjects(objects); 2511 #endif 2512 2259 2513 // probability that volume is "seen" from the view cells 2260 2514 const float prop = EvalViewCellsVolume(objects) / GetViewSpaceVolume(); … … 2283 2537 bvhLeaf->SetSubdivisionCandidate(oSubdivisionCandidate); 2284 2538 2539 #if STORE_VIEWCELLS_WITH_BVH 2540 ReleaseViewCells(objects); 2541 #endif 2542 2285 2543 if (mApplyInitialPartition) 2286 2544 { … … 2325 2583 const ObjectContainer &objects) 2326 2584 { 2327 mSortTimer.Entry();2328 2329 2585 const bool doSort = true; 2330 2586 … … 2362 2618 stable_sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2363 2619 //sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2364 2365 mSortTimer.Exit();2366 2620 } 2367 2621 … … 2412 2666 const ObjectContainer &objects) 2413 2667 { 2668 2414 2669 // reset stats 2415 2670 mBvhStats.Reset(); … … 2424 2679 mRoot = bvhleaf; 2425 2680 2681 #if STORE_VIEWCELLS_WITH_BVH 2682 AssociateViewCellsWithObjects(objects); 2683 #endif 2684 2426 2685 //mTermMinProbability *= mVspTree->GetBoundingBox().GetVolume(); 2427 2686 // probability that volume is "seen" from the view cells … … 2438 2697 AssignInitialSortedObjectList(oData, objects); 2439 2698 2440 2699 #if STORE_VIEWCELLS_WITH_BVH 2700 ReleaseViewCells(objects); 2701 #endif 2441 2702 /////////////////// 2442 2703 //-- add first candidate for object space partition -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r2187 r2198 35 35 class BvhTree; 36 36 class VspTree; 37 class ViewCellsContainer;38 37 class HierarchyManager; 39 38 … … 649 648 static float EvalAbsCost(const ObjectContainer &objects); 650 649 651 float EvalProb(const ObjectContainer &objects) const;652 653 650 void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 654 651 … … 658 655 void CreateUniqueObjectIds(); 659 656 660 PerfTimer mSortTimer;661 657 PerfTimer mNodeTimer; 662 658 PerfTimer mSubdivTimer; 663 659 PerfTimer mEvalTimer; 664 660 PerfTimer mSplitTimer; 661 PerfTimer mPlaneTimer; 662 PerfTimer mSort2Timer; 663 PerfTimer mCollectTimer; 665 664 666 665 protected: … … 710 709 /** Evaluates render cost of the bv induced by these objects 711 710 */ 712 float EvalRenderCost(const ObjectContainer &objects) const;711 float EvalRenderCost(const ObjectContainer &objects);// const; 713 712 714 713 /** Evaluates tree stats in the BSP tree leafs. … … 759 758 static void AssociateObjectsWithLeaf(BvhLeaf *leaf); 760 759 761 760 762 761 ///////////////////////////// 763 762 // Helper functions for local cost heuristics … … 834 833 ViewCellContainer &viewCells, 835 834 const bool setCounter, 836 const bool onlyUnmailedRays) const;835 const bool onlyUnmailedRays);// const; 837 836 838 837 /** Collects view cells which see an object. … … 846 845 const bool useMailBoxing, 847 846 const bool setCounter, 848 const bool onlyUnmailedRays) const;847 const bool onlyUnmailedRays);// const; 849 848 850 849 /** Counts the view cells of this object. note: only 851 850 counts unmailed objects. 852 851 */ 853 int CountViewCells(Intersectable *obj) const;852 int CountViewCells(Intersectable *obj);// const; 854 853 855 854 /** Counts the view cells seen by this bvh leaf 856 855 */ 857 int CountViewCells(const ObjectContainer &objects) const; 856 int CountViewCells(const ObjectContainer &objects);// const; 857 858 #if STORE_VIEWCELLS_WITH_BVH 859 860 int AssociateViewCellsWithObject(Intersectable *obj, const bool useMailBoxing) const; 861 862 void AssociateViewCellsWithObjects(const ObjectContainer &objects) const; 863 864 void ReleaseViewCells(const ObjectContainer &objects); 865 866 int CollectViewCellsFromRays(Intersectable *obj, 867 ViewCellContainer &viewCells, 868 const bool useMailBoxing, 869 const bool setCounter, 870 const bool onlyUnmailedRays); 871 872 int CountViewCellsFromRays(Intersectable *obj); 873 #endif 858 874 859 875 /** Evaluates increase in pvs size. 860 876 */ 861 int EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, const float avgRayContri) const; 877 int EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, 878 const float avgRayContri);// const; 862 879 863 880 /** Rays will be clipped to the bounding box. … … 901 918 /** Evaluates volume of view cells that see the objects. 902 919 */ 903 float EvalViewCellsVolume(const ObjectContainer &objects) const;920 float EvalViewCellsVolume(const ObjectContainer &objects);// const; 904 921 905 922 /** Assigns or newly creates initial list of sorted objects. -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r2187 r2198 282 282 // split was not reevaluated before => do it now 283 283 if (splitCandidate->IsDirty()) 284 { 284 285 splitCandidate->EvalCandidate(); 286 } 285 287 286 288 return splitCandidate; … … 411 413 void HierarchyManager::PrintTimings(const bool lastSplitWasOsp) 412 414 { 413 double sortTime, evalTime, nodeTime, splitTime, subdTime ;414 415 sortTime = mBvHierarchy->mSort Timer.TotalTime();415 double sortTime, evalTime, nodeTime, splitTime, subdTime, planeTime, collectTime, viewCellsTime; 416 417 sortTime = mBvHierarchy->mSort2Timer.TotalTime(); 416 418 evalTime = mBvHierarchy->mEvalTimer.TotalTime(); 417 419 nodeTime = mBvHierarchy->mNodeTimer.TotalTime(); 418 420 splitTime = mBvHierarchy->mSplitTimer.TotalTime(); 419 421 subdTime = mBvHierarchy->mSubdivTimer.TotalTime(); 422 planeTime = mBvHierarchy->mPlaneTimer.TotalTime(); 423 collectTime = mBvHierarchy->mCollectTimer.TotalTime(); 420 424 421 425 cout << "bvh times" … … 424 428 << " node : " << nodeTime 425 429 << " split: " << splitTime 426 << " subd : " << subdTime << endl; 430 << " subd : " << subdTime 431 << " plane: " << planeTime 432 << " colct: " << collectTime 433 << endl; 427 434 428 435 Debug << "bvh times" … … 431 438 << " node : " << nodeTime 432 439 << " split: " << splitTime 433 << " subd : " << subdTime << endl; 440 << " subd : " << subdTime 441 << " plane: " << planeTime 442 << " colct: " << collectTime 443 << endl; 434 444 435 445 sortTime = mVspTree->mSortTimer.TotalTime(); … … 438 448 splitTime = mVspTree->mSplitTimer.TotalTime(); 439 449 subdTime = mVspTree->mSubdivTimer.TotalTime(); 450 planeTime = mVspTree->mPlaneTimer.TotalTime(); 451 viewCellsTime = mVspTree->mViewCellsTimer.TotalTime(); 440 452 441 453 cout << "vsp times" … … 444 456 << " node : " << nodeTime 445 457 << " split: " << splitTime 446 << " subd : " << subdTime << endl; 458 << " subd : " << subdTime 459 << " plane: " << planeTime 460 << " viewc: " << viewCellsTime 461 << endl; 447 462 448 463 Debug << "vsp times" 449 << " sort : " << sortTime 450 << " eval : " << evalTime 451 << " node : " << nodeTime 452 << " split: " << splitTime 453 << " subd : " << subdTime << endl; 464 << " sort : " << sortTime 465 << " eval : " << evalTime 466 << " node : " << nodeTime 467 << " split: " << splitTime 468 << " subd : " << subdTime 469 << " plane: " << planeTime 470 << " viewc: " << viewCellsTime 471 << endl; 472 454 473 cout << endl; 455 474 Debug << endl; … … 854 873 } 855 874 856 //cout << "priority: " << sc->GetPriority() << " rc decr: " << sc->GetRenderCostDecrease() << " | ";875 857 876 /////////////// 858 877 //-- split was successful => update stats and queue … … 877 896 const int pvsEntriesIncr = sc->GetPvsEntriesIncr(); 878 897 mHierarchyStats.mPvsEntries += pvsEntriesIncr; 879 //cout << "pvs entries: " << pvsEntriesIncr << " " << mHierarchyStats. pvsEntries << endl;898 //cout << "pvs entries: " << pvsEntriesIncr << " " << mHierarchyStats.mPvsEntries << endl; 880 899 881 900 // memory size in byte … … 1156 1175 mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 1157 1176 1177 1158 1178 //mHierarchyStats.mPvsEntries -= mBvHierarchy->mPvsEntries + 1; 1159 1179 mHierarchyStats.mPvsEntries = mBvHierarchy->CountViewCells(objects); -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.cpp
r2176 r2198 11 11 mBvhLeaf(0), 12 12 mVssRays(NULL) 13 #if STORE_VIEWCELLS_WITH_BVH 14 , mViewCells(NULL) 15 #endif 13 16 {} 14 17 … … 62 65 } 63 66 67 #if STORE_VIEWCELLS_WITH_BVH 68 69 ViewCellContainer *Intersectable::GetOrCreateViewCells() 70 { 71 if (!mViewCells) 72 mViewCells = new ViewCellContainer(); 73 74 return mViewCells; 75 } 76 77 78 void Intersectable::DelViewCells() 79 { 80 DEL_PTR(mViewCells); 81 } 82 83 #endif 84 64 85 65 86 void Intersectable::DelRayRefs() -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r2176 r2198 2 2 #define __INTERSECTABLE_H 3 3 4 4 5 #include "AxisAlignedBox3.h" 5 #include <set>6 //#include "VssRay.h"7 6 #include "Mailable.h" 7 8 #define STORE_VIEWCELLS_WITH_BVH 0 8 9 9 10 namespace GtpVisibilityPreprocessor { … … 137 138 static bool GreaterCounter(const Intersectable *a, 138 139 const Intersectable *b); 139 140 /** Returns the name of the type of this intersectable141 */142 static std::string GetTypeName(Intersectable *obj);140 141 /** Returns the name of the type of this intersectable 142 */ 143 static std::string GetTypeName(Intersectable *obj); 143 144 144 145 /** Returns normal from the face with the specified index. … … 155 156 void DelRayRefs(); 156 157 158 157 159 protected: 158 159 160 /// some rays piercing this intersectable 160 161 VssRayContainer *mVssRays; 162 163 #if STORE_VIEWCELLS_WITH_BVH 164 public: 165 /** Returns rays stored with this intersectable. 166 */ 167 ViewCellContainer *GetOrCreateViewCells(); 168 169 void DelViewCells(); 170 171 protected: 172 ViewCellContainer *mViewCells; 173 #endif 161 174 }; 162 175 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2187 r2198 1189 1189 const long t1 = GetTime(); 1190 1190 1191 if ( 1 && (rays.size() > 10000))1191 if (rays.size() > 10000) 1192 1192 { 1193 1193 1194 1194 mRayCaster->SortRays(rays); 1195 1195 cout<<"Rays sorted in "<<TimeDiff(t1, GetTime())<<" ms."<<endl; 1196 1197 if (0) {1198 VssRayContainer tmpRays;1199 int m = 890000;1200 1201 for (int i=m; i < m+20; i++) {1202 tmpRays.push_back(new VssRay(rays[i].mOrigin,1203 rays[i].mOrigin + 100.0f*rays[i].mDirection,1204 NULL,1205 NULL1206 )1207 );1208 1209 }1210 ExportRays("sorted_rays.x3d", tmpRays, 200);1211 }1212 1196 } 1213 1197 -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
r2187 r2198 250 250 251 251 // old method: always allocate 252 if ( 1) return new VssRay(origin, termination, originObject, terminationObject, pass, pdf);252 if (0) return new VssRay(origin, termination, originObject, terminationObject, pass, pdf); 253 253 254 254 VssRay *vssRay = mVssRayPool.Alloc(); -
GTP/trunk/Lib/Vis/Preprocessing/src/Statistics.h
r2003 r2198 17 17 static inline double TimeDiff(long time1, long time2) // in s 18 18 { 19 const double clk = 1.0E- 6; // ticks per second19 const double clk = 1.0E-3; // ticks per second 20 20 long t = time2 - time1; 21 21 -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r2187 r2198 281 281 LinkIncremental="1" 282 282 AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release" 283 GenerateDebugInformation=" FALSE"283 GenerateDebugInformation="TRUE" 284 284 SubSystem="1" 285 285 LargeAddressAware="0" -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2187 r2198 2791 2791 2792 2792 // check if last ray was not same ray with reverse direction 2793 if ( lastVssRay == NULL||2793 if (!lastVssRay || 2794 2794 !(ray.mOrigin == lastVssRay->mTermination) || 2795 2795 !(ray.mTermination == lastVssRay->mOrigin)) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2187 r2198 775 775 bool computeSplitPlane) 776 776 { 777 m EvalTimer.Entry();777 mPlaneTimer.Entry(); 778 778 779 779 if (computeSplitPlane) … … 796 796 } 797 797 798 mPlaneTimer.Exit(); 799 800 mEvalTimer.Entry(); 801 798 802 VspLeaf *leaf = static_cast<VspLeaf *>(splitCandidate.mParentData.mNode); 799 803 … … 1112 1116 } 1113 1117 1114 stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1115 //sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1118 if (1) 1119 stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1120 else 1121 sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1116 1122 1117 1123 mSortTimer.Exit(); … … 2552 2558 ViewCell *VspTree::GetViewCell(const Vector3 &point, const bool active) 2553 2559 { 2554 if ( mRoot == NULL)2560 if (!mRoot) 2555 2561 return NULL; 2556 2562 … … 2590 2596 } 2591 2597 2598 // return active or leaf view cell 2592 2599 if (active) 2593 2600 { … … 2785 2792 const AxisAlignedBox3 bbox = GetBoundingBox(node); 2786 2793 2787 if (Overlap(bbox, box)) { 2788 if (node->IsLeaf()) 2789 { 2790 VspLeaf *leaf = static_cast<VspLeaf *>(node); 2791 2792 if (!leaf->GetViewCell()->Mailed() && leaf->TreeValid()) 2794 if (Overlap(bbox, box)) 2795 { 2796 if (node->IsLeaf()) 2797 { 2798 VspLeaf *leaf = static_cast<VspLeaf *>(node); 2799 2800 if (!leaf->GetViewCell()->Mailed() && leaf->TreeValid()) 2793 2801 { 2794 2795 2802 leaf->GetViewCell()->Mail(); 2803 viewCells.push_back(leaf->GetViewCell()); 2796 2804 } 2797 2805 } 2798 2799 { 2800 2801 2802 2803 2804 2805 2806 2806 else 2807 { 2808 VspInterior *interior = static_cast<VspInterior *>(node); 2809 2810 VspNode *first = interior->GetFront(); 2811 VspNode *second = interior->GetBack(); 2812 2813 nodeStack.push(first); 2814 nodeStack.push(second); 2807 2815 } 2808 2816 } … … 2852 2860 void VspTree::GetViewCells(const VssRay &ray, ViewCellContainer &viewCells) 2853 2861 { 2862 mViewCellsTimer.Entry(); 2863 2854 2864 static Ray hray; 2855 2865 hray.Init(ray); … … 2863 2873 const Vector3 termination = hray.Extrap(tmax); 2864 2874 2865 // view cells were not precomputed 2866 // don't mail because we need mailboxing for something else2875 // view cells were not precomputed and are extracted on the fly 2876 // don't mail because the same view cells can be found for different rays 2867 2877 CastLineSegment(origin, termination, viewCells, false); 2878 2879 mViewCellsTimer.Exit(); 2868 2880 } 2869 2881 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r2187 r2198 728 728 PerfTimer mSubdivTimer; 729 729 PerfTimer mEvalTimer; 730 PerfTimer mPlaneTimer; 731 PerfTimer mViewCellsTimer; 730 732 731 733 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r2187 r2198 624 624 { 625 625 // store higher order object 626 mViewCellsManager->DeterminePvsObjects(rays, false);627 } 628 629 630 } 626 mViewCellsManager->DeterminePvsObjects(rays, !mViewCellsManager->ViewCellsConstructed()); 627 } 628 629 630 }
Note: See TracChangeset
for help on using the changeset viewer.