Ignore:
Timestamp:
01/18/06 23:35:50 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
10 edited

Legend:

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

    r497 r551  
    7777                // probability of view cell 
    7878                const float pInVc = mViewCellsManager->GetProbability(vc); 
     79 
    7980                // compute render time of PVS times probability 
    8081                // that view point is in view cell 
     
    8283                        mViewCellsManager->GetRendercost(vc, mObjRenderCost); 
    8384         
    84                 // crossing the border of a view cell is depending on the move speed 
    85                 // and the probability that a view cell border is crossed 
     85                // crossing the border of a view cell is depending on the move  
     86                // speed and the probability that a view cell border is crossed 
    8687                loadPvsOverhead += GetCrossVcProbability() * mVcOverhead; 
    8788 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp

    r549 r551  
    219219    maxDepthNodes*100/(double)Leaves()<<endl; 
    220220 
    221   app << "#N_PMINPVSLEAVES  ( Percentage of leaves with minCost )\n"<< 
     221  app << "#N_PMINPVSLEAVES  ( Percentage of leaves with minPvs )\n"<< 
    222222    minPvsNodes*100/(double)Leaves()<<endl; 
    223223 
    224   app << "#N_PMINRAYSLEAVES  ( Percentage of leaves with minCost )\n"<< 
     224  app << "#N_PMINRAYSLEAVES  ( Percentage of leaves with minRays )\n"<< 
    225225    minRaysNodes*100/(double)Leaves()<<endl; 
    226226         
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r547 r551  
    1010MeshInstance(NULL),  
    1111mPiercingRays(0), 
    12 mArea(0), 
    13 mVolume(0), 
     12mArea(-1), 
     13mVolume(-1), 
    1414mValid(true) 
    1515{ 
     
    1919MeshInstance(mesh),  
    2020mPiercingRays(0), 
    21 mArea(0), 
    22 mVolume(0), 
     21mArea(-1), 
     22mVolume(-1), 
    2323mValid(true) 
    2424{ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r547 r551  
    15091509} 
    15101510 
     1511 
    15111512float BspTree::SplitPlaneCost(const Plane3 &candidatePlane,  
    15121513                                                          const BoundedRayContainer &rays, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r547 r551  
    252252 
    253253 
     254void ViewCellsManager::FinalizeViewCells(const bool createMesh) 
     255{ 
     256        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     257        for (it = mViewCells.begin(); it != it_end; ++ it) 
     258        { 
     259                Finalize(*it, createMesh); 
     260        } 
     261} 
     262 
     263 
     264void ViewCellsManager::Finalize(ViewCell *viewCell, const bool createMesh) 
     265{ 
     266        // implemented in subclasses 
     267} 
     268 
     269 
    254270ViewCell *ViewCellsManager::MergeViewCells(ViewCell &front, ViewCell &back) const 
    255271{ 
     
    11451161void BspViewCellsManager::CreateMesh(ViewCell *vc) 
    11461162{ 
    1147 } 
    1148  
    1149 ViewCell * 
    1150 BspViewCellsManager::GetViewCell(const Vector3 &point) 
     1163        // TODO 
     1164} 
     1165 
     1166 
     1167ViewCell *BspViewCellsManager::GetViewCell(const Vector3 &point) 
    11511168{ 
    11521169  if (!mBspTree) 
     
    14451462void KdViewCellsManager::CreateMesh(ViewCell *vc) 
    14461463{ 
     1464        // TODO 
    14471465} 
    14481466 
     
    17931811void VspKdViewCellsManager::CreateMesh(ViewCell *vc) 
    17941812{ 
     1813        //TODO 
    17951814} 
    17961815 
     
    18161835float VspBspViewCellsManager::GetProbability(ViewCell *viewCell) 
    18171836{ 
    1818         if (mVspBspTree->mUseAreaForPvs) 
     1837        if (0 && mVspBspTree->mUseAreaForPvs) 
    18191838                return GetArea(viewCell) / GetAccVcArea(); 
    18201839        else 
     
    18651884        VssRayContainer savedRays; 
    18661885 
     1886        Debug << "construction samples: " << mConstructionSamples << " rays: " << rays.size() << endl; 
    18671887        GetRaySets(rays, mConstructionSamples, constructionRays, &savedRays); 
    18681888 
     
    19731993                if (exporter) 
    19741994                { 
    1975                         //exporter->SetWireframe(); 
    1976                         exporter->SetFilled(); 
     1995                        if (1) 
     1996                                exporter->SetWireframe(); 
     1997                        else 
     1998                                exporter->SetFilled(); 
    19771999                        ExportViewCellsForViz(exporter); 
    19782000 
     
    20312053        if (mViewCellsFinished) 
    20322054        { 
     2055                FinalizeViewCells(true); 
    20332056                EvaluateViewCellsStats(); 
    20342057                return 0; 
     
    20492072 
    20502073 
    2051         //-- merge the individual view cells: Should be done here because it makes 
     2074        if (1) 
     2075        { 
     2076                FinalizeViewCells(false); 
     2077        } 
     2078 
     2079        //-- merge the individual view cells 
    20522080        MergeViewCells(postProcessRays, objects); 
    20532081        //-- refines the merged view cells 
     
    20592087 
    20602088        // real meshes are only contructed only at this stage 
    2061         CreateViewCellMeshes(); 
     2089        //CreateViewCellMeshes(); 
     2090        FinalizeViewCells(true); 
    20622091 
    20632092        // write view cells to disc 
     
    24972526        return mVspBspTree->CastBeam(beam); 
    24982527} 
     2528 
     2529 
     2530void VspBspViewCellsManager::Finalize(ViewCell *viewCell) 
     2531{ 
     2532        BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCell); 
     2533        CreateMesh(vc); 
     2534 
     2535        vector<BspLeaf *>::const_iterator it, it_end = vc->mLeaves.end(); 
     2536 
     2537        float area = 0; 
     2538        float volume = 0; 
     2539 
     2540        for (it = vc->mLeaves.begin(); it != it_end; ++ it) 
     2541        { 
     2542                BspNodeGeometry geom; 
     2543                BspLeaf *leaf = *it; 
     2544                mVspBspTree->ConstructGeometry(leaf, geom); 
     2545 
     2546                area += geom.GetArea(); 
     2547                volume += geom.GetVolume(); 
     2548        } 
     2549 
     2550        viewCell->SetVolume(volume); 
     2551        viewCell->SetArea(area); 
     2552} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r547 r551  
    216216        virtual float GetArea(ViewCell *viewCell) const; 
    217217 
    218         /** Returns volume of view cells. 
     218        /** Returns volume of view cell. 
    219219        */ 
    220220        virtual float GetVolume(ViewCell *viewCell) const; 
     
    259259        int GetMaxPvsSize() const; 
    260260 
    261  
    262261        /** Exports view cell geometry. 
    263262        */ 
    264263        virtual void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const = 0; 
    265264 
     265        virtual void FinalizeViewCells(const bool createMesh); 
     266 
    266267protected: 
    267268 
     
    271272        */ 
    272273        void CreateUniqueViewCellIds(); 
     274 
     275        /** Finalizes, i.e., creates mesh, volume, area etc. for the view cell. 
     276        */ 
     277        virtual void Finalize(ViewCell *viewCell, const bool createMesh); 
    273278 
    274279        /** Recollects view cells and resets statistics. 
     
    599604        void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const; 
    600605 
     606        //float GetVolume(ViewCell *viewCell) const; 
     607 
     608        void Finalize(ViewCell *viewCell); 
     609 
    601610protected: 
    602611 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r548 r551  
    8383        // maximum and minimum number of view cells 
    8484        environment->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells); 
     85 
     86        environment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
     87 
     88        //-- merge options 
    8589        environment->GetIntValue("VspBspTree.PostProcess.minViewCells", mMergeMinViewCells); 
    8690        environment->GetFloatValue("VspBspTree.PostProcess.maxCostRatio", mMergeMaxCostRatio); 
    87  
    88         environment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    8991        environment->GetBoolValue("VspBspTree.PostProcess.useRaysForMerge", mUseRaysForMerge); 
    9092 
     
    116118        Debug << "max plane candidates: " << mMaxRayCandidates << endl; 
    117119        Debug << "randomize: " << randomize << endl; 
    118  
     120        Debug << "minimum view cells: " << mMergeMinViewCells << endl; 
     121        Debug << "using area for pvs: " << mUseAreaForPvs << endl; 
    119122        Debug << "Split plane strategy: "; 
    120123        if (mSplitPlaneStrategy & RANDOM_POLYGON) 
     
    870873         
    871874        //TODO: for kd split geometry already is box 
    872         if (1 && mUseAreaForPvs) 
     875        if (1) 
    873876        { 
    874877                PolygonContainer::const_iterator it, it_end = tData.mGeometry->mPolys.end(); 
     
    10121015        {   // volume 
    10131016                pBack = pFront = pOverall * 0.5f; 
     1017                 
     1018#if 0 
    10141019                // box length substitute for probability 
    1015 #if 0 
    10161020                const float minBox = box.Min(axis); 
    10171021                const float maxBox = box.Max(axis); 
     
    16031607{ 
    16041608        ViewCell::NewMail(); 
    1605         CollectViewCells(mRoot, onlyValid, viewCells); 
     1609         
     1610        CollectViewCells(mRoot, onlyValid, viewCells, true); 
    16061611} 
    16071612 
     
    19011906 
    19021907 
     1908typedef pair<BspNode *, BspNodeGeometry *> bspNodePair; 
     1909 
    19031910int VspBspTree::FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors, 
    19041911                                                   const bool onlyUnmailed) const 
    19051912{ 
    1906         BspNodeGeometry geom; 
    1907         ConstructGeometry(n, geom); 
    1908  
    1909         stack<BspNode *> nodeStack; 
    1910         nodeStack.push(mRoot); 
    1911  
     1913        stack<bspNodePair> nodeStack; 
     1914         
     1915        BspNodeGeometry nodeGeom; 
     1916        ConstructGeometry(n, nodeGeom); 
     1917         
    19121918        // split planes from the root to this node 
    19131919        // needed to verify that we found neighbor leaf 
     
    19151921        ExtractHalfSpaces(n, halfSpaces); 
    19161922 
     1923 
     1924        BspNodeGeometry *rgeom = new BspNodeGeometry(); 
     1925        ConstructGeometry(mRoot, *rgeom); 
     1926 
     1927        nodeStack.push(bspNodePair(mRoot, rgeom)); 
     1928 
     1929 
    19171930        while (!nodeStack.empty()) 
    19181931        { 
    1919                 BspNode *node = nodeStack.top(); 
     1932                BspNode *node = nodeStack.top().first; 
     1933                BspNodeGeometry *geom = nodeStack.top().second; 
     1934 
    19201935                nodeStack.pop(); 
    19211936 
    1922                 if (node->IsLeaf()) 
    1923  
    1924                 {       // test if this leaf is in valid view space 
    1925             if (node->TreeValid() && 
    1926                                 node != n &&  
    1927                                 (!onlyUnmailed || !node->Mailed())) 
     1937                bool isAdjacent = true; 
     1938 
     1939                // test all planes of current node if still adjacent 
     1940                for (int i = 0; (i < halfSpaces.size()) && isAdjacent && (node != n); ++ i) 
     1941                { 
     1942                        const int cf = 
     1943                                Polygon3::ClassifyPlane(geom->mPolys, 
     1944                                                                                halfSpaces[i], 
     1945                                                                                mEpsilon); 
     1946 
     1947                        if (cf == Polygon3::BACK_SIDE) 
    19281948                        { 
    1929                                 // test all planes of current node if candidate really 
    1930                                 // is neighbour 
    1931                                 BspNodeGeometry neighborCandidate; 
    1932                                 ConstructGeometry(node, neighborCandidate); 
    1933  
    1934                                 bool isAdjacent = true; 
    1935                                 for (int i = 0; (i < halfSpaces.size()) && isAdjacent; ++ i) 
     1949                                isAdjacent = false; 
     1950                        } 
     1951                } 
     1952 
     1953                if (isAdjacent) 
     1954                { 
     1955                 
     1956                        if (node->IsLeaf()) 
     1957                        {        
     1958                                // test if this leaf is in valid view space 
     1959                                if (node->TreeValid() && 
     1960                                        node != n &&  
     1961                                        (!onlyUnmailed || !node->Mailed())) 
    19361962                                { 
    1937                                         const int cf = 
    1938                                                 Polygon3::ClassifyPlane(neighborCandidate.mPolys, 
    1939                                                                                                 halfSpaces[i], 
    1940                                                                                                 mEpsilon); 
    1941  
    1942                                         if (cf == Polygon3::BACK_SIDE) 
    1943                                                 isAdjacent = false; 
     1963                                        // neighbor was found 
     1964                                        neighbors.push_back(dynamic_cast<BspLeaf *>(node)); 
    19441965                                } 
    1945                                 // neighbor was found 
    1946                                 if (isAdjacent) 
    1947                                         neighbors.push_back(dynamic_cast<BspLeaf *>(node)); 
    19481966                        } 
    1949                 } 
    1950                 else 
    1951                 { 
    1952                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    1953  
    1954                         const int cf = Polygon3::ClassifyPlane(geom.mPolys, 
    1955                                                                                                    interior->GetPlane(), 
    1956                                                                                                    mEpsilon); 
    1957  
    1958                         if (cf == Polygon3::FRONT_SIDE) 
    1959                                 nodeStack.push(interior->GetFront()); 
    19601967                        else 
    1961                                 if (cf == Polygon3::BACK_SIDE) 
    1962                                         nodeStack.push(interior->GetBack()); 
     1968                        { 
     1969                                BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     1970 
     1971                                const int cf = Polygon3::ClassifyPlane(nodeGeom.mPolys, 
     1972                                                                                                           interior->GetPlane(), 
     1973                                                                                                           mEpsilon); 
     1974                         
     1975                                BspNode *front = interior->GetFront(); 
     1976                                BspNode *back = interior->GetBack(); 
     1977             
     1978                                BspNodeGeometry *fGeom = new BspNodeGeometry(); 
     1979                                BspNodeGeometry *bGeom = new BspNodeGeometry(); 
     1980 
     1981                                geom->SplitGeometry(*fGeom, 
     1982                                                                        *bGeom, 
     1983                                                                        interior->GetPlane(), 
     1984                                                                        mBox, 
     1985                                                                        mEpsilon); 
     1986                 
     1987                                if (cf == Polygon3::FRONT_SIDE) 
     1988                                { 
     1989                                        nodeStack.push(bspNodePair(interior->GetFront(), fGeom)); 
     1990                                        DEL_PTR(bGeom); 
     1991                                } 
    19631992                                else 
    19641993                                { 
    1965                                         // random decision 
    1966                                         nodeStack.push(interior->GetBack()); 
    1967                                         nodeStack.push(interior->GetFront()); 
     1994                                        if (cf == Polygon3::BACK_SIDE) 
     1995                                        { 
     1996                                                nodeStack.push(bspNodePair(interior->GetBack(), bGeom)); 
     1997                                                DEL_PTR(fGeom); 
     1998                                        } 
     1999                                        else 
     2000                                        {       // random decision 
     2001                                                nodeStack.push(bspNodePair(front, fGeom)); 
     2002                                                nodeStack.push(bspNodePair(back, bGeom)); 
     2003                                        } 
    19682004                                } 
    1969                 } 
     2005                        } 
     2006                } 
     2007 
     2008                DEL_PTR(geom); 
    19702009        } 
    19712010 
     
    26422681        if (0) 
    26432682        { 
     2683                cout << "finding additional merge candidates using geometry" << endl; 
    26442684                vector<BspLeaf *> leaves; 
    26452685                CollectLeaves(leaves, true); 
     
    27022742        mergeStats.Start(); 
    27032743        // TODO: REMOVE LATER for performance! 
    2704         const bool showMergeStats = true; 
     2744        const bool showMergeStats = false; 
    27052745        //BspMergeCandidate::sOverallCost = mBox.SurfaceArea() * mStat.maxPvs; 
    27062746        long startTime = GetTime(); 
    27072747 
    27082748        if (mUseRaysForMerge) 
     2749        { 
     2750                cout << "collecting merge candidates (rays) ... "; 
    27092751                mergeStats.nodes = CollectMergeCandidates(rays); 
     2752                cout << "fininshed collecting candidates" << endl; 
     2753        } 
    27102754        else 
    27112755        { 
     
    27142758                mergeStats.nodes = CollectMergeCandidates(leaves); 
    27152759        } 
     2760         
    27162761 
    27172762        mergeStats.collectTime = TimeDiff(startTime, GetTime()); 
     
    27222767        int pass = 0; 
    27232768        const int nextPass = 200; 
     2769 
     2770        cout << "starting merge ... "; 
    27242771 
    27252772        //-- use priority queue to merge leaf pairs 
     
    27442791 
    27452792                        MergeViewCells(mc.GetLeaf1(), mc.GetLeaf2()); 
    2746                         -- nViewCells; 
    2747                          
     2793                                                 
    27482794                         
    27492795                        // increase absolute merge cost 
     
    27742820                                                << "#CurrentPvs\n" << mc.GetLeaf1()->GetViewCell()->GetPvs().GetSize() << endl; 
    27752821 
     2822                                        cout << "exporting view cells ... "; 
    27762823                                        ViewCellContainer viewCells;     
    27772824                                        CollectViewCells(mRoot, false, viewCells); 
    27782825                         
     2826                                         
    27792827                                        char s[64]; 
    27802828                                        sprintf(s, "merged_viewcells%07d.x3d", nViewCells); 
     
    27842832                                        { 
    27852833                                                exporter->ExportGeometry(objects); 
    2786                                                 Debug << "vc size " << viewCells.size() << endl; 
     2834                                                Debug << "vc size " << (int)viewCells.size() << " merge queue size: " << (int)mMergeQueue.size() << endl; 
    27872835                                                ViewCellContainer::const_iterator it, it_end = viewCells.end(); 
    27882836                 
     
    27942842                                                delete exporter; 
    27952843                                        } 
     2844                                        cout << "finished " << endl; 
    27962845                                } 
    27972846                        } 
     2847 
     2848                        -- nViewCells; 
    27982849                        ++ mergeStats.merged; 
    2799  
    28002850                } 
    28012851                // merge candidate not valid, because one of the leaves was already 
     
    28072857                } 
    28082858        } 
    2809  
     2859        cout << "finished merge" << endl; 
    28102860        mergeStats.mergeTime = TimeDiff(startTime, GetTime()); 
    28112861        mergeStats.Stop(); 
     
    29112961 
    29122962 
    2913 float GetShuffledVcCost(BspLeaf *leaf, BspViewCell *vc1, BspViewCell *vc2, bool useArea) 
     2963float VspBspTree::GetShuffledVcCost(BspLeaf *leaf, BspViewCell *vc1, BspViewCell *vc2) const 
    29142964{ 
    29152965        //const int pvs1 = SubtractedPvsSize(vc1, leaf, *leaf->mPvs); 
     
    29172967        const int pvs2 = AddedPvsSize(vc2->GetPvs(), *leaf->mPvs); 
    29182968 
     2969        if (pvs1 + pvs2 > mViewCellsManager->GetMaxPvsSize()) 
     2970                return 1e15f; 
     2971 
    29192972        float p1, p2; 
    29202973 
    2921     if (useArea) 
     2974    if (mUseAreaForPvs) 
    29222975        { 
    29232976                p1 = vc1->GetArea() - leaf->mProbability; 
     
    30043057        // the view cell should not be empty after the shuffle 
    30053058        if (vc1->mLeaves.size() > 1) 
    3006                 shuffledCost1 = GetShuffledVcCost(leaf1, vc1, vc2, mUseAreaForPvs); 
     3059                shuffledCost1 = GetShuffledVcCost(leaf1, vc1, vc2); 
    30073060        if (vc2->mLeaves.size() > 1) 
    3008                 shuffledCost2 = GetShuffledVcCost(leaf2, vc2, vc1, mUseAreaForPvs); 
     3061                shuffledCost2 = GetShuffledVcCost(leaf2, vc2, vc1); 
    30093062 
    30103063        // shuffling unsuccessful 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r547 r551  
    611611        float GetMemUsage() const; 
    612612 
     613        float GetShuffledVcCost(BspLeaf *leaf, BspViewCell *vc1, BspViewCell *vc2) const; 
     614 
    613615        /// Pointer to the root of the tree 
    614616        BspNode *mRoot; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r540 r551  
    506506 
    507507  cout<<"mUseViewSpaceBox="<<mUseViewSpaceBox<<endl; 
     508  Debug << "use view space box=" << mUseViewSpaceBox << endl; 
    508509  if (mUseViewSpaceBox) 
    509510  { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.cpp

    r485 r551  
    177177    maxDepthNodes*100/(double)Leaves()<<endl; 
    178178 
    179   app << "#N_PMINPVSLEAVES  ( Percentage of leaves with minCost )\n"<< 
     179  app << "#N_PMINPVSLEAVES  ( Percentage of leaves with minPvs )\n"<< 
    180180    minPvsNodes*100/(double)Leaves()<<endl; 
    181181 
    182   app << "#N_PMINRAYSLEAVES  ( Percentage of leaves with minCost )\n"<< 
     182  app << "#N_PMINRAYSLEAVES  ( Percentage of leaves with minRays )\n"<< 
    183183    minRaysNodes*100/(double)Leaves()<<endl; 
    184184         
Note: See TracChangeset for help on using the changeset viewer.