Changeset 1666 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 10/23/06 15:37:18 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1660 r1666 5512 5512 { 5513 5513 ViewCell *viewcell = *it; 5514 5514 5515 5515 if (viewcell->GetValid()) 5516 5516 { // if ray not outside of view space … … 5519 5519 if (ray.mTerminationObject) 5520 5520 { 5521 5522 5523 5524 5525 5526 5521 // todo: maybe not correct for kd node pvs 5522 Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 5523 5524 if (viewcell->GetPvs().GetSampleContribution(obj, 5525 ray.mPdf, 5526 contribution)) 5527 5527 { 5528 5528 ++ ray.mPvsContribution; 5529 5529 } 5530 5531 5530 5531 ray.mRelativePvsContribution += contribution; 5532 5532 } 5533 5534 // for directional sampling it is important to count only contributions5535 // made in one direction!5536 // the other contributions of this sample will be counted for the opposite ray!5533 5534 //-- for directional sampling it is important to count only contributions 5535 //-- made in one direction! 5536 //-- the other contributions of this sample will be counted for the opposite ray! 5537 5537 #if SAMPLE_ORIGIN_OBJECTS 5538 5538 if (ray.mOriginObject && 5539 5539 viewcell->GetPvs().GetSampleContribution(ray.mOriginObject, 5540 5541 5540 ray.mPdf, 5541 contribution)) 5542 5542 { 5543 5543 ++ ray.mPvsContribution; … … 5616 5616 5617 5617 5618 typedef priority_queue<ViewCell *, vector<ViewCell *>, 5619 myless<vector<ViewCell *>::value_type> > ViewCellsQueue; 5620 5621 typedef priority_queue<BvhNode *, vector<BvhNode *>, 5622 myless<vector<BvhNode *>::value_type> > ObjectsQueue; 5623 5624 void VspOspViewCellsManager::ExportStats(const string &mergeStats) 5625 { 5626 ofstream stats; 5627 stats.open(mergeStats.c_str()); 5628 5629 ObjectsQueue objectsQueue; 5630 ViewCellsQueue viewCellsQueue; 5631 5632 objectsQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 5633 viewCellsQueue.push(mViewCellsTree->GetRoot()); 5634 5635 int numViewCells = 1; 5636 5637 const AxisAlignedBox3 box = mViewSpaceBox; 5638 const float vol = box.GetVolume(); 5639 5640 const int rootPvs = mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 5641 const int rootEntries = mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 5642 5643 cout << "exporting stats ... " << endl; 5644 5645 float totalRenderCost, avgRenderCost, expectedCost; 5646 5647 float deviation = 0; 5648 int totalPvs = rootPvs; 5649 int entriesInPvs = rootEntries; 5650 5651 totalRenderCost = avgRenderCost = expectedCost = (float)rootPvs; 5652 5653 const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 5654 const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 5655 5656 ///////////// 5657 //-- first view cell 5658 5659 /* mViewCellsTree->UpdateStats(stats, 5660 0, 5661 numViewCells, 5662 0, 5663 totalRenderCost, 5664 rootPvs, 5665 expectedCost, 5666 avgRenderCost, 5667 deviation, 5668 totalPvs, 5669 entriesInPvs, 5670 memoryCost, 5671 0, 5672 mRoot->GetVolume()); 5673 */ 5674 5675 //-- go through tree in the order of render cost decrease 5676 //-- which is the same order as the view cells were merged 5677 //-- or the reverse order of subdivision for subdivision-only 5678 //-- view cell hierarchies. 5679 5680 while (!(objectsQueue.empty() && viewCellsQueue.empty())) 5681 { 5682 ViewCell *viewCell = viewCellsQueue.top(); 5683 BvhNode *bvhNode = objectsQueue.top(); 5684 5685 if (viewCell->GetMergeCost() < bvhNode->GetMergeCost()) 5686 { 5687 viewCellsQueue.pop(); 5688 /* 5689 if (!vc->IsLeaf()) 5690 { 5691 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 5692 5693 const int parentPvs = GetPvsSize(interior); 5694 const int parentPvsEntries = GetPvsEntries(interior); 5695 const float parentCost = (float)parentPvs * interior->GetVolume(); 5696 5697 float childCost = 0; 5698 int childPvs = 0; 5699 int childPvsEntries = 0; 5700 5701 -- numViewCells; 5702 5703 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 5704 5705 for (it = interior->mChildren.begin(); it != it_end; ++ it) 5706 { 5707 ViewCell *vc = *it; 5708 5709 const int pvsSize = GetPvsSize(vc); 5710 const int pvsEntries = GetPvsEntries(vc); 5711 5712 childCost += (float) pvsSize * vc->GetVolume(); 5713 childPvs += pvsSize; 5714 childPvsEntries += pvsEntries; 5715 5716 tqueue.push(vc); 5717 ++ numViewCells; 5718 } 5719 5720 // update stats for this view cell 5721 const float costDecr = (parentCost - childCost) / vol; 5722 5723 totalRenderCost -= costDecr; 5724 totalPvs += childPvs - parentPvs; 5725 entriesInPvs += childPvsEntries - parentPvsEntries; 5726 5727 expectedCost = totalRenderCost / (float)numViewCells; 5728 avgRenderCost = (float)totalPvs / (float)numViewCells; 5729 5730 const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 5731 const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 5732 5733 mViewCellsTree->UpdateStats(stats, 5734 0, 5735 numViewCells, 5736 costDecr, 5737 totalRenderCost, 5738 parentPvs, 5739 expectedCost, 5740 avgRenderCost, 5741 deviation, 5742 totalPvs, 5743 entriesInPvs, 5744 memoryCost, 5745 childPvs - parentPvs, 5746 vc->GetVolume()); 5747 */ 5748 } 5749 else // object space split 5750 { 5751 } 5752 } 5753 5754 stats.close(); 5755 } 5756 5757 5618 5758 #if TEST_EVALUATION 5619 5759 void VspOspViewCellsManager::EvalViewCellPartition() … … 5693 5833 cout << "finished" << endl; 5694 5834 5695 vector<int> storageFunc;5696 mViewCellsTree->GetStorageFunction(storageFunc);5697 5698 vector<float> costFunc;5699 mViewCellsTree->GetCostFunction(costFunc);5700 5701 ofstream outstr("out.txt");5702 5703 for (int i = 0; i < storageFunc.size(); ++ i)5704 outstr << i << ": " << storageFunc[i] << endl;5705 outstr << endl;5706 for (int i = 0; i < costFunc.size(); ++ i)5707 outstr << i << ": " << costFunc[i] << endl;5708 if (0)5709 for (int i = 0; i <50; ++ i)5710 {5711 Vector3 point = GetViewSpaceBox().GetRandomPoint();5712 ViewCell *vc = GetViewCell(point);5713 }5714 //RenderBvhNode(mHierarchyManager->mBvHierarchy->GetRoot());5715 5716 5835 disposeRays(evaluationSamples, NULL); 5717 5836 }
Note: See TracChangeset
for help on using the changeset viewer.