Ignore:
Timestamp:
02/02/06 19:16:39 (18 years ago)
Author:
mattausch
Message:

fixed bug in mergueue to find root of merge and sort out doube view cells

File:
1 edited

Legend:

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

    r581 r582  
    5656        environment->GetBoolValue("ViewCells.PostProcess.useRaysForMerge", mUseRaysForMerge); 
    5757         
    58         environment->GetIntValue("ViewCells.active", mNumActiveViewCells); 
     58        environment->GetIntValue("ViewCells.active", mNumMergedViewCells); 
    5959 
    6060        mMinPvsSize = emptyViewCells ? 1 : 0; 
     
    107107{ 
    108108        cout << "disposing samples ... "; 
     109        long startTime = GetTime(); 
     110        int n = (int)rays.size(); 
     111 
    109112        if (outRays) 
    110113        { 
     
    121124        } 
    122125        cout << "finished" << endl; 
     126        Debug << "disposed " << n << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    123127} 
    124128 
     
    519523 
    520524 
    521 ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCell &left, ViewCell &right) const 
     525ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCell *left, ViewCell *right) const 
    522526{ 
    523527        // generate parent view cell 
     
    525529 
    526530        // merge pvs 
    527         vc->GetPvs().Merge(left.GetPvs(), right.GetPvs()); 
     531        vc->GetPvs().Merge(left->GetPvs(), right->GetPvs()); 
    528532 
    529533        //-- merge ray sets 
    530534        if (0) 
    531535        { 
    532                 stable_sort(left.mPiercingRays.begin(), left.mPiercingRays.end()); 
    533                 stable_sort(right.mPiercingRays.begin(), right.mPiercingRays.end()); 
    534  
    535                 std::merge(left.mPiercingRays.begin(), left.mPiercingRays.end(), 
    536                                    right.mPiercingRays.begin(), right.mPiercingRays.end(), 
     536                stable_sort(left->mPiercingRays.begin(), left->mPiercingRays.end()); 
     537                stable_sort(right->mPiercingRays.begin(), right->mPiercingRays.end()); 
     538 
     539                std::merge(left->mPiercingRays.begin(), left->mPiercingRays.end(), 
     540                                   right->mPiercingRays.begin(), right->mPiercingRays.end(), 
    537541                                   vc->mPiercingRays.begin()); 
    538542        } 
    539543 
    540544 
    541         vc->SetupChildLink(&left); 
    542         vc->SetupChildLink(&right); 
    543  
     545        vc->SetupChildLink(left); 
     546        vc->SetupChildLink(right); 
     547 
     548 
     549        return vc; 
     550} 
     551 
     552 
     553ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCellContainer &children) const 
     554{ 
     555        ViewCellInterior *vc = new ViewCellInterior();//GenerateViewCell(); 
     556 
     557        ViewCellContainer::const_iterator it, it_end = children.end(); 
     558 
     559        for (it = children.begin(); it != it_end; ++ it) 
     560        { 
     561                // merge pvs 
     562                vc->GetPvs().Merge(vc->GetPvs(), (*it)->GetPvs()); 
     563 
     564                vc->SetupChildLink(*it); 
     565        } 
    544566 
    545567        return vc; 
     
    845867                if (!mOnlyValidViewCells || (*it)->GetValid()) 
    846868                { 
    847                         ExportColor(exporter, *it); 
    848                         ExportViewCellGeometry(exporter, *it); 
    849                 } 
    850         } 
     869                        ExportColor(exporter, *it);              
     870                        ExportViewCellGeometry(exporter, *it);           
     871                } 
     872        } 
     873 
    851874} 
    852875 
     
    11751198                VssRayContainer vcRays; 
    11761199                Intersectable::NewMail(); 
    1177 #if 0 
    1178                 BspViewCell *vc = dynamic_cast<BspViewCell *>(mViewCells[i]); 
    1179 #else 
    1180                 BspViewCell *vc = dynamic_cast<BspViewCell *>(mViewCells[Random((int)mViewCells.size())]); 
    1181 #endif 
     1200                ViewCell *vc; 
     1201 
     1202                if (0) 
     1203                        vc = mViewCells[i]; 
     1204                else 
     1205                        vc = mViewCells[Random((int)mViewCells.size())]; 
     1206 
    11821207                cout << "creating output for view cell " << i << " ... "; 
    11831208 
     
    12131238 
    12141239                        //-- export view cell 
     1240#if VC_HISTORY 
    12151241                        mBspTree->ConstructGeometry(vc, vcGeom); 
    12161242                        exporter->ExportPolygons(vcGeom.mPolys); 
     1243#endif 
    12171244                } 
    12181245 
     
    12711298                // cast line segment to get intersections with bsp leaves 
    12721299                CastLineSegment(vssRay->mTermination, vssRay->mOrigin, viewCells); 
    1273  
     1300#if VC_HISTORY 
    12741301                ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    12751302                for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    12761303                { 
    1277                         BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     1304                        ViewCell *vc = *vit; 
    12781305                        ray->intersections.push_back(BspIntersection(0, vc->mLeaf)); 
    12791306                } 
    1280  
     1307#endif 
    12811308                mBspRays.push_back(ray); 
    12821309        } 
     
    13341361        { 
    13351362                BspNodeGeometry geom; 
    1336                 mBspTree->ConstructGeometry( 
    1337                         dynamic_cast<BspViewCell *>(vc), geom); 
     1363#if VC_HISTORY 
     1364                mBspTree->ConstructGeometry(vc, geom); 
    13381365                exporter->ExportPolygons(geom.mPolys); 
     1366#endif 
    13391367        } 
    13401368} 
     
    20812109        { 
    20822110                // we can use the view cells tree hierarchy to get the right set 
    2083                 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumActiveViewCells); 
     2111                mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); 
    20842112        } 
    20852113 
     
    23802408                        for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
    23812409                        { 
    2382                                 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     2410                                ViewCell *vc = *vit; 
    23832411 
    23842412                                vm = RandomMaterial(); 
     
    25472575                        for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
    25482576                        { 
    2549                                 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     2577                                ViewCell *vc = *vit; 
    25502578 
    25512579                                ViewCellContainer leaves; 
     
    26582686                VssRayContainer vcRays; 
    26592687                Intersectable::NewMail(); 
    2660                 BspViewCell *vc; 
     2688                ViewCell *vc; 
    26612689         
    26622690                if (0) // largest view cell pvs first 
    2663                 { 
    2664                         vc = dynamic_cast<BspViewCell *>(mViewCells[i]); 
    2665                 } 
     2691                        vc = mViewCells[i]; 
    26662692                else 
    2667                 { 
    2668                         vc = dynamic_cast<BspViewCell *> 
    2669                                 (mViewCells[Random((int)mViewCells.size())]); 
    2670                 } 
     2693                        vc = mViewCells[Random((int)mViewCells.size())]; 
    26712694 
    26722695        if (1) 
     
    26782701                                for     (int j = 0; j < (int)ray->mViewCells.size(); ++ j) 
    26792702                                { 
    2680                                         BspViewCell *bspVc = dynamic_cast<BspViewCell *>(ray->mViewCells[j]); 
    2681                                         BspLeaf *leaf = bspVc->mLeaf; 
    2682                                         if (vc == bspVc) 
     2703                                        ViewCell *rayvc = ray->mViewCells[j]; 
     2704#if VC_HISTORY 
     2705                                        BspLeaf *leaf = rayvc->mLeaf; 
     2706                                        if (vc == rayvc) 
    26832707                                                vcRays.push_back(ray); 
     2708#endif 
    26842709                                } 
    26852710                        } 
     
    28352860 
    28362861        BspNodeGeometry geom; 
    2837         mVspBspTree-> 
    2838                 ConstructGeometry(dynamic_cast<BspViewCell *>(vc), geom); 
     2862        mVspBspTree->ConstructGeometry(vc, geom); 
    28392863        exporter->ExportPolygons(geom.mPolys); 
    28402864} 
     
    28452869        ViewCellContainer leaves; 
    28462870        mViewCellsTree->CollectLeaves(vc, leaves); 
    2847  
    28482871 
    28492872        int maxDist = 0; 
     
    28862909 
    28872910        BspNodeGeometry geom; 
    2888         BspViewCell *bspVc = dynamic_cast<BspViewCell *>(vc); 
    2889         mVspBspTree->ConstructGeometry(bspVc, geom); 
     2911         
     2912        mVspBspTree->ConstructGeometry(vc, geom); 
    28902913 
    28912914        Mesh *mesh = new Mesh(); 
     
    29843007void VspBspViewCellsManager::Finalize(ViewCell *viewCell, const bool createMesh) 
    29853008{ 
    2986         BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCell); 
    2987         CreateMesh(vc); 
     3009        CreateMesh(viewCell); 
    29883010 
    29893011        float area = 0; 
     
    29913013 
    29923014        ViewCellContainer leaves; 
    2993         mViewCellsTree->CollectLeaves(vc, leaves); 
     3015        mViewCellsTree->CollectLeaves(viewCell, leaves); 
    29943016 
    29953017        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
Note: See TracChangeset for help on using the changeset viewer.