Ignore:
Timestamp:
11/25/05 17:16:26 (19 years ago)
Author:
mattausch
Message:

bsptree view cells working in VssPreprocessor?

File:
1 edited

Legend:

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

    r433 r436  
    143143                Polygon3 *front_piece = NULL; 
    144144                Polygon3 *back_piece = NULL; 
    145          
    146                 VertexContainer splitVertices; 
    147145 
    148146                switch (cf) 
     
    164162                                poly->Split(mPlane,  
    165163                                                        *front_piece,  
    166                                                         *back_piece,  
    167                                                         splitVertices); 
     164                                                        *back_piece); 
    168165                                         
    169166                                ++ splits; // increase number of splits 
     
    698695        facePolyMap.clear(); 
    699696 
    700         // compue bounding box 
     697        // compute bounding box 
    701698        Polygon3::IncludeInBox(*polys, mBox); 
    702699 
     
    721718} 
    722719 
     720void BspTree::Construct(const ObjectContainer &objects, const RayContainer &sampleRays) 
     721{ 
     722    mStat.nodes = 1; 
     723        mBox.Initialize();      // initialise BSP tree bounding box 
     724         
     725        BoundedRayContainer *rays = new BoundedRayContainer(); 
     726        PolygonContainer *polys = new PolygonContainer(); 
     727         
     728        // copy mesh instance polygons into one big polygon soup 
     729        mStat.polys = AddToPolygonSoup(objects, *polys); 
     730 
     731        RayContainer::const_iterator rit, rit_end = sampleRays.end(); 
     732 
     733        //-- store rays 
     734        for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
     735        { 
     736                Ray *ray = *rit; 
     737        ray->SetId(-1); // reset id 
     738 
     739                float minT, maxT; 
     740                if (BoundRay(*ray, minT, maxT)) 
     741                        rays->push_back(new BoundedRay(ray, minT, maxT)); 
     742        } 
     743 
     744        Debug << "tree has " << (int)polys->size() << " polys, " << (int)sampleRays.size() << " rays" << endl; 
     745        Construct(polys, rays); 
     746} 
     747 
    723748void BspTree::Construct(PolygonContainer *polys, BoundedRayContainer *rays) 
    724749{ 
     
    736761 
    737762        mStat.Start(); 
    738         cout << "**** Contructing bsp tree ****\n"; 
    739  
     763        cout << "Contructing bsp tree ... "; 
     764        long startTime = GetTime(); 
    740765        while (!tStack.empty())  
    741766        { 
    742767                tData = tStack.top(); 
     768 
    743769            tStack.pop(); 
    744770 
    745771                // subdivide leaf node 
    746                 BspNode *subRoot = Subdivide(tStack, tData); 
    747         } 
     772                BspNode *r = Subdivide(tStack, tData); 
     773 
     774                if (r == mRoot) 
     775                        Debug << "BSP tree construction time spent at root: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
     776        } 
     777 
     778        cout << "finished\n"; 
    748779 
    749780        mStat.Stop(); 
     
    14521483        float pFront = 0; 
    14531484        float pBack = 0; 
    1454 Debug << "here" << endl; 
     1485 
    14551486        if (mSplitPlaneStrategy & PVS) 
    14561487        { 
     
    15731604 
    15741605                // give penalty to unbalanced split 
    1575                 if (0) 
     1606                if (1) 
    15761607                if (((pFront * 0.2 + Limits::Small) > pBack) || (pFront < (pBack * 0.2 + Limits::Small))) 
    15771608                        val += 0.5; 
     
    15831614                  << " backpvs: " << backPvs << " pBack: " << pBack << endl << endl; 
    15841615#endif 
    1585         Debug << "here2" << endl; 
    15861616        return val; 
    15871617} 
     
    21952225                                        backPoly = new Polygon3(); 
    21962226 
    2197                                         candidatePolys[i]->Split(halfSpaces[j], *frontPoly,  
    2198                                                                                          *backPoly, splitPts); 
     2227                                        candidatePolys[i]->Split(halfSpaces[j],  
     2228                                                                                         *frontPoly,  
     2229                                                                                         *backPoly); 
    21992230 
    22002231                                        DEL_PTR(candidatePolys[i]); 
     
    24502481                                        Polygon3 *backPoly = new Polygon3(); 
    24512482                                 
    2452                                         VertexContainer splitPts; 
    2453                                                  
    2454                                         poly->Split(splitPlane, *frontPoly, *backPoly, splitPts); 
     2483                                        poly->Split(splitPlane, *frontPoly, *backPoly); 
    24552484 
    24562485                                        DEL_PTR(poly); 
     
    25072536                        case Polygon3::SPLIT: 
    25082537                                { 
    2509                                         VertexContainer splitPts; 
    2510                                  
    25112538                                        Polygon3 *frontPoly = new Polygon3(); 
    25122539                                        Polygon3 *backPoly = new Polygon3(); 
    25132540 
    2514                                         planePoly->Split(plane, *frontPoly, *backPoly, splitPts); 
     2541                                        planePoly->Split(plane, *frontPoly, *backPoly); 
    25152542                                        DEL_PTR(planePoly); 
    25162543 
Note: See TracChangeset for help on using the changeset viewer.