Changeset 608 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
- Timestamp:
- 02/08/06 20:32:42 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r607 r608 606 606 if (mViewCellsManager->EqualToSpatialNode(mergedVc)) 607 607 ++ mergeStats.siblings; 608 mergedVc->SetCost(realExpectedCost); 608 609 609 610 if (((mergeStats.merged % statsOut) == 0) || … … 664 665 ViewCellInterior *root = mViewCellsManager->MergeViewCells(activeViewCells); 665 666 root->SetMergeCost(totalRenderCost); 667 // $$JB keep this 0 temporarilly 668 root->SetCost(0.0f); 669 666 670 mRoot = root; 667 671 } … … 693 697 Debug << mergeStats << endl << endl; 694 698 695 699 // assign colors for the view cells so that at least one is always consistent 700 AssignRandomColors(); 696 701 //TODO: should return sample contributions? 697 702 return mergeStats.merged; … … 1533 1538 1534 1539 1540 void 1541 ViewCellsTree::AssignRandomColors() 1542 { 1543 TraversalQueue tqueue; 1544 tqueue.push(mRoot); 1545 mRoot->SetColor(RandomColor(0.3f, 1.0f)); 1546 while (!tqueue.empty()) 1547 { 1548 ViewCell *vc = tqueue.top(); 1549 1550 // save the view cells if it is a leaf or if enough view cells have already been traversed 1551 // because of the priority queue, this will be the optimal set of v 1552 if (!vc->IsLeaf()) { 1553 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1554 1555 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1556 float maxProbability = -1.0f; 1557 ViewCell *maxViewCell = NULL; 1558 for (it = interior->mChildren.begin(); it != it_end; ++ it) { 1559 ViewCell *v = *it; 1560 // set random color 1561 v->SetColor(RandomColor(0.3f, 1.0f)); 1562 if (v->GetVolume() > maxProbability) { 1563 maxProbability = v->GetVolume(); 1564 maxViewCell = v; 1565 } 1566 maxViewCell->SetColor(vc->GetColor()); 1567 tqueue.push(v); 1568 } 1569 1570 } 1571 1572 tqueue.pop(); 1573 } 1574 } 1575 1576 /** Get costs resulting from each merge step. */ 1577 void 1578 ViewCellsTree::GetCostFunction(vector<float> &costFunction) 1579 { 1580 TraversalQueue tqueue; 1581 tqueue.push(mRoot); 1582 while (!tqueue.empty()) { 1583 ViewCell *vc = tqueue.top(); 1584 1585 // save the view cells if it is a leaf or if enough view cells have already been traversed 1586 // because of the priority queue, this will be the optimal set of v 1587 if (!vc->IsLeaf()) { 1588 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1589 costFunction.push_back(interior->GetCost()); 1590 1591 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1592 1593 for (it = interior->mChildren.begin(); it != it_end; ++ it) { 1594 tqueue.push(*it); 1595 } 1596 1597 } 1598 1599 tqueue.pop(); 1600 } 1601 } 1602 1603 1535 1604 void ViewCellsTree::UpdateViewCellsStats(ViewCell *vc, ViewCellsStatistics &vcStat) 1536 1605 {
Note: See TracChangeset
for help on using the changeset viewer.