Changeset 1008


Ignore:
Timestamp:
06/09/06 09:07:40 (18 years ago)
Author:
mattausch
Message:

worked on vsp osp tree. warning: does not compile

Location:
GTP/trunk/Lib/Vis
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r1006 r1008  
    259259public: 
    260260  signals: 
    261         UpdatePvsErrorItem(int i, 
    262                                            GlRendererBuffer::PvsErrorEntry &); 
     261        void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 
    263262}; 
    264263 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1006 r1008  
    88#include "Material.h" 
    99#include "gzstream.h" 
    10  
     10#include "VspOspTree.h" 
    1111 
    1212namespace GtpVisibilityPreprocessor { 
     
    1717class BspPvs; 
    1818class BspLeaf; 
    19 class VspKdLeaf; 
     19class VspLeaf; 
    2020class KdLeaf; 
    2121class ViewCellInterior; 
     
    9797        friend class ViewCellsTree; 
    9898        friend class ViewCellsManager; 
    99         //friend class VspBspViewCellsManager; 
    100         //friend class BspViewCellsManager; 
    101         //friend class VspBspTree; 
    102         //friend class FromPointVisibilityTree; 
    103         //friend class BspTree; 
    104  
    10599 
    106100public: 
     
    380374 
    381375 
     376//typedef HierarchyLeafViewCell<VspLeaf *> VspViewCell; 
    382377typedef HierarchyLeafViewCell<BspLeaf *> BspViewCell; 
    383378typedef HierarchyLeafViewCell<KdLeaf *> KdViewCell; 
    384 typedef HierarchyLeafViewCell<VspKdLeaf *> VspKdViewCell; 
     379 
    385380 
    386381 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r1006 r1008  
    410410}; 
    411411 
     412 
    412413/** Implementation of the view cell BSP tree.  
    413414*/ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1006 r1008  
    4646 
    4747 
     48int VspNode::sMailId = 1; 
     49 
     50 
     51/******************************************************************/ 
     52/*                  class VspNode implementation                  */ 
     53/******************************************************************/ 
     54 
     55 
     56VspNode::VspNode():  
     57mParent(NULL), mTreeValid(true), mTimeStamp(0) 
     58{} 
     59 
     60 
     61VspNode::VspNode(VspInterior *parent):  
     62mParent(parent), mTreeValid(true) 
     63{} 
     64 
     65 
     66bool VspNode::IsRoot() const  
     67{ 
     68        return mParent == NULL; 
     69} 
     70 
     71 
     72VspInterior *VspNode::GetParent()  
     73{  
     74        return mParent;  
     75} 
     76 
     77 
     78void VspNode::SetParent(VspInterior *parent) 
     79{ 
     80        mParent = parent; 
     81} 
     82 
     83 
     84bool VspNode::IsSibling(VspNode *n) const 
     85{ 
     86        return  ((this != n) && mParent &&  
     87                         (mParent->GetFront() == n) || (mParent->GetBack() == n)); 
     88} 
     89 
     90 
     91int VspNode::GetDepth() const 
     92{ 
     93        int depth = 0; 
     94        VspNode *p = mParent; 
     95         
     96        while (p) 
     97        { 
     98                p = p->mParent; 
     99                ++ depth; 
     100        } 
     101 
     102        return depth; 
     103} 
     104 
     105 
     106bool VspNode::TreeValid() const 
     107{ 
     108        return mTreeValid; 
     109} 
     110 
     111 
     112void VspNode::SetTreeValid(const bool v) 
     113{ 
     114        mTreeValid = v; 
     115} 
     116 
     117 
     118/****************************************************************/ 
     119/*              class VspInterior implementation                */ 
     120/****************************************************************/ 
     121 
     122 
     123VspInterior::VspInterior(const AxisAlignedPlane &plane):  
     124mPlane(plane), mFront(NULL), mBack(NULL) 
     125{} 
     126 
     127VspInterior::~VspInterior()  
     128{  
     129        DEL_PTR(mFront);  
     130        DEL_PTR(mBack); 
     131} 
     132 
     133bool VspInterior::IsLeaf() const 
     134{  
     135        return false;  
     136} 
     137 
     138VspNode *VspInterior::GetBack()  
     139{ 
     140        return mBack; 
     141} 
     142 
     143VspNode *VspInterior::GetFront()  
     144{ 
     145        return mFront; 
     146} 
     147 
     148AxisAlignedPlane VspInterior::GetPlane() const 
     149{ 
     150        return mPlane; 
     151} 
     152 
     153void VspInterior::ReplaceChildLink(VspNode *oldChild, VspNode *newChild)  
     154{ 
     155        if (mBack == oldChild) 
     156                mBack = newChild; 
     157        else 
     158                mFront = newChild; 
     159} 
     160 
     161void VspInterior::SetupChildLinks(VspNode *b, VspNode *f)  
     162{ 
     163    mBack = b; 
     164    mFront = f; 
     165} 
     166 
     167 
     168/****************************************************************/ 
     169/*                  class VspLeaf implementation                */ 
     170/****************************************************************/ 
     171 
     172 
     173VspLeaf::VspLeaf(): mViewCell(NULL), mPvs(NULL) 
     174{ 
     175} 
     176 
     177 
     178VspLeaf::~VspLeaf() 
     179{ 
     180        DEL_PTR(mPvs); 
     181} 
     182 
     183 
     184VspLeaf::VspLeaf(ViewCellLeaf *viewCell):  
     185mViewCell(viewCell) 
     186{ 
     187} 
     188 
     189 
     190VspLeaf::VspLeaf(VspInterior *parent):  
     191VspNode(parent), mViewCell(NULL), mPvs(NULL) 
     192{} 
     193 
     194 
     195 
     196VspLeaf::VspLeaf(VspInterior *parent, ViewCellLeaf *viewCell):  
     197VspNode(parent), mViewCell(viewCell), mPvs(NULL) 
     198{ 
     199} 
     200 
     201ViewCellLeaf *VspLeaf::GetViewCell() const 
     202{ 
     203        return mViewCell; 
     204} 
     205 
     206void VspLeaf::SetViewCell(ViewCellLeaf *viewCell) 
     207{ 
     208        mViewCell = viewCell; 
     209} 
     210 
     211 
     212bool VspLeaf::IsLeaf() const  
     213{  
     214        return true;  
     215} 
    48216 
    49217 
     
    140308 
    141309 
    142 BspViewCell *VspOspTree::GetOutOfBoundsCell() 
     310VspViewCell *VspOspTree::GetOutOfBoundsCell() 
    143311{ 
    144312        return mOutOfBoundsCell; 
     
    146314 
    147315 
    148 BspViewCell *VspOspTree::GetOrCreateOutOfBoundsCell() 
     316VspViewCell *VspOspTree::GetOrCreateOutOfBoundsCell() 
    149317{ 
    150318        if (!mOutOfBoundsCell) 
    151319        { 
    152                 mOutOfBoundsCell = new BspViewCell(); 
     320                mOutOfBoundsCell = new VspViewCell(); 
    153321                mOutOfBoundsCell->SetId(-1); 
    154322                mOutOfBoundsCell->SetValid(false); 
     
    159327 
    160328 
    161 const BspTreeStatistics &VspOspTree::GetStatistics() const 
    162 { 
    163         return mBspStats; 
     329const VspTreeStatistics &VspOspTree::GetStatistics() const 
     330{ 
     331        return mVspStats; 
    164332} 
    165333 
     
    171339} 
    172340 
     341 
    173342void VspOspTree::Construct(const VssRayContainer &sampleRays, 
    174343                                                   AxisAlignedBox3 *forcedBoundingBox) 
    175344{ 
    176         mBspStats.nodes = 1; 
     345        mVspStats.nodes = 1; 
    177346        mBox.Initialize();      // initialise BSP tree bounding box 
    178347 
     
    231400        return (float) 
    232401                 (sizeof(VspOspTree) +  
    233                   mBspStats.Leaves() * sizeof(BspLeaf) +  
     402                  mVspStats.Leaves() * sizeof(VspLeaf) +  
    234403                  mCreatedViewCells * sizeof(BspViewCell) + 
    235                   mBspStats.pvs * sizeof(ObjectPvsData) + 
    236                   mBspStats.Interior() * sizeof(BspInterior) + 
    237                   mBspStats.accumRays * sizeof(RayInfo)) / (1024.0f * 1024.0f); 
     404                  mVspStats.pvs * sizeof(ObjectPvsData) + 
     405                  mVspStats.Interior() * sizeof(VspInterior) + 
     406                  mVspStats.accumRays * sizeof(RayInfo)) / (1024.0f * 1024.0f); 
    238407} 
    239408 
     
    243412        VspOspSplitQueue tQueue; 
    244413 
    245         mRoot = new BspLeaf(); 
     414        mRoot = new VspLeaf(); 
    246415 
    247416        const float prop = mBox.GetVolume(); 
     
    274443         
    275444         
    276         mBspStats.Start(); 
     445        mVspStats.Start(); 
    277446        cout << "Constructing vsp bsp tree ... \n"; 
    278447 
     
    313482 
    314483                // subdivide leaf node 
    315                 BspNode *r = Subdivide(tQueue, splitCandidate); 
     484                VspNode *r = Subdivide(tQueue, splitCandidate); 
    316485 
    317486                if (r == mRoot) 
     
    319488                                  << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    320489 
    321                 if (mBspStats.Leaves() >= nLeaves) 
     490                if (mVspStats.Leaves() >= nLeaves) 
    322491                { 
    323492                        nLeaves += 500; 
    324493 
    325                         cout << "leaves=" << mBspStats.Leaves() << endl; 
     494                        cout << "leaves=" << mVspStats.Leaves() << endl; 
    326495                        Debug << "needed " 
    327496                                  << TimeDiff(interTime, GetTime())*1e-3  
     
    341510        cout << "finished\n"; 
    342511 
    343         mBspStats.Stop(); 
     512        mVspStats.Stop(); 
    344513} 
    345514 
     
    360529        return 
    361530                (mOutOfMemory  
    362                 || (mBspStats.Leaves() >= mMaxViewCells)  
     531                || (mVspStats.Leaves() >= mMaxViewCells)  
    363532                || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    364533                 ); 
     
    367536 
    368537// subdivide using a split plane queue 
    369 BspNode *VspOspTree::Subdivide(VspOspSplitQueue &tQueue, 
     538VspNode *VspOspTree::Subdivide(VspOspSplitQueue &tQueue, 
    370539                                                           VspOspSplitCandidate &splitCandidate) 
    371540{ 
    372541        VspOspTraversalData &tData = splitCandidate.mParentData; 
    373542 
    374         BspNode *newNode = tData.mNode; 
     543        VspNode *newNode = tData.mNode; 
    375544 
    376545        if (!LocalTerminationCriteriaMet(tData) && !GlobalTerminationCriteriaMet(tData)) 
     
    382551                 
    383552                // create new interior node and two leaf node 
    384                 //TODO 
    385                 const Plane3 splitPlane;// = splitCandidate.mSplitPlane; 
    386                                  
     553                const AxisAlignedPlane splitPlane = splitCandidate.mSplitPlane; 
     554 
    387555                newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData); 
    388556         
     
    409577 
    410578                        mSubdivisionStats  
    411                                         << "#ViewCells\n" << mBspStats.Leaves() << endl 
     579                                        << "#ViewCells\n" << mVspStats.Leaves() << endl 
    412580                                        << "#RenderCostDecrease\n" << -costDecr << endl 
    413581                                        << "#SplitCandidateCost\n" << splitCandidate.GetCost() << endl 
    414582                                        << "#TotalRenderCost\n" << mTotalCost << endl 
    415                                         << "#AvgRenderCost\n" << (float)mTotalPvsSize / (float)mBspStats.Leaves() << endl; 
     583                                        << "#AvgRenderCost\n" << (float)mTotalPvsSize / (float)mVspStats.Leaves() << endl; 
    416584                } 
    417585 
     
    435603        if (newNode->IsLeaf()) 
    436604        { 
    437                 BspLeaf *leaf = dynamic_cast<BspLeaf *>(newNode); 
     605                VspLeaf *leaf = dynamic_cast<VspLeaf *>(newNode); 
    438606                BspViewCell *viewCell = new BspViewCell(); 
    439607 
     
    448616                mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().GetSize()); 
    449617 
    450                 mBspStats.contributingSamples += conSamp; 
    451                 mBspStats.sampleContributions +=(int) sampCon; 
     618                mVspStats.contributingSamples += conSamp; 
     619                mVspStats.sampleContributions +=(int) sampCon; 
    452620 
    453621                //-- store additional info 
     
    484652        VspOspTraversalData backData; 
    485653 
    486         BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
     654        VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 
    487655 
    488656        // compute locally best split plane 
    489         // TODO 
    490     const bool success =0;/// SelectPlane(splitData.mSplitPlane, tData,  
    491 //                                                                       frontData, backData); 
     657        const bool success =  
     658                SelectPlane(tData, splitData.mSplitPlane, 
     659                                        frontData.mProbability, backData.mProbability); 
     660 
    492661        //TODO 
    493662        // compute global decrease in render cost 
    494         splitData.mRenderCost = 0;//EvalRenderCostDecrease(splitData.mSplitPlane, tData); 
     663        splitData.mRenderCost = EvalRenderCostDecrease(splitData.mSplitPlane, tData); 
    495664        splitData.mParentData = tData; 
    496665        splitData.mMaxCostMisses = success ? tData.mMaxCostMisses : tData.mMaxCostMisses + 1; 
     
    498667 
    499668 
    500 BspInterior *VspOspTree::SubdivideNode(const Plane3 &splitPlane, 
     669VspInterior *VspOspTree::SubdivideNode(const AxisAlignedPlane &splitPlane, 
    501670                                                                           VspOspTraversalData &tData, 
    502671                                                                           VspOspTraversalData &frontData, 
    503672                                                                           VspOspTraversalData &backData) 
    504673{ 
    505         BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
     674        VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 
    506675         
    507676        //-- the front and back traversal data is filled with the new values 
     
    514683 
    515684        //-- subdivide rays 
     685#if TODO         
    516686        SplitRays(splitPlane, 
    517687                          *tData.mRays, 
    518688                          *frontData.mRays, 
    519689                          *backData.mRays); 
    520  
     690#endif 
    521691 
    522692        // compute pvs 
     
    543713 
    544714        // store maximal and minimal depth 
    545         if (tData.mDepth > mBspStats.maxDepth) 
    546         { 
    547                 Debug << "max depth increases to " << tData.mDepth << " at " << mBspStats.Leaves() << " leaves" << endl; 
    548                 mBspStats.maxDepth = tData.mDepth; 
    549         } 
    550  
    551         mBspStats.nodes += 2; 
     715        if (tData.mDepth > mVspStats.maxDepth) 
     716        { 
     717                Debug << "max depth increases to " << tData.mDepth << " at " << mVspStats.Leaves() << " leaves" << endl; 
     718                mVspStats.maxDepth = tData.mDepth; 
     719        } 
     720 
     721        mVspStats.nodes += 2; 
    552722 
    553723     
    554         BspInterior *interior = new BspInterior(splitPlane); 
     724        VspInterior *interior = new VspInterior(splitPlane); 
    555725 
    556726#ifdef _DEBUG 
     
    561731        //-- create front and back leaf 
    562732 
    563         BspInterior *parent = leaf->GetParent(); 
     733        VspInterior *parent = leaf->GetParent(); 
    564734 
    565735        // replace a link from node's parent 
     
    575745 
    576746        // and setup child links 
    577         interior->SetupChildLinks(new BspLeaf(interior), new BspLeaf(interior)); 
     747        interior->SetupChildLinks(new VspLeaf(interior), new VspLeaf(interior)); 
    578748 
    579749        frontData.mNode = interior->GetFront(); 
     
    586756 
    587757 
    588 void VspOspTree::AddToPvs(BspLeaf *leaf, 
     758void VspOspTree::AddToPvs(VspLeaf *leaf, 
    589759                                                  const RayInfoContainer &rays, 
    590760                                                  float &sampleContributions, 
     
    9461116 
    9471117 
    948 float VspOspTree::EvalRenderCostDecrease(const Plane3 &candidatePlane, 
     1118float VspOspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 
    9491119                                                                                 const VspOspTraversalData &data) const 
    9501120{ 
     
    9681138                float t; 
    9691139                VssRay *ray = rayInf.mRay; 
    970                 const int cf = rayInf.ComputeRayIntersection(candidatePlane, t); 
     1140                const int cf =  
     1141                        rayInf.ComputeRayIntersection(candidatePlane.mAxis,  
     1142                                                                                  candidatePlane.mPosition, t); 
    9711143 
    9721144                // find front and back pvs for origing and termination object 
     
    11161288 
    11171289 
    1118 void VspOspTree::CollectLeaves(vector<BspLeaf *> &leaves,  
     1290void VspOspTree::CollectLeaves(vector<VspLeaf *> &leaves,  
    11191291                                                           const bool onlyUnmailed, 
    11201292                                                           const int maxPvsSize) const 
    11211293{ 
    1122         stack<BspNode *> nodeStack; 
     1294        stack<VspNode *> nodeStack; 
    11231295        nodeStack.push(mRoot); 
    11241296 
    11251297        while (!nodeStack.empty()) 
    11261298        { 
    1127                 BspNode *node = nodeStack.top(); 
     1299                VspNode *node = nodeStack.top(); 
    11281300                nodeStack.pop(); 
    11291301                 
     
    11311303                { 
    11321304                        // test if this leaf is in valid view space 
    1133                         BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     1305                        VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
    11341306                        if (leaf->TreeValid() &&  
    11351307                                (!onlyUnmailed || !leaf->Mailed()) && 
     
    11411313                else 
    11421314                { 
    1143                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     1315                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    11441316 
    11451317                        nodeStack.push(interior->GetBack()); 
     
    11561328 
    11571329 
    1158 BspNode *VspOspTree::GetRoot() const 
     1330VspNode *VspOspTree::GetRoot() const 
    11591331{ 
    11601332        return mRoot; 
     
    11651337{ 
    11661338        // the node became a leaf -> evaluate stats for leafs 
    1167         BspLeaf *leaf = dynamic_cast<BspLeaf *>(data.mNode); 
    1168  
    1169  
    1170         if (data.mPvs > mBspStats.maxPvs) 
    1171         { 
    1172                 mBspStats.maxPvs = data.mPvs; 
    1173         } 
    1174  
    1175         mBspStats.pvs += data.mPvs; 
    1176  
    1177         if (data.mDepth < mBspStats.minDepth) 
    1178         { 
    1179                 mBspStats.minDepth = data.mDepth; 
     1339        VspLeaf *leaf = dynamic_cast<VspLeaf *>(data.mNode); 
     1340 
     1341 
     1342        if (data.mPvs > mVspStats.maxPvs) 
     1343        { 
     1344                mVspStats.maxPvs = data.mPvs; 
     1345        } 
     1346 
     1347        mVspStats.pvs += data.mPvs; 
     1348 
     1349        if (data.mDepth < mVspStats.minDepth) 
     1350        { 
     1351                mVspStats.minDepth = data.mDepth; 
    11801352        } 
    11811353         
    11821354        if (data.mDepth >= mTermMaxDepth) 
    11831355        { 
    1184         ++ mBspStats.maxDepthNodes; 
    1185                 //Debug << "new max depth: " << mBspStats.maxDepthNodes << endl; 
     1356        ++ mVspStats.maxDepthNodes; 
     1357                //Debug << "new max depth: " << mVspStats.maxDepthNodes << endl; 
    11861358        } 
    11871359 
    11881360        // accumulate rays to compute rays /  leaf 
    1189         mBspStats.accumRays += (int)data.mRays->size(); 
     1361        mVspStats.accumRays += (int)data.mRays->size(); 
    11901362 
    11911363        if (data.mPvs < mTermMinPvs) 
    1192                 ++ mBspStats.minPvsNodes; 
     1364                ++ mVspStats.minPvsNodes; 
    11931365 
    11941366        if ((int)data.mRays->size() < mTermMinRays) 
    1195                 ++ mBspStats.minRaysNodes; 
     1367                ++ mVspStats.minRaysNodes; 
    11961368 
    11971369        if (data.GetAvgRayContribution() > mTermMaxRayContribution) 
    1198                 ++ mBspStats.maxRayContribNodes; 
     1370                ++ mVspStats.maxRayContribNodes; 
    11991371 
    12001372        if (data.mProbability <= mTermMinProbability) 
    1201                 ++ mBspStats.minProbabilityNodes; 
     1373                ++ mVspStats.minProbabilityNodes; 
    12021374         
    12031375        // accumulate depth to compute average depth 
    1204         mBspStats.accumDepth += data.mDepth; 
     1376        mVspStats.accumDepth += data.mDepth; 
    12051377 
    12061378        ++ mCreatedViewCells; 
     
    12211393{ 
    12221394        int hits = 0; 
    1223  
     1395#if TODO 
    12241396        stack<BspRayTraversalData> tQueue; 
    12251397 
     
    12341406        Vector3 extp = ray.Extrap(maxt); 
    12351407 
    1236         BspNode *node = mRoot; 
    1237         BspNode *farChild = NULL; 
     1408        VspNode *node = mRoot; 
     1409        VspNode *farChild = NULL; 
    12381410 
    12391411        while (1) 
     
    12411413                if (!node->IsLeaf()) 
    12421414                { 
    1243                         BspInterior *in = dynamic_cast<BspInterior *>(node); 
     1415                        VspInterior *in = dynamic_cast<VspInterior *>(node); 
    12441416 
    12451417                        Plane3 splitPlane = in->GetPlane(); 
     
    12741446 
    12751447                        // push data for far child 
    1276                         tQueue.push(BspRayTraversalData(farChild, extp, maxt)); 
     1448                        tQueue.push(VspRayTraversalData(farChild, extp, maxt)); 
    12771449 
    12781450                        // find intersection of ray segment with plane 
     
    12831455                } else // reached leaf => intersection with view cell 
    12841456                { 
    1285                         BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     1457                        VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
    12861458 
    12871459                        if (!leaf->GetViewCell()->Mailed()) 
     
    13111483                } 
    13121484        } 
    1313  
     1485#endif 
    13141486        return hits; 
    13151487} 
     
    13281500// TODO 
    13291501#if HAS_TO_BE_REDONE 
    1330         stack<BspNode *> nodeStack; 
     1502        stack<VspNode *> nodeStack; 
    13311503 
    13321504        if (!mRoot) 
     
    13371509        while (!nodeStack.empty())  
    13381510        { 
    1339                 BspNode *node = nodeStack.top(); 
     1511                VspNode *node = nodeStack.top(); 
    13401512                nodeStack.pop(); 
    13411513                 
    13421514                if (node->IsLeaf()) 
    13431515        { 
    1344                         BspViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 
     1516                        BspViewCell *viewCell = dynamic_cast<VspLeaf *>(node)->GetViewCell(); 
    13451517 
    13461518                        if (!viewCell->GetValid()) 
    13471519                        { 
    1348                                 BspViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 
     1520                                BspViewCell *viewCell = dynamic_cast<VspLeaf *>(node)->GetViewCell(); 
    13491521         
    13501522                                ViewCellContainer leaves; 
     
    13551527                                for (it = leaves.begin(); it != it_end; ++ it) 
    13561528                                { 
    1357                                         BspLeaf *l = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
     1529                                        VspLeaf *l = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
    13581530                                        l->SetViewCell(GetOrCreateOutOfBoundsCell()); 
    1359                                         ++ mBspStats.invalidLeaves; 
     1531                                        ++ mVspStats.invalidLeaves; 
    13601532                                } 
    13611533 
     
    13671539                else 
    13681540                { 
    1369                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     1541                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    13701542                 
    13711543                        nodeStack.push(interior->GetFront()); 
     
    13741546        } 
    13751547 
    1376         Debug << "invalid leaves: " << mBspStats.invalidLeaves << endl; 
     1548        Debug << "invalid leaves: " << mVspStats.invalidLeaves << endl; 
    13771549#endif 
    13781550} 
     
    13811553void VspOspTree::CollectRays(VssRayContainer &rays) 
    13821554{ 
    1383         vector<BspLeaf *> leaves; 
    1384  
    1385         vector<BspLeaf *>::const_iterator lit, lit_end = leaves.end(); 
     1555        vector<VspLeaf *> leaves; 
     1556 
     1557        vector<VspLeaf *>::const_iterator lit, lit_end = leaves.end(); 
    13861558 
    13871559        for (lit = leaves.begin(); lit != lit_end; ++ lit) 
    13881560        { 
    1389                 BspLeaf *leaf = *lit; 
     1561                VspLeaf *leaf = *lit; 
    13901562                VssRayContainer::const_iterator rit, rit_end = leaf->mVssRays.end(); 
    13911563 
     
    13981570void VspOspTree::ValidateTree() 
    13991571{ 
    1400         stack<BspNode *> nodeStack; 
     1572        stack<VspNode *> nodeStack; 
    14011573 
    14021574        if (!mRoot) 
     
    14051577        nodeStack.push(mRoot); 
    14061578         
    1407         mBspStats.invalidLeaves = 0; 
     1579        mVspStats.invalidLeaves = 0; 
    14081580        while (!nodeStack.empty())  
    14091581        { 
    1410                 BspNode *node = nodeStack.top(); 
     1582                VspNode *node = nodeStack.top(); 
    14111583                nodeStack.pop(); 
    14121584                 
    14131585                if (node->IsLeaf()) 
    14141586                { 
    1415                         BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     1587                        VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
    14161588 
    14171589                        if (!leaf->GetViewCell()->GetValid()) 
    1418                                 ++ mBspStats.invalidLeaves; 
     1590                                ++ mVspStats.invalidLeaves; 
    14191591 
    14201592                        // validity flags don't match => repair 
     
    14271599                else 
    14281600                { 
    1429                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     1601                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    14301602                 
    14311603                        nodeStack.push(interior->GetFront()); 
     
    14341606        } 
    14351607 
    1436         Debug << "invalid leaves: " << mBspStats.invalidLeaves << endl; 
    1437 } 
    1438  
    1439  
    1440  
    1441 void VspOspTree::CollectViewCells(BspNode *root, 
     1608        Debug << "invalid leaves: " << mVspStats.invalidLeaves << endl; 
     1609} 
     1610 
     1611 
     1612 
     1613void VspOspTree::CollectViewCells(VspNode *root, 
    14421614                                                                  bool onlyValid, 
    14431615                                                                  ViewCellContainer &viewCells, 
    14441616                                                                  bool onlyUnmailed) const 
    14451617{ 
    1446         stack<BspNode *> nodeStack; 
     1618        stack<VspNode *> nodeStack; 
    14471619 
    14481620        if (!root) 
     
    14531625        while (!nodeStack.empty())  
    14541626        { 
    1455                 BspNode *node = nodeStack.top(); 
     1627                VspNode *node = nodeStack.top(); 
    14561628                nodeStack.pop(); 
    14571629                 
     
    14601632                        if (!onlyValid || node->TreeValid()) 
    14611633                        { 
    1462                                 ViewCellLeaf *leafVc = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 
     1634                                ViewCellLeaf *leafVc = dynamic_cast<VspLeaf *>(node)->GetViewCell(); 
    14631635 
    14641636                                ViewCell *viewCell = mViewCellsTree->GetActiveViewCell(leafVc); 
     
    14731645                else 
    14741646                { 
    1475                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     1647                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    14761648                 
    14771649                        nodeStack.push(interior->GetFront()); 
     
    15381710 
    15391711 
    1540 int VspOspTree::FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors, 
     1712int VspOspTree::FindNeighbors(VspNode *n, vector<VspLeaf *> &neighbors, 
    15411713                                                          const bool onlyUnmailed) const 
    15421714{ 
     
    15461718 
    15471719 
    1548 BspLeaf *VspOspTree::GetRandomLeaf(const Plane3 &halfspace) 
     1720VspLeaf *VspOspTree::GetRandomLeaf(const Plane3 &halfspace) 
    15491721{ 
    15501722#if TODO 
    1551     stack<BspNode *> nodeStack; 
     1723    stack<VspNode *> nodeStack; 
    15521724        nodeStack.push(mRoot); 
    15531725 
     
    15561728        while (!nodeStack.empty()) 
    15571729        { 
    1558                 BspNode *node = nodeStack.top(); 
     1730                VspNode *node = nodeStack.top(); 
    15591731                nodeStack.pop(); 
    15601732 
    15611733                if (node->IsLeaf()) 
    15621734                { 
    1563                         return dynamic_cast<BspLeaf *>(node); 
     1735                        return dynamic_cast<VspLeaf *>(node); 
    15641736                } 
    15651737                else 
    15661738                { 
    1567                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    1568                         BspNode *next; 
     1739                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
     1740                        VspNode *next; 
    15691741                        BspNodeGeometry geom; 
    15701742 
     
    15981770 
    15991771 
    1600 BspLeaf *VspOspTree::GetRandomLeaf(const bool onlyUnmailed) 
    1601 { 
    1602         stack<BspNode *> nodeStack; 
     1772VspLeaf *VspOspTree::GetRandomLeaf(const bool onlyUnmailed) 
     1773{ 
     1774        stack<VspNode *> nodeStack; 
    16031775 
    16041776        nodeStack.push(mRoot); 
     
    16081780        while (!nodeStack.empty()) 
    16091781        { 
    1610                 BspNode *node = nodeStack.top(); 
     1782                VspNode *node = nodeStack.top(); 
    16111783                nodeStack.pop(); 
    16121784 
     
    16141786                { 
    16151787                        if ( (!onlyUnmailed || !node->Mailed()) ) 
    1616                                 return dynamic_cast<BspLeaf *>(node); 
     1788                                return dynamic_cast<VspLeaf *>(node); 
    16171789                } 
    16181790                else 
    16191791                { 
    1620                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     1792                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    16211793 
    16221794                        // random decision 
     
    16801852{ 
    16811853        int hits = 0; 
     1854#if TODO 
    16821855        stack<BspRayTraversalData> tStack; 
    16831856 
     
    16901863        Vector3 extp = termination; 
    16911864 
    1692         BspNode *node = mRoot; 
    1693         BspNode *farChild = NULL; 
     1865        VspNode *node = mRoot; 
     1866        VspNode *farChild = NULL; 
    16941867 
    16951868        float t; 
     
    17001873                if (!node->IsLeaf()) 
    17011874                { 
    1702                         BspInterior *in = dynamic_cast<BspInterior *>(node); 
     1875                        VspInterior *in = dynamic_cast<VspInterior *>(node); 
    17031876 
    17041877                        Plane3 splitPlane = in->GetPlane(); 
     
    17381911 
    17391912                        // push data for far child 
    1740                         tStack.push(BspRayTraversalData(farChild, extp)); 
     1913                        tStack.push(VspRayTraversalData(farChild, extp)); 
    17411914 
    17421915                        // find intersection of ray segment with plane 
     
    17461919                { 
    17471920                        // reached leaf => intersection with view cell 
    1748                         BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     1921                        VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
    17491922                        ViewCell *viewCell; 
    17501923                         
     
    17751948                } 
    17761949        } 
    1777  
     1950#endif 
    17781951        return hits; 
    17791952} 
     
    17811954 
    17821955 
    1783 BspNode *VspOspTree::CollapseTree(BspNode *node, int &collapsed) 
     1956VspNode *VspOspTree::CollapseTree(VspNode *node, int &collapsed) 
    17841957{ 
    17851958// TODO 
     
    17881961                return node; 
    17891962 
    1790         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    1791  
    1792         BspNode *front = CollapseTree(interior->GetFront(), collapsed); 
    1793         BspNode *back = CollapseTree(interior->GetBack(), collapsed); 
     1963        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
     1964 
     1965        VspNode *front = CollapseTree(interior->GetFront(), collapsed); 
     1966        VspNode *back = CollapseTree(interior->GetBack(), collapsed); 
    17941967 
    17951968        if (front->IsLeaf() && back->IsLeaf()) 
    17961969        { 
    1797                 BspLeaf *frontLeaf = dynamic_cast<BspLeaf *>(front); 
    1798                 BspLeaf *backLeaf = dynamic_cast<BspLeaf *>(back); 
     1970                VspLeaf *frontLeaf = dynamic_cast<VspLeaf *>(front); 
     1971                VspLeaf *backLeaf = dynamic_cast<VspLeaf *>(back); 
    17991972 
    18001973                //-- collapse tree 
     
    18031976                        BspViewCell *vc = frontLeaf->GetViewCell(); 
    18041977 
    1805                         BspLeaf *leaf = new BspLeaf(interior->GetParent(), vc); 
     1978                        VspLeaf *leaf = new VspLeaf(interior->GetParent(), vc); 
    18061979                        leaf->SetTreeValid(frontLeaf->TreeValid()); 
    18071980 
     
    18422015#if HAS_TO_BE_REDONE 
    18432016        // list not valid anymore => clear 
    1844         stack<BspNode *> nodeStack; 
     2017        stack<VspNode *> nodeStack; 
    18452018        nodeStack.push(mRoot); 
    18462019 
     
    18492022        while (!nodeStack.empty()) 
    18502023        { 
    1851                 BspNode *node = nodeStack.top(); 
     2024                VspNode *node = nodeStack.top(); 
    18522025                nodeStack.pop(); 
    18532026 
    18542027                if (node->IsLeaf()) 
    18552028                { 
    1856                         BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     2029                        VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
    18572030 
    18582031                        BspViewCell *viewCell = leaf->GetViewCell(); 
     
    18692042                else 
    18702043                { 
    1871                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     2044                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    18722045 
    18732046                        nodeStack.push(interior->GetFront()); 
     
    18832056ViewCell *VspOspTree::GetViewCell(const Vector3 &point, const bool active) 
    18842057{ 
     2058#if TODO 
    18852059        if (mRoot == NULL) 
    18862060                return NULL; 
    18872061 
    1888         stack<BspNode *> nodeStack; 
     2062        stack<VspNode *> nodeStack; 
    18892063        nodeStack.push(mRoot); 
    18902064   
     
    18932067        while (!nodeStack.empty())   
    18942068        { 
    1895                 BspNode *node = nodeStack.top(); 
     2069                VspNode *node = nodeStack.top(); 
    18962070                nodeStack.pop(); 
    18972071         
    18982072                if (node->IsLeaf())  
    18992073                { 
    1900                         viewcell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 
     2074                        viewcell = dynamic_cast<VspLeaf *>(node)->GetViewCell(); 
    19012075                        break; 
    19022076                }  
    19032077                else     
    19042078                {        
    1905                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     2079                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    19062080         
    19072081                        // random decision 
     
    19172091        else 
    19182092                return viewcell; 
     2093#endif 
    19192094} 
    19202095 
     
    19222097bool VspOspTree::ViewPointValid(const Vector3 &viewPoint) const 
    19232098{ 
    1924         BspNode *node = mRoot; 
     2099#if TODO 
     2100        VspNode *node = mRoot; 
    19252101 
    19262102        while (1) 
     
    19332109                        return false; 
    19342110                         
    1935                 BspInterior *in = dynamic_cast<BspInterior *>(node); 
     2111                VspInterior *in = dynamic_cast<VspInterior *>(node); 
    19362112                                         
    19372113                if (in->GetPlane().Side(viewPoint) <= 0)  
     
    19442120                } 
    19452121        } 
    1946  
     2122#endif 
    19472123        // should never come here 
    19482124        return false; 
     
    19502126 
    19512127 
    1952 void VspOspTree::PropagateUpValidity(BspNode *node) 
     2128void VspOspTree::PropagateUpValidity(VspNode *node) 
    19532129{ 
    19542130        const bool isValid = node->TreeValid(); 
     
    19692145                { 
    19702146            node = node->GetParent(); 
    1971                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     2147                        VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    19722148                         
    19732149                        // the parent is valid iff both leaves are valid 
     
    19912167 
    19922168#if ZIPPED_VIEWCELLS 
    1993 void VspOspTree::ExportNode(BspNode *node, ogzstream &stream) 
     2169void VspOspTree::ExportNode(VspNode *node, ogzstream &stream) 
    19942170#else 
    1995 void VspOspTree::ExportNode(BspNode *node, ofstream &stream) 
     2171void VspOspTree::ExportNode(VspNode *node, ofstream &stream) 
    19962172#endif 
    19972173{ 
    19982174        if (node->IsLeaf()) 
    19992175        { 
    2000                 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     2176                VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
    20012177                ViewCell *viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 
    20022178 
     
    20092185        else 
    20102186        { 
    2011                 BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     2187#if TODO         
     2188                VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    20122189         
    20132190                Plane3 plane = interior->GetPlane(); 
     
    20182195                ExportNode(interior->GetBack(), stream); 
    20192196                ExportNode(interior->GetFront(), stream); 
    2020  
     2197#endif 
    20212198                stream << "</Interior>" << endl; 
    20222199        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1006 r1008  
    99#include "VssRay.h" 
    1010#include "RayInfo.h" 
    11 #include "ViewCellBsp.h" 
    12  
     11#include "gzstream.h" 
    1312 
    1413 
     
    1615 
    1716class ViewCellLeaf; 
    18 //class BspViewCell; 
     17class VspViewCell; 
    1918class Plane3; 
    20 class VspBspTree;   
    21 class BspInterior; 
    22 class BspNode; 
    2319class AxisAlignedBox3; 
    2420class Ray; 
     
    2925class ViewCellsTree; 
    3026class Environment; 
     27class VspInterior; 
     28class VspLeaf; 
     29class VspNode; 
     30 
     31 
     32/** A definition for an axis aligned plane. 
     33*/ 
     34struct AxisAlignedPlane 
     35{ 
     36public: 
     37        int mAxis; 
     38        float mPosition; 
     39}; 
     40 
     41 
     42class VspTreeStatistics: public StatisticsBase 
     43{ 
     44public: 
     45        // total number of nodes 
     46        int nodes; 
     47        // number of splits 
     48        int splits[3]; 
     49         
     50        // totals number of rays 
     51        int rays; 
     52        // maximal reached depth 
     53        int maxDepth; 
     54        // minimal depth 
     55        int minDepth; 
     56         
     57        // max depth nodes 
     58        int maxDepthNodes; 
     59        // minimum depth nodes 
     60        int minDepthNodes; 
     61        // max depth nodes 
     62        int minPvsNodes; 
     63        // nodes with minimum PVS 
     64        int minRaysNodes; 
     65        // max ray contribution nodes 
     66        int maxRayContribNodes; 
     67        // minimum area nodes 
     68        int minProbabilityNodes; 
     69        /// nodes termination because of max cost ratio; 
     70        int maxCostNodes; 
     71        // max number of rays per node 
     72        int maxObjectRefs; 
     73        /// samples contributing to pvs 
     74        int contributingSamples; 
     75        /// sample contributions to pvs 
     76        int sampleContributions; 
     77        /// largest pvs 
     78        int maxPvs; 
     79        /// number of invalid leaves 
     80        int invalidLeaves; 
     81        /// accumulated number of rays refs 
     82        int accumRays; 
     83        int pvs; 
     84        // accumulated depth (used to compute average) 
     85        int accumDepth; 
     86 
     87        // Constructor 
     88        VspTreeStatistics()  
     89        { 
     90                Reset(); 
     91        } 
     92 
     93        int Nodes() const {return nodes;} 
     94        int Interior() const { return nodes / 2; } 
     95        int Leaves() const { return (nodes / 2) + 1; } 
     96         
     97        // TODO: computation wrong 
     98        double AvgDepth() const { return accumDepth / (double)Leaves();};  
     99        double AvgRays() const { return accumRays / (double)Leaves();};  
     100 
     101        void Reset()  
     102        { 
     103                nodes = 0; 
     104                for (int i = 0; i < 3; ++ i) 
     105                        splits[i] = 0; 
     106                 
     107                maxDepth = 0; 
     108                minDepth = 99999; 
     109                accumDepth = 0; 
     110        pvs = 0; 
     111                maxDepthNodes = 0; 
     112                minPvsNodes = 0; 
     113                minRaysNodes = 0; 
     114                maxRayContribNodes = 0; 
     115                minProbabilityNodes = 0; 
     116                maxCostNodes = 0; 
     117 
     118                contributingSamples = 0; 
     119                sampleContributions = 0; 
     120 
     121                maxPvs = 0; 
     122                invalidLeaves = 0; 
     123                accumRays = 0; 
     124        } 
     125 
     126        void Print(ostream &app) const; 
     127 
     128        friend ostream &operator<<(ostream &s, const VspTreeStatistics &stat)  
     129        { 
     130                stat.Print(s); 
     131                return s; 
     132        }  
     133}; 
     134 
     135/** 
     136    VspNode abstract class serving for interior and leaf node implementation 
     137*/ 
     138class VspNode  
     139{ 
     140 
     141public: 
     142        VspNode(); 
     143        virtual ~VspNode(){}; 
     144        VspNode(VspInterior *parent); 
     145 
     146        /** Determines whether this node is a leaf or not 
     147        @return true if leaf 
     148        */ 
     149        virtual bool IsLeaf() const = 0; 
     150 
     151        /** Determines whether this node is a root 
     152        @return true if root 
     153        */ 
     154        virtual bool IsRoot() const; 
     155 
     156        /** Returns parent node. 
     157        */ 
     158        VspInterior *GetParent(); 
     159 
     160        /** Sets parent node. 
     161        */ 
     162        void SetParent(VspInterior *parent); 
     163 
     164        /** Returns true if this node is a sibling of node n. 
     165        */ 
     166        bool IsSibling(VspNode *n) const; 
     167 
     168        /** returns depth of the node. 
     169        */ 
     170        int GetDepth() const; 
     171 
     172        /** returns true if the whole subtree is valid 
     173        */ 
     174        bool TreeValid() const; 
     175 
     176        void SetTreeValid(const bool v); 
     177 
     178        //-- mailing options 
     179 
     180        void Mail() { mMailbox = sMailId; } 
     181        static void NewMail() { ++ sMailId; } 
     182        bool Mailed() const { return mMailbox == sMailId; } 
     183 
     184        static int sMailId; 
     185        int mMailbox; 
     186 
     187        int mTimeStamp; 
     188 
     189protected: 
     190 
     191        /// if this sub tree is a completely valid view space region 
     192        bool mTreeValid; 
     193        /// parent of this node 
     194        VspInterior *mParent; 
     195}; 
     196 
     197 
     198/** BSP interior node implementation  
     199*/ 
     200class VspInterior: public VspNode  
     201{ 
     202public: 
     203        /** Standard contructor taking split plane as argument. 
     204        */ 
     205        VspInterior(const AxisAlignedPlane &plane); 
     206        ~VspInterior(); 
     207        /** @return false since it is an interior node  
     208        */ 
     209        bool IsLeaf() const; 
     210 
     211        VspNode *GetBack(); 
     212        VspNode *GetFront(); 
     213 
     214        /** Returns split plane. 
     215        */ 
     216        AxisAlignedPlane GetPlane() const; 
     217 
     218        /** Replace front or back child with new child. 
     219        */ 
     220        void ReplaceChildLink(VspNode *oldChild, VspNode *newChild); 
     221        /** Replace front and back child. 
     222        */ 
     223        void SetupChildLinks(VspNode *b, VspNode *f); 
     224 
     225        friend ostream &operator<<(ostream &s, const VspInterior &A) 
     226        { 
     227                return s << A.mPlane.mAxis << " " << A.mPlane.mPosition; 
     228        } 
     229 
     230protected: 
     231 
     232        /// Splitting plane corresponding to this node 
     233        AxisAlignedPlane mPlane; 
     234 
     235        /// back node 
     236        VspNode *mBack; 
     237        /// front node 
     238        VspNode *mFront; 
     239}; 
     240 
     241 
     242/** BSP leaf node implementation. 
     243*/ 
     244class VspLeaf: public VspNode  
     245{ 
     246 
     247public: 
     248        VspLeaf(); 
     249        VspLeaf(ViewCellLeaf *viewCell); 
     250        VspLeaf(VspInterior *parent); 
     251        VspLeaf(VspInterior *parent, ViewCellLeaf *viewCell); 
     252 
     253        ~VspLeaf(); 
     254 
     255        /** @return true since it is an interior node  
     256        */ 
     257        bool IsLeaf() const; 
     258         
     259        /** Returns pointer of view cell. 
     260        */ 
     261        ViewCellLeaf *GetViewCell() const; 
     262 
     263        /** Sets pointer to view cell. 
     264        */ 
     265        void SetViewCell(ViewCellLeaf *viewCell); 
     266 
     267        /// Rays piercing this leaf. 
     268        VssRayContainer mVssRays; 
     269         
     270        /// leaf pvs 
     271        ObjectPvs *mPvs; 
     272 
     273        /// Probability that the view point lies in this leaf 
     274        float mProbability; 
     275 
     276protected: 
     277         
     278        /// if NULL this does not correspond to feasible viewcell 
     279        ViewCellLeaf *mViewCell; 
     280}; 
     281 
    31282 
    32283/** 
     
    57308{ 
    58309        friend class ViewCellsParseHandlers; 
    59         friend class VspBspViewCellsManager; 
     310        friend class VspVspViewCellsManager; 
    60311 
    61312public: 
    62313         
    63         /** A definition for an axis aligned plane. 
    64         */ 
    65         struct AxisAlignedPlane 
    66         { 
    67         public: 
    68                 int mAxis; 
    69                 float mPosition; 
    70         }; 
    71  
    72314        /** Additional data which is passed down the BSP tree during traversal. 
    73315        */ 
     
    76318        public: 
    77319                /// the current node 
    78                 BspNode *mNode; 
     320                VspNode *mNode; 
    79321                /// current depth 
    80322                int mDepth; 
     
    114356                {} 
    115357                 
    116                 VspOspTraversalData(BspNode *node,  
     358                VspOspTraversalData(VspNode *node,  
    117359                                                        const int depth,  
    118360                                                        RayInfoContainer *rays, 
     
    193435#if 1 
    194436                        return mRenderCost; 
    195 #endif 
    196 #if 0 
     437#else 
    197438                        return (float) (-mDepth); // for kd tree 
    198439#endif 
     
    217458        /** Returns BSP Tree statistics. 
    218459        */ 
    219         const BspTreeStatistics &GetStatistics() const;  
     460        const VspTreeStatistics &GetStatistics() const;  
    220461   
    221462 
     
    233474                @param maxPvs the maximal pvs (-1 means unlimited) 
    234475        */ 
    235         void CollectLeaves(vector<BspLeaf *> &leaves,  
     476        void CollectLeaves(vector<VspLeaf *> &leaves,  
    236477                                           const bool onlyUnmailed = false, 
    237478                                           const int maxPvs = -1) const; 
     
    241482        AxisAlignedBox3 GetBoundingBox()const; 
    242483 
    243         /** Returns root of BSP tree. 
    244         */ 
    245         BspNode *GetRoot() const; 
     484        /** Returns root of the view space partitioning tree. 
     485        */ 
     486        VspNode *GetRoot() const; 
    246487 
    247488        /** Collects the leaf view cells of the tree 
     
    259500        /** finds neighbouring leaves of this tree node. 
    260501        */ 
    261         int FindNeighbors(BspNode *n,  
    262                                           vector<BspLeaf *> &neighbors,  
     502        int FindNeighbors(VspNode *n,  
     503                                          vector<VspLeaf *> &neighbors,  
    263504                                          const bool onlyUnmailed) const; 
    264505 
     
    266507                @param halfspace defines the halfspace from which the leaf is taken. 
    267508        */ 
    268         BspLeaf *GetRandomLeaf(const Plane3 &halfspace); 
     509        VspLeaf *GetRandomLeaf(const Plane3 &halfspace); 
    269510 
    270511        /** Returns random leaf of BSP tree. 
    271512                @param onlyUnmailed if only unmailed leaves should be returned. 
    272513        */ 
    273         BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false); 
     514        VspLeaf *GetRandomLeaf(const bool onlyUnmailed = false); 
    274515 
    275516        /** Returns epsilon of this tree. 
     
    291532        void SetViewCellsManager(ViewCellsManager *vcm); 
    292533 
    293         /** Returns distance from node 1 to node 2. 
    294         */ 
    295         int TreeDistance(BspNode *n1, BspNode *n2) const; 
    296534 
    297535        /** Collapses the tree with respect to the view cell partition. 
     
    316554                the invalid view space. 
    317555        */ 
    318         BspViewCell *GetOutOfBoundsCell(); 
     556        VspViewCell *GetOutOfBoundsCell(); 
    319557 
    320558        /** Writes tree to output stream 
     
    332570        int CastBeam(Beam &beam); 
    333571 
    334         /** Finds approximate neighbours, i.e., finds correct neighbors 
    335                 in most cases but sometimes more. 
    336         */ 
    337         int FindApproximateNeighbors(BspNode *n,  
    338                                                              vector<BspLeaf *> &neighbors, 
    339                                                                  const bool onlyUnmailed) const; 
    340572 
    341573        /** Checks if tree validity-flags are right  
     
    410642        /** Evaluates render cost decrease of next split. 
    411643        */ 
    412         float EvalRenderCostDecrease(const Plane3 &candidatePlane, 
     644        float EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 
    413645                                                                 const VspOspTraversalData &data) const; 
    414646 
     
    419651        /** Collects view cells in the subtree under root. 
    420652        */ 
    421         void CollectViewCells(BspNode *root,  
     653        void CollectViewCells(VspNode *root,  
    422654                                                  bool onlyValid,  
    423655                                                  ViewCellContainer &viewCells, 
     
    427659                the invalid view space. If it does not exist, it is created. 
    428660        */ 
    429         BspViewCell *GetOrCreateOutOfBoundsCell(); 
     661        VspViewCell *GetOrCreateOutOfBoundsCell(); 
    430662 
    431663        /** Collapses the tree with respect to the view cell partition, 
     
    436668                this node otherwise 
    437669        */ 
    438         BspNode *CollapseTree(BspNode *node, int &collapsed); 
     670        VspNode *CollapseTree(VspNode *node, int &collapsed); 
    439671 
    440672        /** Helper function revalidating the view cell leaf list after merge. 
     
    451683                @returns new root of the subtree 
    452684        */ 
    453         BspNode *Subdivide(VspOspSplitQueue &tQueue, 
     685        VspNode *Subdivide(VspOspSplitQueue &tQueue, 
    454686                                           VspOspSplitCandidate &splitCandidate); 
    455687 
     
    469701        */ 
    470702 
    471         BspInterior *SubdivideNode(const Plane3 &splitPlane, 
     703        VspInterior *SubdivideNode(const AxisAlignedPlane &splitPlane, 
    472704                                                           VspOspTraversalData &tData, 
    473705                                                           VspOspTraversalData &frontData, 
     
    546778                 
    547779        */ 
    548         void AddToPvs(BspLeaf *leaf, 
     780        void AddToPvs(VspLeaf *leaf, 
    549781                                  const RayInfoContainer &rays,  
    550782                                  float &sampleContributions, 
     
    553785        /** Propagates valid flag up the tree. 
    554786        */ 
    555         void PropagateUpValidity(BspNode *node); 
     787        void PropagateUpValidity(VspNode *node); 
    556788 
    557789        /** Writes the node to disk 
     
    559791        */ 
    560792#if ZIPPED_VIEWCELLS 
    561         void ExportNode(BspNode *node, ogzstream &stream); 
     793        void ExportNode(VspNode *node, ogzstream &stream); 
    562794#else 
    563         void ExportNode(BspNode *node, ofstream &stream); 
     795        void ExportNode(VspNode *node, ofstream &stream); 
    564796#endif 
    565797 
     
    575807 
    576808        /// Pointer to the root of the tree 
    577         BspNode *mRoot; 
    578                  
    579         BspTreeStatistics mBspStats; 
     809        VspNode *mRoot; 
     810                 
     811        VspTreeStatistics mVspStats; 
    580812         
    581813        /// View cell corresponding to the space outside the valid view space 
    582         BspViewCell *mOutOfBoundsCell; 
     814        VspViewCell *mOutOfBoundsCell; 
    583815 
    584816        /// box around the whole view domain 
Note: See TracChangeset for help on using the changeset viewer.