Changeset 2117 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 02/15/07 13:19:17 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2116 r2117 681 681 if (mUseKdPvs) 682 682 { 683 KdNode *node = GetPreprocessor()->mKdTree->GetPvsNode(isTermination ?684 683 KdNode *node = GetPreprocessor()-> 684 mKdTree->GetPvsNode(isTermination ? ray.mTermination : ray.mOrigin); 685 685 return GetPreprocessor()->mKdTree->GetOrCreateKdIntersectable(node); 686 686 } … … 1278 1278 1279 1279 ViewCellContainer viewCells; 1280 1280 1281 cout << "objects size: " << ObjectPvsIterator::sObjects.size() << endl; 1282 cout << "pvs size: " << ObjectPvs::sPvsSize << endl; 1283 1281 1284 // $$ JB hack - the collect best viewcells does not work? 1282 1285 #if 0 … … 2612 2615 2613 2616 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 } 2617 void 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 2625 2629 2626 2630 void ViewCellsManager::ComputeViewCellContribution(ViewCell *viewCell, … … 2630 2634 const bool addSamplesToPvs) 2631 2635 { 2632 2633 2636 // check if we are outside of view space 2637 // $$JB tmp commented to speedup up computations 2634 2638 #if 0 2635 2636 return;2639 if (!obj || !viewCell->GetValid()) 2640 return; 2637 2641 #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(); 2666 2673 2667 2674 #if CONTRIBUTION_RELATIVE_TO_PVS_SIZE 2668 relContribution /= viewcell->GetPvs().GetSize();2675 relContribution /= viewcell->GetPvs().GetSize(); 2669 2676 #endif 2670 2677 2671 2678 #if DIST_WEIGHTED_CONTRIBUTION 2672 // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the2673 // object-> a new contribution in the proximity of the viewcell has a larger weight!2674 relContribution /= SqrDistance(GetViewCellBox(viewcell).Center(),2675 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 2677 2684 #endif 2678 2685 } 2679 2686 2680 2687 #if SUM_RAY_CONTRIBUTIONS || AVG_RAY_CONTRIBUTIONS 2681 2688 ray.mRelativePvsContribution += relContribution; 2682 2689 #else 2683 2684 2685 ray.mRelativePvsContribution = relContribution;2690 // recalculate relative contribution - use max of Rel Contribution 2691 if (ray.mRelativePvsContribution < relContribution) 2692 ray.mRelativePvsContribution = relContribution; 2686 2693 #endif 2687 2694 } … … 3287 3294 while (pit.HasMoreEntries()) 3288 3295 { 3289 ObjectPvsEntry entry = pit.Next(); 3290 3291 Intersectable *object = entry.mObject; 3292 object->Mail(); 3296 pit.Next()->Mail(); 3293 3297 } 3294 3298 … … 3301 3305 { 3302 3306 // now go through the pvs again 3303 ObjectPvsEntry entry = pit2.Next(); 3304 Intersectable *object = entry.mObject; 3307 Intersectable *object = pit2.Next(); 3305 3308 3306 3309 // Vector3 center = object->GetBox().Center(); … … 3385 3388 while (pit.HasMoreEntries()) 3386 3389 { 3387 ObjectPvsEntry entry = pit.Next(); 3388 Intersectable *object = entry.mObject; 3389 object->Mail(); 3390 pit.Next()->Mail(); 3390 3391 } 3391 3392 } … … 3447 3448 ObjectContainer objects; 3448 3449 3450 PvsData pvsData; 3451 3449 3452 while (pit.HasMoreEntries()) { 3450 ObjectPvsEntry entry = pit.Next();3453 Intersectable *object = pit.Next(pvsData); 3451 3454 3452 Intersectable *object = entry.mObject;3453 3455 // compute filter size based on the distance and the numebr of samples 3454 3456 AxisAlignedBox3 box = object->GetBox(); … … 3457 3459 float globalRadius = distance*globalC; 3458 3460 3459 int objectSamples = (int) entry.mData.mSumPdf;3461 int objectSamples = (int)pvsData.mSumPdf; 3460 3462 float localRadius = MAX_FLOAT; 3461 3463 … … 3525 3527 if (!mUseKdPvs) 3526 3528 { 3529 PvsData pvsData; 3530 3527 3531 // copy the base pvs to the new pvs 3528 3532 pit = basePvs.GetIterator(); 3529 3533 while (pit.HasMoreEntries()) 3530 3534 { 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); 3533 3537 } 3534 3538 }
Note: See TracChangeset
for help on using the changeset viewer.