Ignore:
Timestamp:
02/15/07 13:19:17 (17 years ago)
Author:
mattausch
Message:

implemented bit pvs (warnin: only worjs for preprocessing)

File:
1 edited

Legend:

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

    r2116 r2117  
    681681        if (mUseKdPvs) 
    682682        { 
    683           KdNode *node = GetPreprocessor()->mKdTree->GetPvsNode(isTermination ? 
    684                                                                                                                         ray.mTermination : ray.mOrigin); 
     683                KdNode *node = GetPreprocessor()-> 
     684                        mKdTree->GetPvsNode(isTermination ?     ray.mTermination : ray.mOrigin); 
    685685          return GetPreprocessor()->mKdTree->GetOrCreateKdIntersectable(node); 
    686686        } 
     
    12781278 
    12791279        ViewCellContainer viewCells; 
    1280          
     1280 
     1281        cout << "objects size: " << ObjectPvsIterator::sObjects.size() << endl; 
     1282        cout << "pvs size: " <<  ObjectPvs::sPvsSize << endl; 
     1283 
    12811284        // $$ JB hack - the collect best viewcells does not work? 
    12821285#if 0 
     
    26122615 
    26132616 
    2614 void 
    2615 ViewCellsManager::SortViewCellPvs() 
    2616 { 
    2617  
    2618   ViewCellContainer::iterator it, it_end = mViewCells.end(); 
    2619   for (it = mViewCells.begin(); it != it_end; ++ it) { 
    2620         ObjectPvs &pvs = (*it)->GetPvs(); 
    2621         if (pvs.RequiresResortLog()) 
    2622           pvs.SimpleSort(); 
    2623   } 
    2624 } 
     2617void ViewCellsManager::SortViewCellPvs() 
     2618{ 
     2619        ViewCellContainer::iterator it, it_end = mViewCells.end(); 
     2620         
     2621        for (it = mViewCells.begin(); it != it_end; ++ it)  
     2622        { 
     2623                ObjectPvs &pvs = (*it)->GetPvs(); 
     2624                if (pvs.RequiresResortLog()) 
     2625                        pvs.SimpleSort(); 
     2626        } 
     2627} 
     2628 
    26252629 
    26262630void ViewCellsManager::ComputeViewCellContribution(ViewCell *viewCell, 
     
    26302634                                                                                                   const bool addSamplesToPvs) 
    26312635{ 
    2632   // check if we are outside of view space 
    2633   // $$JB tmp commented to speedup up computations 
     2636        // check if we are outside of view space 
     2637        // $$JB tmp commented to speedup up computations 
    26342638#if 0 
    2635   if (!obj || !viewCell->GetValid()) 
    2636         return; 
     2639        if (!obj || !viewCell->GetValid()) 
     2640                return; 
    26372641#endif 
    2638    
    2639    
    2640   // if ray not outside of view space 
    2641   float relContribution = 0.0f; 
    2642   float absContribution = 0.0f; 
    2643   bool hasAbsContribution; 
    2644    
    2645   // todo: maybe not correct for kd node pvs 
    2646   if (addSamplesToPvs) { 
    2647         hasAbsContribution = viewCell->GetPvs().AddSampleDirtyCheck(obj, 
    2648                                                                                                                                 ray.mPdf); 
    2649         //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 
    2650   } 
    2651   else { 
    2652         hasAbsContribution = viewCell->GetPvs().GetSampleContribution( 
    2653                                                                                                                                   obj, 
    2654                                                                                                                                   ray.mPdf, 
    2655                                                                                                                                   relContribution); 
    2656   } 
    2657    
    2658   // $$ clear the relative contribution as it is currently not correct anyway 
    2659   //  relContribution = 0.0f; 
    2660    
    2661   if (hasAbsContribution)  { 
    2662         ++ ray.mPvsContribution; 
    2663         absContribution = relContribution = 1.0f; 
    2664         if (viewCell->GetPvs().RequiresResort())  
    2665                 viewCell->GetPvs().SimpleSort(); 
     2642 
     2643        // if ray not outside of view space 
     2644        float relContribution = 0.0f; 
     2645        float absContribution = 0.0f; 
     2646        bool hasAbsContribution; 
     2647 
     2648        // todo: maybe not correct for kd node pvs 
     2649        if (addSamplesToPvs)  
     2650        { 
     2651                hasAbsContribution = viewCell->GetPvs(). 
     2652                        AddSampleDirtyCheck(obj, ray.mPdf); 
     2653                //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 
     2654        } 
     2655        else  
     2656        { 
     2657                hasAbsContribution =  
     2658                        viewCell->GetPvs().GetSampleContribution(obj, 
     2659                        ray.mPdf, 
     2660                        relContribution); 
     2661        } 
     2662 
     2663        // $$ clear the relative contribution as it is currently not correct anyway 
     2664        //  relContribution = 0.0f; 
     2665 
     2666        if (hasAbsContribution)   
     2667        { 
     2668                ++ ray.mPvsContribution; 
     2669                absContribution = relContribution = 1.0f; 
     2670 
     2671                if (viewCell->GetPvs().RequiresResort())  
     2672                        viewCell->GetPvs().SimpleSort(); 
    26662673 
    26672674#if CONTRIBUTION_RELATIVE_TO_PVS_SIZE 
    2668         relContribution /= viewcell->GetPvs().GetSize(); 
     2675                relContribution /= viewcell->GetPvs().GetSize(); 
    26692676#endif 
    2670          
     2677 
    26712678#if DIST_WEIGHTED_CONTRIBUTION  
    2672         // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 
    2673         // object-> a new contribution in the proximity of the viewcell has a larger weight! 
    2674         relContribution /= SqrDistance(GetViewCellBox(viewcell).Center(), 
    2675                                                                   ray.mTermination); 
    2676          
     2679                // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 
     2680                // object-> a new contribution in the proximity of the viewcell has a larger weight! 
     2681                relContribution /=  
     2682                        SqrDistance(GetViewCellBox(viewcell).Center(), ray.mTermination); 
     2683 
    26772684#endif 
    26782685        } 
    2679    
     2686 
    26802687#if SUM_RAY_CONTRIBUTIONS || AVG_RAY_CONTRIBUTIONS 
    2681   ray.mRelativePvsContribution += relContribution; 
     2688        ray.mRelativePvsContribution += relContribution; 
    26822689#else 
    2683   // recalculate relative contribution - use max of Rel Contribution 
    2684   if (ray.mRelativePvsContribution < relContribution) 
    2685         ray.mRelativePvsContribution = relContribution; 
     2690        // recalculate relative contribution - use max of Rel Contribution 
     2691        if (ray.mRelativePvsContribution < relContribution) 
     2692                ray.mRelativePvsContribution = relContribution; 
    26862693#endif 
    26872694} 
     
    32873294  while (pit.HasMoreEntries()) 
    32883295  {              
    3289           ObjectPvsEntry entry = pit.Next(); 
    3290    
    3291           Intersectable *object = entry.mObject; 
    3292       object->Mail(); 
     3296      pit.Next()->Mail(); 
    32933297  } 
    32943298 
     
    33013305  {              
    33023306          // now go through the pvs again 
    3303           ObjectPvsEntry entry = pit2.Next(); 
    3304           Intersectable *object = entry.mObject; 
     3307          Intersectable *object = pit2.Next(); 
    33053308 
    33063309          //    Vector3 center = object->GetBox().Center(); 
     
    33853388          while (pit.HasMoreEntries())   
    33863389          { 
    3387                   ObjectPvsEntry entry = pit.Next(); 
    3388                   Intersectable *object = entry.mObject; 
    3389                   object->Mail(); 
     3390                  pit.Next()->Mail(); 
    33903391          } 
    33913392  } 
     
    34473448        ObjectContainer objects; 
    34483449         
     3450        PvsData pvsData; 
     3451 
    34493452        while (pit.HasMoreEntries()) {           
    3450           ObjectPvsEntry entry = pit.Next(); 
     3453          Intersectable *object = pit.Next(pvsData); 
    34513454           
    3452           Intersectable *object = entry.mObject; 
    34533455          // compute filter size based on the distance and the numebr of samples 
    34543456          AxisAlignedBox3 box = object->GetBox(); 
     
    34573459          float globalRadius = distance*globalC; 
    34583460           
    3459           int objectSamples = (int)entry.mData.mSumPdf; 
     3461          int objectSamples = (int)pvsData.mSumPdf; 
    34603462          float localRadius = MAX_FLOAT; 
    34613463           
     
    35253527  if (!mUseKdPvs) 
    35263528  { 
     3529          PvsData pvsData; 
     3530 
    35273531          // copy the base pvs to the new pvs 
    35283532          pit = basePvs.GetIterator(); 
    35293533          while (pit.HasMoreEntries())  
    35303534          {              
    3531                   ObjectPvsEntry entry = pit.Next(); 
    3532                   pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 
     3535                  Intersectable *obj = pit.Next(pvsData); 
     3536                  pvs.AddSampleDirty(obj, pvsData.mSumPdf); 
    35333537          } 
    35343538  } 
Note: See TracChangeset for help on using the changeset viewer.