Changeset 1824 for GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
- Timestamp:
- 11/28/06 19:46:36 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
r1785 r1824 336 336 leaf->dirBBox.Initialize(); 337 337 leaf->dirBBox.SetMin(2, 0.0f); 338 leaf->dirBBox.SetMax(2, 1.0f);338 leaf->dirBBox.SetMax(2, 0.0f); 339 339 mRoots[i] = leaf; 340 340 } … … 391 391 // make the z axis (unused) a unit size 392 392 // important for volume computation 393 394 393 395 394 // if ( forcedBoundingBox ) … … 2230 2229 dirVector = dirBox.GetPoint(dVector); 2231 2230 2232 direction = Vector3(sin(dirVector.x), sin(dirVector.y), cos(dirVector.x)); 2233 2234 2235 // shift the origin a little bit 2236 direction.Normalize(); 2231 direction = VssRay::GetInvDirParam(dirVector.x, dirVector.y); 2237 2232 2238 2233 // float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); … … 2243 2238 #if 1 2244 2239 if (box.ComputeMinMaxT(origin, direction, &minT, &maxT) && minT < maxT) 2245 dist = maxT;2240 dist = (maxT + 1e-2*boxSize); 2246 2241 #else 2247 2242 dist = 0.5f*boxSize; … … 2373 2368 w1*leaf->rays[r1].GetDir() + 2374 2369 w2*leaf->rays[r2].GetDir(); 2370 2371 // shift the origin a little bit 2372 direction.Normalize(); 2373 2375 2374 } else { 2376 2375 Vector3 dirVector; … … 2405 2404 dirVector = dirBox.GetPoint(dVector); 2406 2405 2407 direction = Vector3(sin(dirVector.x), sin(dirVector.y), cos(dirVector.x)); 2408 } 2409 2410 // shift the origin a little bit 2411 direction.Normalize(); 2406 direction = VssRay::GetInvDirParam(dirVector.x,dirVector.y); 2407 } 2408 2412 2409 2413 2410 // float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); … … 2628 2625 if (node->IsLeaf()) { 2629 2626 RssTreeLeaf *leaf = (RssTreeLeaf *)node; 2630 // 2627 // prunned += PruneRaysRandom(leaf, ratio); 2631 2628 prunned += PruneRaysContribution(leaf, ratio); 2632 2629 } else { … … 2759 2756 // if small very high importance of the last sample 2760 2757 // if 1.0f then weighs = 1 1/2 1/3 1/4 2758 //float passSampleWeightDecay = 1.0f; 2761 2759 float passSampleWeightDecay = 1.0f; 2762 //float passSampleWeightDecay = 0.0001f;2763 2760 2764 2761 float … … 2768 2765 float weight; 2769 2766 if (1) 2770 weight = 1.0f/sqr(passDiff + passSampleWeightDecay);2767 weight = 1.0f/(passDiff + passSampleWeightDecay); 2771 2768 else 2772 switch (passDiff) {2769 switch (passDiff) { 2773 2770 case 0: 2774 2775 2776 default:2777 2778 2771 // weight = 1.0f; 2772 // break; 2773 default: 2774 weight = 1.0f; 2775 break; 2779 2776 // case 1: 2780 2777 // weight = 0.5f; … … 2823 2820 float sumRelContributions = 0.0f; 2824 2821 float sumWeights = 0.0f; 2822 float maxContribution = 0.0f; 2823 float maxRelContribution = 0.0f; 2824 float sumLength = 0; 2825 2825 2826 for (; it != it_end; ++it) { 2826 2827 VssRay *ray = (*it).mRay; 2828 float sumLength = ray->Length(); 2829 2827 2830 float weight = GetSampleWeight(ray->mPass); 2828 2831 2829 sumContributions += weight*ray->mPvsContribution; 2830 //$$ 20.7. changed to sqr to pronouce higher contribution so that they do not get smoothed!! 2832 float c1 = weight*ray->mPvsContribution; 2833 float c2 = weight*ray->mRelativePvsContribution; 2834 sumContributions += c1; 2835 if (c1 > maxContribution) 2836 maxContribution = c1; 2837 2838 //$$ 20.7. changed to sqr to pronouce higher contribution so that 2839 // they do not get smoothed!! 2831 2840 //sumRelContributions += weight*ray->mRelativePvsContribution; 2832 2833 sumRelContributions += sqr(weight*ray->mRelativePvsContribution); 2834 2841 2842 sumRelContributions += c2; 2843 if (c2 > maxRelContribution) 2844 maxRelContribution = c2; 2845 2835 2846 //sumWeights += weight; 2836 2847 sumWeights += 1.0f; 2837 2848 } 2849 2850 float distImportance = 0.0f; 2851 2852 if (leaf->rays.size()) { 2853 // compute average length of the ray 2854 float avgLength = sumLength/leaf->rays.size(); 2855 // compute estimated area of the visible surface corresponding to these rays 2856 float ss = GetBBox(leaf).SurfaceArea()/2.0f; 2857 float sd = GetDirBBox(leaf).SurfaceArea(); 2858 float s = ss + avgLength*(2*sqrt(ss*sd) + avgLength*sd); 2859 2860 distImportance = s/leaf->rays.size(); 2861 } 2862 2838 2863 // $$ 2839 2864 // sumWeights = leaf->mTotalRays; 2840 2841 if (sumWeights != 0.0f) 2865 2866 if (sumWeights != 0.0f) { 2842 2867 leaf->mImportance = 2843 (weightAbsContributions*sumContributions + 2844 (1.0f - weightAbsContributions)*sumRelContributions)/sumWeights; 2845 else 2868 sqr(((weightAbsContributions*sumContributions + 2869 (1.0f - weightAbsContributions)*sumRelContributions)/sumWeights)); 2870 2871 // leaf->mImportance = 2872 // (weightAbsContributions*maxContribution + 2873 // (1.0f - weightAbsContributions)*maxRelContribution)/sumWeights; 2874 2875 } else 2846 2876 leaf->mImportance = 0.0f; 2847 2877 … … 2856 2886 RssTreeLeaf::GetImportance() const 2857 2887 { 2858 // return sqr(mImportance);2888 // return sqr(mImportance); 2859 2889 return mImportance; 2860 2890 }
Note: See TracChangeset
for help on using the changeset viewer.