Ignore:
Timestamp:
11/28/06 19:46:36 (18 years ago)
Author:
bittner
Message:

global lines support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp

    r1785 r1824  
    336336          leaf->dirBBox.Initialize(); 
    337337          leaf->dirBBox.SetMin(2, 0.0f); 
    338           leaf->dirBBox.SetMax(2, 1.0f); 
     338          leaf->dirBBox.SetMax(2, 0.0f); 
    339339          mRoots[i] = leaf; 
    340340        } 
     
    391391  // make the z axis (unused) a unit size 
    392392  // important for volume computation 
    393  
    394393   
    395394  //  if ( forcedBoundingBox )  
     
    22302229        dirVector = dirBox.GetPoint(dVector); 
    22312230         
    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); 
    22372232         
    22382233        //      float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); 
     
    22432238#if 1 
    22442239        if (box.ComputeMinMaxT(origin, direction, &minT, &maxT) && minT < maxT) 
    2245           dist = maxT; 
     2240          dist = (maxT + 1e-2*boxSize); 
    22462241#else 
    22472242        dist = 0.5f*boxSize; 
     
    23732368                w1*leaf->rays[r1].GetDir() + 
    23742369                w2*leaf->rays[r2].GetDir(); 
     2370 
     2371          // shift the origin a little bit 
     2372          direction.Normalize(); 
     2373           
    23752374        } else { 
    23762375          Vector3 dirVector; 
     
    24052404          dirVector = dirBox.GetPoint(dVector); 
    24062405 
    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         
    24122409         
    24132410        //      float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); 
     
    26282625          if (node->IsLeaf()) { 
    26292626                RssTreeLeaf *leaf = (RssTreeLeaf *)node; 
    2630                 // prunned += PruneRaysRandom(leaf, ratio); 
     2627                //              prunned += PruneRaysRandom(leaf, ratio); 
    26312628                prunned += PruneRaysContribution(leaf, ratio); 
    26322629          } else { 
     
    27592756// if small very high importance of the last sample 
    27602757// if 1.0f then weighs = 1 1/2 1/3 1/4 
     2758//float passSampleWeightDecay = 1.0f; 
    27612759float passSampleWeightDecay = 1.0f; 
    2762 //float passSampleWeightDecay = 0.0001f; 
    27632760 
    27642761float 
     
    27682765  float weight; 
    27692766  if (1)  
    2770         weight = 1.0f/sqr(passDiff + passSampleWeightDecay); 
     2767                weight = 1.0f/(passDiff + passSampleWeightDecay); 
    27712768  else  
    2772         switch (passDiff) { 
     2769                switch (passDiff) { 
    27732770          case 0: 
    2774           //      weight = 1.0f; 
    2775           //      break; 
    2776         default: 
    2777           weight = 1.0f; 
    2778           break; 
     2771                        //        weight = 1.0f; 
     2772                        //        break; 
     2773                default: 
     2774                        weight = 1.0f; 
     2775                        break; 
    27792776          //    case 1: 
    27802777//        weight = 0.5f; 
     
    28232820        float sumRelContributions = 0.0f; 
    28242821        float sumWeights = 0.0f; 
     2822        float maxContribution = 0.0f; 
     2823        float maxRelContribution = 0.0f; 
     2824        float sumLength = 0; 
     2825         
    28252826        for (; it != it_end; ++it) { 
    28262827          VssRay *ray = (*it).mRay; 
     2828          float sumLength = ray->Length(); 
     2829 
    28272830          float weight = GetSampleWeight(ray->mPass); 
    28282831           
    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!! 
    28312840          //sumRelContributions += weight*ray->mRelativePvsContribution; 
    2832  
    2833           sumRelContributions += sqr(weight*ray->mRelativePvsContribution); 
    2834            
     2841           
     2842          sumRelContributions += c2; 
     2843          if (c2 > maxRelContribution) 
     2844                maxRelContribution = c2; 
     2845 
    28352846          //sumWeights += weight; 
    28362847          sumWeights += 1.0f; 
    28372848        } 
     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         
    28382863        // $$  
    28392864        // sumWeights = leaf->mTotalRays; 
    2840            
    2841         if (sumWeights != 0.0f)  
     2865 
     2866        if (sumWeights != 0.0f) { 
    28422867          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 
    28462876          leaf->mImportance = 0.0f; 
    28472877         
     
    28562886RssTreeLeaf::GetImportance()  const 
    28572887{ 
    2858   //return sqr(mImportance); 
     2888  //  return sqr(mImportance); 
    28592889  return mImportance; 
    28602890} 
Note: See TracChangeset for help on using the changeset viewer.