Ignore:
Timestamp:
04/04/06 23:55:38 (18 years ago)
Author:
mattausch
Message:

improved performance of TerrainSceneManager?
revisit octreescenemanager

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

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp

    r704 r726  
    156156       
    157157      currentMesh->AddFace(face); 
    158       if (meshGrouping != 0 && 
    159                                         currentMesh->mFaces.size() >=  meshGrouping) { 
     158      if (meshGrouping != 0 && currentMesh->mFaces.size() >=  meshGrouping) { 
    160159                if (ROTATE_SCENE) 
    161160                        RotateMesh(currentMesh); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r719 r726  
    24412441                { 
    24422442                        geom.Add(candidatePolys[i], candidatePlanes[i]); 
    2443                         //      geom.mPolys.push_back(candidates[i]); 
    24442443                } 
    24452444        } 
     
    24562455 
    24572456 
    2458 int BspTree::FindNeighbors(BspNode *n, vector<BspLeaf *>  
    2459                                                    &neighbors, 
     2457int BspTree::FindNeighbors(BspNode *n,  
     2458                                                   vector<BspLeaf *> &neighbors, 
    24602459                                                   const bool onlyUnmailed) const 
    24612460{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r722 r726  
    21042104        { 
    21052105                exporter->ExportMesh(vc->GetMesh()); 
     2106         
    21062107                return; 
    21072108        } 
    21082109 
     2110         
     2111        if (clipPlane) 
     2112        { 
     2113                ViewCellContainer leaves; 
     2114                mViewCellsTree->CollectLeaves(vc, leaves); 
     2115                ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     2116 
     2117                for (it = leaves.begin(); it != it_end; ++ it) 
     2118                { 
     2119                        BspNodeGeometry geom; 
     2120 
     2121                        BspNodeGeometry front; 
     2122                        BspNodeGeometry back; 
     2123 
     2124                        BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
     2125                        mBspTree->ConstructGeometry(leaf, geom); 
     2126 
     2127                        const float eps = 0.00000001f; 
     2128                        const int cf = geom.Side(*clipPlane, eps); 
     2129 
     2130                        if (cf == -1) 
     2131                        { 
     2132                                exporter->ExportPolygons(geom.GetPolys()); 
     2133                        } 
     2134                        else if (cf == 0) 
     2135                        { 
     2136                                geom.SplitGeometry(front, 
     2137                                                                   back, 
     2138                                                                   *clipPlane, 
     2139                                                                   mViewSpaceBox,  
     2140                                                                   eps); 
     2141         
     2142                                //Debug << "geo size: " << geom.Size() << endl; 
     2143                                //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 
     2144                                if (back.Valid()) 
     2145                                { 
     2146                                        exporter->ExportPolygons(back.GetPolys()); 
     2147                                }                        
     2148                        } 
     2149                } 
     2150        } 
     2151        else 
     2152        { 
     2153                BspNodeGeometry geom; 
     2154                mBspTree->ConstructGeometry(vc, geom); 
     2155                         
     2156                exporter->ExportPolygons(geom.GetPolys()); 
     2157        } 
     2158} 
     2159 
     2160 
     2161void BspViewCellsManager::CreateMesh(ViewCell *vc) 
     2162{ 
     2163        // delete previous mesh 
     2164        ///DEL_PTR(vc->GetMesh()); 
    21092165        BspNodeGeometry geom; 
    21102166        mBspTree->ConstructGeometry(vc, geom); 
    21112167 
    2112         if (clipPlane) 
    2113         { 
    2114                 const int cf = Polygon3::ClassifyPlane(geom.GetPolys(), *clipPlane, 0.0001f); 
    2115  
    2116                 if (cf == Polygon3::BACK_SIDE) 
    2117                 { 
    2118                         exporter->ExportPolygons(geom.GetPolys()); 
    2119                 } 
    2120                 else if (cf == Polygon3::SPLIT) 
    2121                 { 
    2122                         BspNodeGeometry front; 
    2123                         BspNodeGeometry back; 
    2124  
    2125                         geom.SplitGeometry(front, 
    2126                                                            back, 
    2127                                                            *clipPlane, 
    2128                                                            mViewSpaceBox,  
    2129                                                            0.0001f); 
    2130  
    2131                         if (back.Valid()) 
    2132                                 exporter->ExportPolygons(back.GetPolys()); 
    2133                 } 
    2134         } 
    2135         else 
    2136         { 
    2137                 exporter->ExportPolygons(geom.GetPolys()); 
    2138         } 
    2139 } 
    2140  
    2141  
    2142 void BspViewCellsManager::CreateMesh(ViewCell *vc) 
    2143 { 
    2144         if (vc->GetMesh()) 
    2145                 delete vc->GetMesh(); 
    2146  
    2147         BspNodeGeometry geom; 
    2148          
    2149         mBspTree->ConstructGeometry(vc, geom); 
    2150  
    21512168        Mesh *mesh = new Mesh(); 
     2169 
    21522170        geom.AddToMesh(*mesh); 
    21532171        vc->SetMesh(mesh); 
     2172        // put mesh into mesh container so we can savely delete it 
    21542173        mMeshContainer.push_back(mesh); 
    21552174} 
     
    27852804} 
    27862805 
     2806 
    27872807void VspKdViewCellsManager::Visualize(const ObjectContainer &objects, 
    27882808                                                                          const VssRayContainer &sampleRays) 
     
    28822902        Exporter *exporter = Exporter::GetExporter("vspkdtree_merged.x3d"); 
    28832903 
    2884         //if (exportGeometry) exporter->SetWireframe(); 
    2885         //else exporter->SetFilled(); 
    28862904 
    28872905        ExportViewCellsForViz(exporter); 
     
    40004018void VspBspViewCellsManager::CreateMesh(ViewCell *vc) 
    40014019{ 
    4002         if (vc->GetMesh()) 
    4003                 delete vc->GetMesh(); 
    4004  
    4005          
     4020        //if (vc->GetMesh()) delete vc->GetMesh(); 
    40064021        BspNodeGeometry geom; 
    40074022 
     
    40114026        geom.AddToMesh(*mesh); 
    40124027        vc->SetMesh(mesh); 
     4028        // put mesh into mesh container so we can savely delete it 
    40134029        mMeshContainer.push_back(mesh); 
    40144030} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r719 r726  
    458458 
    459459        EvalPriority(tData); 
    460          
    461  
    462         if (mSimulateOctree) 
    463         tData.mAxis = 0; 
     460 
    464461 
    465462        // first node is kd node, i.e. an axis aligned box 
     
    569566                                                          geom); 
    570567 
    571          
    572568 
    573569        // compute first split candidate 
     
    695691                VspBspTraversalData tBackData; 
    696692 
    697                 if (mSimulateOctree) 
    698                 {       // choose axes in circular motion 
    699                         tFrontData.mAxis = (tData.mAxis + 1) % 3; 
    700                         tBackData.mAxis = (tData.mAxis + 1) % 3; 
    701                 } 
    702  
    703693                // create new interior node and two leaf nodes 
    704694                // or return leaf as it is (if maxCostRatio missed) 
     
    709699                Plane3 splitPlane; 
    710700                BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
    711  
     701                 
     702                // choose next split plane 
    712703                if (!SelectPlane(splitPlane, leaf, tData, tFrontData, tBackData, splitAxis)) 
    713704                { 
     
    722713                } 
    723714         
     715                // if this a valid split => subdivide this node further 
    724716                if (splitFurther) //-- continue subdivision 
    725717                { 
     
    732724 
    733725                        tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && (splitAxis < 3)); 
     726                        tFrontData.mAxis = tBackData.mAxis = splitAxis; 
    734727 
    735728                        // how often was max cost ratio missed in this branch? 
     
    740733                        EvalPriority(tBackData); 
    741734 
     735                        // evaluate subdivision stats 
    742736                        if (1) 
    743737                        { 
    744  
    745738                                float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 
    746739                                float cBack = (float)tBackData.mPvs * tBackData.mProbability; 
     
    823816} 
    824817 
    825  
     818// subdivide using a split plane queue 
    826819BspNode *VspBspTree::Subdivide(VspBspSplitQueue &tQueue, 
    827820                                                           VspBspSplitCandidate &splitCandidate) 
     
    839832 
    840833                //-- continue subdivision 
     834                 
    841835                // create new interior node and two leaf node 
    842836                const Plane3 splitPlane = splitCandidate.mSplitPlane; 
     
    853847 
    854848                tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && (splitAxis < 3)); 
    855                  
     849                tFrontData.mAxis = tBackData.mAxis = splitAxis; 
     850 
    856851                // how often was max cost ratio missed in this branch? 
    857852                tFrontData.mMaxCostMisses = maxCostMisses; 
     
    960955 
    961956        // compute locally best split plane 
    962         bool success = SelectPlane(splitData.mSplitPlane, leaf, tData,  
     957    bool success = SelectPlane(splitData.mSplitPlane, leaf, tData,  
    963958                                                           frontData, backData, splitData.mSplitAxis); 
    964959 
     
    14031398                sAxis = Random(3); 
    14041399        else if (mSimulateOctree) 
    1405                 sAxis = tData.mAxis; 
     1400                sAxis = (tData.mAxis + 1) % 3; 
    14061401                 
    14071402        //Debug << "use special axis: " << useSpecialAxis << endl; 
     
    20122007 
    20132008        const int pvsSize = data.mPvs; 
    2014 //cout << "here433" << endl; 
     2009 
    20152010        RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 
    20162011 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r712 r726  
    11451145                for (oit = objects.begin(); oit != oit_end; ++ oit) 
    11461146                { 
    1147                         if (1) 
    1148                         { 
     1147                        if (0) 
    11491148                                SetForcedMaterial(RandomMaterial()); 
    1150                         } 
    1151  
     1149                         
    11521150                        ExportIntersectable(*oit); 
    11531151                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r712 r726  
    5757 
    5858 
     59static void RotateMesh(Mesh *mesh) 
     60{ 
     61        VertexContainer::iterator it, it_end = mesh->mVertices.end(); 
     62 
     63        const float angle = 30.0f * PI / 180.0f; 
     64        const Matrix4x4 rot = RotationYMatrix(angle); 
     65 
     66        for (it = mesh->mVertices.begin(); it != it_end; ++ it) 
     67        { 
     68                (*it) = rot * (*it);         
     69        } 
     70} 
    5971 
    6072// --------------------------------------------------------------------------- 
     
    96108 
    97109 
    98 static void RotateMesh(Mesh *mesh) 
    99 { 
    100         VertexContainer::iterator it, it_end = mesh->mVertices.end(); 
    101  
    102         const float angle = 30.0f * PI / 180.0f; 
    103         const Matrix4x4 rot = RotationYMatrix(angle); 
    104  
    105         for (it = mesh->mVertices.begin(); it != it_end; ++ it) 
    106         { 
    107                 (*it) = rot * (*it);         
    108         } 
    109 } 
    110110 
    111111 
Note: See TracChangeset for help on using the changeset viewer.