Changeset 325


Ignore:
Timestamp:
10/13/05 13:10:21 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
2 edited

Legend:

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

    r324 r325  
    613613                leaf->SetViewCell(tData.mViewCell); 
    614614                 
    615                 // clean up 
     615                //-- clean up 
     616 
    616617                // remaining polygons are discarded or added to node 
    617618                leaf->ProcessPolygons(tData.mPolygons, sStoreSplitPolys); 
    618619                DEL_PTR(tData.mPolygons); 
     620 
     621                if (tData.mRays()) 
     622                        CLEAR_CONTAINER(*tData.mRays); 
     623                DEL_PTR(tData.mRays); 
    619624 
    620625                return leaf; 
     
    631636                                                                                  *frontPolys, 
    632637                                                                                  *backPolys,  
    633                                                                                   coincident); 
     638                                                                                  coincident, 
     639                                                                                  *tData.mRays); 
    634640 
    635641        ViewCell *frontViewCell = mRootCell; 
     
    655661        interior->ProcessPolygons(&coincident, sStoreSplitPolys); 
    656662 
     663        // split rays 
     664        RayContainer *frontRays = NULL; 
     665        RayContainer *backRays = NULL; 
     666 
     667        if (tData.mRays) 
     668        { 
     669                RayContainer *frontRays = new RayContainer(); 
     670                RayContainer *backRays = new RayContainer(); 
     671 
     672                Plane3 plane; 
     673                SplitRays(plane, *tData.mRays, *frontRays, *backRays); 
     674        } 
     675 
    657676        // push the children on the stack 
    658677        tStack.push(BspTraversalData(interior->GetBack(),  
    659678                                                                 backPolys,  
    660679                                                                 tData.mDepth + 1,  
    661                                                                  backViewCell)); 
     680                                                                 backViewCell,  
     681                                                                 backRays)); 
    662682 
    663683        tStack.push(BspTraversalData(interior->GetFront(),  
    664684                                                                 frontPolys,  
    665685                                                                 tData.mDepth + 1,  
    666                                                                  frontViewCell)); 
     686                                                                 frontViewCell,  
     687                                                                 frontRays)); 
    667688 
    668689        // cleanup 
    669690        DEL_PTR(tData.mNode); 
    670691        DEL_PTR(tData.mPolygons); 
     692        DEL_PTR(tData.mRays); 
    671693 
    672694        return interior; 
     
    707729                                                                        PolygonContainer &frontPolys, 
    708730                                                                        PolygonContainer &backPolys,  
    709                                                                         PolygonContainer &coincident) 
     731                                                                        PolygonContainer &coincident, 
     732                                                                        const RayContainer &rays) 
    710733{ 
    711734        mStat.nodes += 2; 
    712735 
    713736        // add the new nodes to the tree + select subdivision plane 
    714         BspInterior *interior = new BspInterior(SelectPlane(leaf, polys));  
     737        BspInterior *interior = new BspInterior(SelectPlane(leaf, polys, rays));  
    715738 
    716739#ifdef _DEBUG 
     
    726749                                                        coincident,  
    727750                                                        splits,  
    728                                                         sStoreSplitPolys); 
     751                                                        mStoreSplitPolys); 
    729752         
    730753        mStat.splits += splits; 
     
    849872 
    850873Plane3 BspTree::SelectPlane(BspLeaf *leaf,  
    851                                                         PolygonContainer &polys) 
     874                                                        PolygonContainer &polys,  
     875                                                        const RayContainer &rays) 
    852876{ 
    853877        if (polys.size() == 0) 
     
    898922 
    899923        // use heuristics to find appropriate plane 
    900         return SelectPlaneHeuristics(polys, sMaxCandidates); 
     924        return SelectPlaneHeuristics(polys, rays, sMaxCandidates); 
    901925} 
    902926 
    903927Plane3 BspTree::SelectPlaneHeuristics(PolygonContainer &polys, 
     928                                                                          const RayContainer &rays, 
    904929                                                                          const int maxTests) 
    905930{ 
     
    918943                 
    919944                // evaluate current candidate 
    920                 float candidateCost = SplitPlaneCost(polys, candidatePlane); 
     945                float candidateCost = SplitPlaneCost(polys, candidatePlane, rays); 
    921946                         
    922947                if (candidateCost < lowestCost) 
     
    945970 
    946971float BspTree::SplitPlaneCost(PolygonContainer &polys,  
    947                                                           const Plane3 &candidatePlane) 
     972                                                          const Plane3 &candidatePlane,  
     973                                                          const RayContainer &rays) 
    948974{ 
    949975        float val = 0; 
     
    13561382        } 
    13571383} 
     1384 
     1385void BspTree::SplitRays(const Plane3 plane, 
     1386                                                RayContainer &rays,  
     1387                                                RayContainer &frontRays,  
     1388                                                RayContainer &backRays) 
     1389{ 
     1390        while (!rays.empty()) 
     1391        { 
     1392                //TODO 
     1393        } 
     1394} 
    13581395//} // GtpVisibilityPreprocessor 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r322 r325  
    234234                /// the view cell associated with this subdivsion 
    235235                ViewCell *mViewCell; 
    236                  
     236                /// rays piercing this node 
     237                RayContainer *mRays; 
     238 
    237239                BspTraversalData(): 
    238240                mNode(NULL), 
    239241                mPolygons(NULL), 
    240242                mDepth(0), 
    241                 mViewCell(NULL) 
     243                mViewCell(NULL), 
     244                mRays(NULL) 
    242245                {} 
    243246                 
     
    245248                                                 PolygonContainer *polys,  
    246249                                                 const int depth,  
    247                                                  ViewCell *viewCell):  
     250                                                 ViewCell *viewCell, 
     251                                                 RayContainer *rays = NULL):  
    248252                mNode(node),  
    249253                mPolygons(polys),  
    250254                mDepth(depth),  
    251                 mViewCell(viewCell) 
     255                mViewCell(viewCell), 
     256                mRays(rays) 
    252257                {} 
    253258    }; 
     
    353358        */ 
    354359        float SplitPlaneCost(PolygonContainer &polys,  
    355                                                  const Plane3 &candidatePlane); 
     360                                                 const Plane3 &candidatePlane, 
     361                                                 const RayContainer &rays); 
    356362 
    357363        /** Evaluates tree stats in the BSP tree leafs. 
     
    369375                @param leaf the leaf to be split 
    370376                @param polys the polygon list on which the split decition is based 
    371                 @Returns the split plane 
     377                @param rays ray container on which selection may be based 
     378                Returns the split plane 
    372379        */ 
    373380        Plane3 SelectPlane(BspLeaf *leaf,  
    374                                            PolygonContainer &polys); 
     381                                           PolygonContainer &polys, 
     382                                           const RayContainer &ray); 
    375383 
    376384        /** Filters next view cell down the tree and inserts it into the appropriate leaves 
     
    390398                @param backPolys returns the polygons in the back of the split plane 
    391399                @param coincident returns the polygons coincident to the split plane 
     400                @param rays ray container used to guide the split process 
    392401                @returns the root of the subdivision 
    393402        */ 
     
    396405                                                           PolygonContainer &frontPolys, 
    397406                                                           PolygonContainer &backPolys,  
    398                                                            PolygonContainer &coincident); 
     407                                                           PolygonContainer &coincident, 
     408                                                           const RayContainer &rays); 
    399409 
    400410        /** Filters polygons down the tree. 
     
    413423                2.5d aligned) 
    414424                @param polygons container of polygons 
     425                @param rays bundle of rays on which the split can be based 
    415426                @param maxTests the maximal number of candidate tests 
    416427        */ 
    417428        Plane3 SelectPlaneHeuristics(PolygonContainer &polys,  
    418                                                                 const int maxTests); 
     429                                                                 const RayContainer &rays, 
     430                                                                 const int maxTests); 
    419431 
    420432        /** Extracts the meshes of the objects and adds them to polygons.  
     
    490502                                                         vector<SortableEntry> &splitCandidates) const; 
    491503 
     504        /** Splits the rays into front and back rays according to split plane 
     505                @param rays contains the rays to be split. The rays are  
     506                           distributed to front and back rays. 
     507                @param frontRays returns rays on the front side of the plane 
     508                @param backRays returns rays on the back side of the plane 
     509        */ 
     510        void BspTree::SplitRays(const Plane3 plane, 
     511                                                        RayContainer &rays,  
     512                                                        RayContainer &frontRays,  
     513                                                        RayContainer &backRays); 
     514 
    492515        /// Pointer to the root of the tree 
    493516        BspNode *mRoot; 
Note: See TracChangeset for help on using the changeset viewer.