Ignore:
Timestamp:
12/16/05 18:52:33 (19 years ago)
Author:
mattausch
Message:

updated view cells, view cell manager. changed rendersimulator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r466 r469  
    324324                 
    325325                leaf->SetViewCell(viewCell); 
    326                 viewCell->mBspLeaves.push_back(leaf); 
     326                viewCell->mLeaves.push_back(leaf); 
    327327 
    328328                //-- add pvs 
     
    12621262                                        stat.minPvs = pvsSize; 
    12631263 
    1264                                 if ((int)viewCell->mBspLeaves.size() > stat.maxLeaves) 
    1265                                         stat.maxLeaves = (int)viewCell->mBspLeaves.size();               
     1264                                if ((int)viewCell->mLeaves.size() > stat.maxLeaves) 
     1265                                        stat.maxLeaves = (int)viewCell->mLeaves.size();          
    12661266                        } 
    12671267                } 
     
    14611461void VspBspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &vcGeom) const 
    14621462{ 
    1463         vector<BspLeaf *> leaves = vc->mBspLeaves; 
     1463        vector<BspLeaf *> leaves = vc->mLeaves; 
    14641464 
    14651465        vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); 
     
    17121712 
    17131713 
    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; 
     1714int VspBspTree::CastLineSegment(const Vector3 &origin, 
     1715                                                                const Vector3 &termination, 
     1716                                                                vector<ViewCell *> &viewcells) 
     1717{ 
     1718        int hits = 0; 
     1719        stack<BspRayTraversalData> tStack; 
    17221720   
    1723   float mint = 0.0f, maxt = 1.0f; 
     1721        float mint = 0.0f, maxt = 1.0f; 
    17241722   
    1725   Intersectable::NewMail(); 
     1723        Intersectable::NewMail(); 
    17261724   
    1727   Vector3 entp = origin; 
    1728   Vector3 extp = termination; 
     1725        Vector3 entp = origin; 
     1726        Vector3 extp = termination; 
    17291727   
    1730   BspNode *node = mRoot; 
    1731   BspNode *farChild = NULL; 
     1728        BspNode *node = mRoot; 
     1729        BspNode *farChild = NULL; 
    17321730   
    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); 
    17361736           
    1737           Plane3 splitPlane = in->GetPlane(); 
    1738           const int entSide = splitPlane.Side(entp); 
    1739           const int extSide = splitPlane.Side(extp); 
     1737                        Plane3 splitPlane = in->GetPlane(); 
     1738                        const int entSide = splitPlane.Side(entp); 
     1739                        const int extSide = splitPlane.Side(extp); 
    17401740           
    1741           if (entSide < 0) { 
    1742                 node = in->GetBack(); 
    1743                  
    1744                 if(extSide <= 0) // plane does not split ray => no far child 
    1745                   continue; 
    1746                  
    1747                 farChild = in->GetFront(); // plane splits ray 
    1748                  
    1749           } else 
    1750                 if (entSide > 0) { 
    1751                   node = in->GetFront(); 
     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(); 
    17521752                   
    1753                   if (extSide >= 0) // plane does not split ray => no far child 
    1754                         continue; 
     1753                                if (extSide >= 0) // plane does not split ray => no far child 
     1754                                        continue; 
    17551755                   
    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                   } 
     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                        } 
    17651765           
    1766           // push data for far child 
    1767           tStack.push(BspRayTraversalData(farChild, extp, maxt)); 
     1766                        // push data for far child 
     1767                        tStack.push(BspRayTraversalData(farChild, extp, maxt)); 
    17681768           
    1769           // find intersection of ray segment with plane 
    1770           float t; 
    1771           extp = splitPlane.FindIntersection(origin, extp, &t); 
    1772           maxt *= t; 
     1769                        // find intersection of ray segment with plane 
     1770                        float t; 
     1771                        extp = splitPlane.FindIntersection(origin, extp, &t); 
     1772                        maxt *= t; 
    17731773           
    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); 
    17771778           
    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                        } 
    17831785           
    1784           //-- fetch the next far child from the stack 
    1785           if (tStack.empty()) 
    1786                 break; 
     1786                        //-- fetch the next far child from the stack 
     1787                        if (tStack.empty()) 
     1788                                break; 
    17871789       
    1788           entp = extp; 
    1789           mint = maxt; // NOTE: need this? 
     1790                        entp = extp; 
     1791                        mint = maxt; // NOTE: need this? 
    17901792           
    1791           BspRayTraversalData &s = tStack.top(); 
     1793                         
     1794                        BspRayTraversalData &s = tStack.top(); 
     1795             
     1796                        node = s.mNode; 
     1797                        extp = s.mExitPoint; 
     1798                        maxt = s.mMaxT; 
    17921799           
    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.