Changeset 469 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
- Timestamp:
- 12/16/05 18:52:33 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r466 r469 324 324 325 325 leaf->SetViewCell(viewCell); 326 viewCell->m BspLeaves.push_back(leaf);326 viewCell->mLeaves.push_back(leaf); 327 327 328 328 //-- add pvs … … 1262 1262 stat.minPvs = pvsSize; 1263 1263 1264 if ((int)viewCell->m BspLeaves.size() > stat.maxLeaves)1265 stat.maxLeaves = (int)viewCell->m BspLeaves.size();1264 if ((int)viewCell->mLeaves.size() > stat.maxLeaves) 1265 stat.maxLeaves = (int)viewCell->mLeaves.size(); 1266 1266 } 1267 1267 } … … 1461 1461 void VspBspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &vcGeom) const 1462 1462 { 1463 vector<BspLeaf *> leaves = vc->m BspLeaves;1463 vector<BspLeaf *> leaves = vc->mLeaves; 1464 1464 1465 1465 vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); … … 1712 1712 1713 1713 1714 int 1715 VspBspTree::CastLineSegment(const Vector3 &origin, 1716 const Vector3 &termination, 1717 vector<ViewCell *> &viewcells 1718 ) 1719 { 1720 int hits = 0; 1721 stack<BspRayTraversalData> tStack; 1714 int VspBspTree::CastLineSegment(const Vector3 &origin, 1715 const Vector3 &termination, 1716 vector<ViewCell *> &viewcells) 1717 { 1718 int hits = 0; 1719 stack<BspRayTraversalData> tStack; 1722 1720 1723 1721 float mint = 0.0f, maxt = 1.0f; 1724 1722 1725 1723 Intersectable::NewMail(); 1726 1724 1727 1728 1725 Vector3 entp = origin; 1726 Vector3 extp = termination; 1729 1727 1730 1731 1728 BspNode *node = mRoot; 1729 BspNode *farChild = NULL; 1732 1730 1733 while (1) { 1734 if (!node->IsLeaf()) { 1735 BspInterior *in = dynamic_cast<BspInterior *>(node); 1731 while (1) 1732 { 1733 if (!node->IsLeaf()) 1734 { 1735 BspInterior *in = dynamic_cast<BspInterior *>(node); 1736 1736 1737 1738 1739 1737 Plane3 splitPlane = in->GetPlane(); 1738 const int entSide = splitPlane.Side(entp); 1739 const int extSide = splitPlane.Side(extp); 1740 1740 1741 if (entSide < 0) {1742 node = in->GetBack();1743 1744 if(extSide <= 0) // plane does not split ray => no far child1745 continue;1746 1747 farChild = in->GetFront(); // plane splits ray1748 1749 } else1750 if (entSide > 0){1751 1741 if (entSide < 0) 1742 { 1743 node = in->GetBack(); 1744 1745 if(extSide <= 0) // plane does not split ray => no far child 1746 continue; 1747 1748 farChild = in->GetFront(); // plane splits ray 1749 } else if (entSide > 0) 1750 { 1751 node = in->GetFront(); 1752 1752 1753 1754 continue;1753 if (extSide >= 0) // plane does not split ray => no far child 1754 continue; 1755 1755 1756 1757 }1758 else // ray and plane are coincident1759 1760 // WHAT TO DO IN THIS CASE ?1761 //break;1762 node = in->GetFront();1763 continue;1764 1756 farChild = in->GetBack(); // plane splits ray 1757 } 1758 else // ray and plane are coincident 1759 { 1760 // WHAT TO DO IN THIS CASE ? 1761 //break; 1762 node = in->GetFront(); 1763 continue; 1764 } 1765 1765 1766 1767 1766 // push data for far child 1767 tStack.push(BspRayTraversalData(farChild, extp, maxt)); 1768 1768 1769 1770 1771 1772 1769 // find intersection of ray segment with plane 1770 float t; 1771 extp = splitPlane.FindIntersection(origin, extp, &t); 1772 maxt *= t; 1773 1773 1774 } else { 1775 // reached leaf => intersection with view cell 1776 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 1774 } else 1775 { 1776 // reached leaf => intersection with view cell 1777 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 1777 1778 1778 if (!leaf->GetViewCell()->Mailed()) { 1779 viewcells.push_back(leaf->GetViewCell()); 1780 leaf->GetViewCell()->Mail(); 1781 hits++; 1782 } 1779 if (!leaf->GetViewCell()->Mailed()) 1780 { 1781 viewcells.push_back(leaf->GetViewCell()); 1782 leaf->GetViewCell()->Mail(); 1783 ++ hits; 1784 } 1783 1785 1784 1785 1786 break;1786 //-- fetch the next far child from the stack 1787 if (tStack.empty()) 1788 break; 1787 1789 1788 1789 1790 entp = extp; 1791 mint = maxt; // NOTE: need this? 1790 1792 1791 BspRayTraversalData &s = tStack.top(); 1793 1794 BspRayTraversalData &s = tStack.top(); 1795 1796 node = s.mNode; 1797 extp = s.mExitPoint; 1798 maxt = s.mMaxT; 1792 1799 1793 node = s.mNode; 1794 extp = s.mExitPoint; 1795 maxt = s.mMaxT; 1796 1797 tStack.pop(); 1798 } 1799 } 1800 return hits; 1801 } 1800 tStack.pop(); 1801 } 1802 } 1803 return hits; 1804 }
Note: See TracChangeset
for help on using the changeset viewer.