Changeset 1903
- Timestamp:
- 12/16/06 19:05:53 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1899 r1903 1826 1826 1827 1827 if (onlyMailedRays && !ray->Mailed()) 1828 { //if (onlyMailedRays)cout << "u";1828 { 1829 1829 continue; 1830 }//else if (onlyMailedRays) cout << "z"; 1831 1832 //ray->Mail(); 1830 } 1831 1833 1832 ++ numRays; 1834 1833 … … 1846 1845 if (!useMailBoxing || !vc->Mailed()) 1847 1846 { 1848 if (useMailBoxing) 1847 if (useMailBoxing) // => view cell not mailed 1849 1848 { 1850 1849 vc->Mail(); … … 1854 1853 } 1855 1854 } 1855 1856 1856 viewCells.push_back(vc); 1857 1857 } -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1877 r1903 800 800 ViewCellContainer &viewCells, 801 801 const bool setCounter, 802 const bool only UnmailedRays) const;802 const bool onlyMailedRays) const; 803 803 804 804 /** Counts the view cells of this object. note: only … … 817 817 const bool useMailBoxing, 818 818 const bool setCounter, 819 const bool only UnmailedRays) const;819 const bool onlyMailedRays) const; 820 820 821 821 /** Evaluates increase in pvs size. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1902 r1903 79 79 80 80 81 int ViewCellsManager::CastPassSamples2(const int samplesPerPass, VssRayContainer &passSamples) const 82 { 83 long startTime = GetTime(); 84 85 SimpleRayContainer simpleRays; 86 87 simpleRays.reserve(samplesPerPass); 88 passSamples.reserve(samplesPerPass * 2); // always creates double rays 89 90 // create one third of each type 91 int castRays = 0; 92 93 mMixtureDistribution->GenerateSamples(mSamplesPerPass, simpleRays); 94 95 cout << "generated " << simpleRays.size() << " samples in " 96 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 97 98 startTime = GetTime(); 99 100 // shoot simple ray and add it to importance samples 101 mPreprocessor->CastRays(simpleRays, passSamples, true); 102 103 cout << "cast " << samplesPerPass << " samples in " 104 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 105 106 mMixtureDistribution->ComputeContributions(passSamples); 107 108 return (int)passSamples.size(); 109 } 110 111 81 112 void ViewCellsManager::ParseEnvironment() 82 113 { … … 123 154 mStrategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 124 155 } 125 else 126 { 127 mStrategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 128 //mStrategies.push_back(SamplingStrategy::VIEWSPACE_BORDER_BASED_DISTRIBUTION); 129 mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 130 //mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 131 //mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 132 } 133 156 134 157 135 158 Debug << "casting strategies: "; … … 137 160 Debug << mStrategies[i] << " "; 138 161 Debug << endl; 162 163 // now decode distribution string 164 char buff[1024]; 165 Environment::GetSingleton()->GetStringValue("RssPreprocessor.distributions", buff); 166 167 mMixtureDistribution = new MixtureDistribution(*mPreprocessor); 168 mMixtureDistribution->Construct(buff); 169 139 170 140 171 // sampling type for view cells construction samples … … 278 309 DEL_PTR(mViewCellsTree); 279 310 } 280 } 311 312 DEL_PTR(mMixtureDistribution); 313 } 314 281 315 282 316 Intersectable * … … 2028 2062 const bool storeViewCells) 2029 2063 { 2030 2031 2032 2033 2034 return 0.0f;2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 return 0;2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2064 ray.mPvsContribution = 0; 2065 ray.mRelativePvsContribution = 0.0f; 2066 2067 if (ray.mTerminationObject==NULL) 2068 return 0.0f; 2069 2070 ViewCellContainer viewcells; 2071 2072 static Ray hray; 2073 hray.Init(ray); 2074 2075 float tmin = 0, tmax = 1.0; 2076 2077 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 2078 return 0; 2079 2080 Vector3 origin = hray.Extrap(tmin); 2081 Vector3 termination = hray.Extrap(tmax); 2082 2083 ViewCell::NewMail(); 2084 2085 // traverse the view space subdivision 2086 CastLineSegment(origin, termination, viewcells); 2087 2088 if (storeViewCells) 2055 2089 { 2056 // copy viewcells memory efficiently 2057 ray.mViewCells.reserve(viewcells.size()); 2058 ray.mViewCells = viewcells; 2059 } 2060 2061 ViewCellContainer::const_iterator it = viewcells.begin(); 2062 2063 Intersectable *terminationObj = GetIntersectable(ray, true); 2064 2065 2066 for (; it != viewcells.end(); ++ it) 2067 { 2068 ViewCell *viewcell = *it; 2069 2070 if (viewcell->GetValid()) 2071 { // if ray not outside of view space 2072 float contribution; 2073 2074 if (terminationObj) 2090 // copy viewcells memory efficiently 2091 ray.mViewCells.reserve(viewcells.size()); 2092 ray.mViewCells = viewcells; 2093 } 2094 2095 ViewCellContainer::const_iterator it = viewcells.begin(); 2096 2097 Intersectable *terminationObj = GetIntersectable(ray, true); 2098 2099 2100 for (; it != viewcells.end(); ++ it) 2101 { 2102 ViewCell *viewcell = *it; 2103 2104 if (viewcell->GetValid()) 2105 { 2106 // if ray not outside of view space 2107 float contribution; 2108 2109 if (terminationObj) 2075 2110 { 2076 // todo: maybe not correct for kd node pvs 2077 bool absContribution = viewcell->GetPvs().GetSampleContribution( 2078 terminationObj, 2079 ray.mPdf, 2080 contribution); 2111 // todo: maybe not correct for kd node pvs 2112 bool absContribution = 2113 viewcell->GetPvs().GetSampleContribution( 2114 terminationObj, 2115 ray.mPdf, 2116 contribution); 2081 2117 #if DIST_WEIGHTED_CONTRIBUTION 2082 2083 2118 // clear the relative contribution 2119 contribution = 0.0f; 2084 2120 #endif 2085 2121 if (absContribution) 2086 2122 { 2087 2088 2123 ++ ray.mPvsContribution; 2124 if (addRays) { 2089 2125 #if PVS_ADD_DIRTY 2090 viewcell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf); 2091 if (viewcell->GetPvs().RequiresResort()) { 2092 viewcell->GetPvs().SimpleSort(); 2126 viewcell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf); 2127 if (viewcell->GetPvs().RequiresResort()) { 2128 viewcell->GetPvs().SimpleSort(); 2129 } 2130 #else 2131 viewcell->GetPvs().AddSample(terminationObj, ray.mPdf); 2132 #endif 2093 2133 } 2094 #else2095 viewcell->GetPvs().AddSample(terminationObj, ray.mPdf);2096 #endif2097 }2098 2134 #if DIST_WEIGHTED_CONTRIBUTION 2099 2100 2101 2102 2135 // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 2136 // object-> a new contribution in the proximity of the viewcell has a larger weight! 2137 contribution = 1.0f/SqrDistance(GetViewCellBox(viewcell).Center(), 2138 ray.mTermination); 2103 2139 #endif 2104 2140 } 2105 2106 2141 2142 ray.mRelativePvsContribution += contribution; 2107 2143 } 2108 2144 } … … 6016 6052 evalStrats.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 6017 6053 } 6018 else 6019 { 6020 //evalStrats.push_back(SamplingStrategy::VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6021 evalStrats.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 6022 evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6023 //evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6024 //evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6025 } 6026 6054 6027 6055 Debug << "casting eval strategies: "; 6028 6056 for (int i = 0; i < (int)evalStrats.size(); ++ i) … … 6048 6076 Debug << "casting " << samplesPerPass << " samples ... "; 6049 6077 6050 CastPassSamples(samplesPerPass, evalStrats, evaluationSamples); 6051 //CastPassSamples(samplesPerPass, mStrategies, evaluationSamples); 6052 6078 if (1) 6079 { 6080 CastPassSamples(samplesPerPass, evalStrats, evaluationSamples); 6081 } 6082 else 6083 { 6084 // use mixed distributions 6085 CastPassSamples2(samplesPerPass, evaluationSamples); 6086 } 6087 6053 6088 castSamples += samplesPerPass; 6054 6089 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1902 r1903 39 39 class ViewCellsTree; 40 40 class ViewCell; 41 41 class MixtureDistribution; 42 42 struct AxisAlignedPlane; 43 43 struct BspRay; 44 44 45 45 46 struct PvsFilterStatistics { … … 596 597 VssRayContainer &vssRays) const; 597 598 599 int CastPassSamples2(const int samplesPerPass, 600 VssRayContainer &passSamples) const; 601 598 602 /** Parse the options from the environment file. 599 603 */ … … 756 760 757 761 bool mUseKdPvs; 762 763 MixtureDistribution *mMixtureDistribution; 758 764 759 765 ////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1899 r1903 1451 1451 // get subset of rays 1452 1452 RayInfoContainer randomRays; 1453 randomRays.reserve(m MaxTests);1453 randomRays.reserve(min(mMaxTests, (int)tData.mRays->size())); 1454 1454 1455 1455 RayInfoContainer *usedRays; -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1892 r1903 265 265 //PreprocessorThread *pt = PreprocessorThreadFactory::Create(preprocessor); 266 266 PreprocessorThread *pt; 267 cout << "here8"<<endl;268 267 269 268 #if USE_QT
Note: See TracChangeset
for help on using the changeset viewer.