Changeset 675


Ignore:
Timestamp:
03/06/06 09:17:09 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj

    r672 r675  
    150150                                Filter=""> 
    151151                                <File 
     152                                        RelativePath="..\include\OgreOcclusionCullingSceneManager.h"> 
     153                                </File> 
     154                                <File 
    152155                                        RelativePath="..\include\OgreOctreeHierarchyInterface.h"> 
    153156                                </File> 
     
    167170                                <File 
    168171                                        RelativePath="..\src\OgreBspHierarchyInterface.cpp"> 
     172                                </File> 
     173                                <File 
     174                                        RelativePath="..\src\OgreOcclusionCullingSceneManager.cpp"> 
    169175                                </File> 
    170176                                <File 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp

    r347 r675  
    1 #include "OgreVisibilityTerrainSceneManager.h" 
     1#include "OgreOcclusionCullingSceneManager.h" 
    22#include "OgreVisibilityOptionsManager.h" 
    33#include <OgreMath.h> 
     
    1414 
    1515//----------------------------------------------------------------------- 
    16 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 
     16OcclusionCullingSceneManager::OcclusionCullingSceneManager( 
    1717                                                        GtpVisibility::VisibilityManager *visManager):  
    1818mVisibilityManager(visManager),  
     
    4545} 
    4646//----------------------------------------------------------------------- 
    47 void VisibilityTerrainSceneManager::InitDepthPass() 
     47void OcclusionCullingSceneManager::InitDepthPass() 
    4848{ 
    4949        MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass"); 
     
    6666} 
    6767//----------------------------------------------------------------------- 
    68 VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager() 
     68OcclusionCullingSceneManager::~OcclusionCullingSceneManager() 
    6969{ 
    7070        OGRE_DELETE(mHierarchyInterface); 
    7171} 
    7272//----------------------------------------------------------------------- 
    73 void VisibilityTerrainSceneManager::InitItemBufferPass() 
     73void OcclusionCullingSceneManager::InitItemBufferPass() 
    7474{ 
    7575        MaterialPtr itemBufferMat = MaterialManager::getSingleton(). 
     
    9595} 
    9696//------------------------------------------------------------------------- 
    97 void VisibilityTerrainSceneManager::setWorldGeometry( const String& filename ) 
     97void OcclusionCullingSceneManager::setWorldGeometry( const String& filename ) 
    9898{ 
    9999    // Clear out any existing world resources (if not default) 
     
    124124 
    125125//----------------------------------------------------------------------- 
    126 void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam) 
     126void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam) 
    127127{ 
    128128        // add player camera for visualization purpose 
     
    173173} 
    174174//----------------------------------------------------------------------- 
    175 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 
     175Pass *OcclusionCullingSceneManager::setPass(Pass* pass) 
    176176{ 
    177177        // TODO: setting vertex program is not efficient 
     
    236236} 
    237237//----------------------------------------------------------------------- 
    238 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, 
     238void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam, 
    239239                                                                                                                bool onlyShadowCasters) 
    240240{ 
     
    266266} 
    267267//----------------------------------------------------------------------- 
    268 void VisibilityTerrainSceneManager::_renderVisibleObjects() 
     268void OcclusionCullingSceneManager::_renderVisibleObjects() 
    269269{ 
    270270 
     
    354354                if (mUseDepthPass) 
    355355                { 
    356                         for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
     356                        for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++ it) 
    357357                        { 
    358358                                (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 
     
    381381 
    382382//----------------------------------------------------------------------- 
    383 void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam) 
     383void OcclusionCullingSceneManager::_updateSceneGraph(Camera* cam) 
    384384{ 
    385385        mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 
     
    389389} 
    390390//----------------------------------------------------------------------- 
    391 bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val) 
     391bool OcclusionCullingSceneManager::setOption(const String & key, const void * val) 
    392392{ 
    393393        if (key == "UseDepthPass") 
     
    482482} 
    483483//----------------------------------------------------------------------- 
    484 bool VisibilityTerrainSceneManager::getOption(const String & key, void *val) 
     484bool OcclusionCullingSceneManager::getOption(const String & key, void *val) 
    485485{ 
    486486        if (key == "NumHierarchyNodes") 
     
    494494} 
    495495//----------------------------------------------------------------------- 
    496 bool VisibilityTerrainSceneManager::getOptionValues(const String & key,  
     496bool OcclusionCullingSceneManager::getOptionValues(const String & key,  
    497497                                                                                                        StringVector &refValueList) 
    498498{ 
     
    500500} 
    501501//----------------------------------------------------------------------- 
    502 bool VisibilityTerrainSceneManager::getOptionKeys(StringVector & refKeys) 
     502bool OcclusionCullingSceneManager::getOptionKeys(StringVector & refKeys) 
    503503{ 
    504504        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
     
    506506} 
    507507//----------------------------------------------------------------------- 
    508 void VisibilityTerrainSceneManager::setVisibilityManager(GtpVisibility:: 
     508void OcclusionCullingSceneManager::setVisibilityManager(GtpVisibility:: 
    509509                                                                                                                 VisibilityManager *visManager) 
    510510{ 
     
    512512} 
    513513//----------------------------------------------------------------------- 
    514 GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager( void ) 
     514GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::getVisibilityManager( void ) 
    515515{ 
    516516        return mVisibilityManager; 
    517517} 
    518518//----------------------------------------------------------------------- 
    519 void VisibilityTerrainSceneManager::WriteLog() 
     519void OcclusionCullingSceneManager::WriteLog() 
    520520{ 
    521521        std::stringstream d; 
     
    535535} 
    536536//----------------------------------------------------------------------- 
    537 void VisibilityTerrainSceneManager::renderObjects( 
     537void OcclusionCullingSceneManager::renderObjects( 
    538538        const RenderPriorityGroup::TransparentRenderablePassList& objs,  
    539539    bool doLightIteration, const LightList* manualLightList) 
     
    546546} 
    547547//----------------------------------------------------------------------- 
    548 bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass) 
     548bool OcclusionCullingSceneManager::validatePassForRendering(Pass* pass) 
    549549{ 
    550550        // skip all but first pass if we are doing the depth pass 
     
    553553                return false; 
    554554        } 
     555 
    555556        return SceneManager::validatePassForRendering(pass); 
    556557} 
    557558//----------------------------------------------------------------------- 
    558 void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 
     559void OcclusionCullingSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 
    559560{ 
    560561        if (!mIsItemBufferPhase) 
     
    575576} 
    576577//----------------------------------------------------------------------- 
    577 void VisibilityTerrainSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) 
     578void OcclusionCullingSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) 
    578579{ 
    579580        // Do solids 
     
    632633} 
    633634//----------------------------------------------------------------------- 
    634 void VisibilityTerrainSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass) 
     635void OcclusionCullingSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass) 
    635636{ 
    636637        static LightList nullLightList; 
     
    677678} 
    678679//----------------------------------------------------------------------- 
    679 GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::GetVisibilityManager() 
     680GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::GetVisibilityManager() 
    680681{ 
    681682        return mVisibilityManager; 
    682683} 
    683684//----------------------------------------------------------------------- 
    684 void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam) 
     685void OcclusionCullingSceneManager::InitVisibilityCulling(Camera *cam) 
    685686{ 
    686687        // reset culling manager stats 
     
    742743        // possible two cameras (one for culling, one for rendering) 
    743744        mHierarchyInterface->InitTraversal(mCameraInProgress,  
    744                                                         mCullCamera ? getCamera("CullCamera") : NULL, 
    745                                                         mLeavePassesInQueue); 
     745                                                                           mCullCamera ? getCamera("CullCamera") : NULL, 
     746                                                                           mLeavePassesInQueue); 
    746747                 
    747748        //std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;LogManager::getSingleton().logMessage(d.str()); 
    748749} 
    749750//----------------------------------------------------------------------- 
    750 OctreeHierarchyInterface *VisibilityTerrainSceneManager::GetHierarchyInterface() 
     751OctreeHierarchyInterface *OcclusionCullingSceneManager::GetHierarchyInterface() 
    751752{ 
    752753        return mHierarchyInterface; 
    753754} 
    754755//----------------------------------------------------------------------- 
    755 void VisibilityTerrainSceneManager::endFrame() 
     756void OcclusionCullingSceneManager::endFrame() 
    756757{ 
    757758        TerrainRenderable::ResetRenderLevelIndex(); 
    758759} 
    759760//----------------------------------------------------------------------- 
    760 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName,  
     761Entity* OcclusionCullingSceneManager::createEntity(const String& entityName,  
    761762                                                                                                        const String& meshName) 
    762763{ 
     
    774775} 
    775776//----------------------------------------------------------------------- 
    776 void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 
     777void OcclusionCullingSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 
    777778{ 
    778779        // only render solid passes during hierarchical culling 
     
    806807} 
    807808//----------------------------------------------------------------------- 
    808 void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 
     809void OcclusionCullingSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 
    809810{ 
    810811   if (mIsHierarchicalCulling) 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/egsr_test_script

    r674 r675  
    22PROGRAM=../bin/release/Preprocessor.exe 
    33 
    4 #SCENE=soda5 
     4SCENE=soda5 
    55#SCENE=soda 
    6 SCENE=atlanta 
     6#SCENE=atlanta 
    77#SCENE=vienna 
    88 
     
    3232-view_cells_post_process_merge=true \ 
    3333-vsp_bsp_term_min_pvs=0 \ 
     34-view_cells_evaluation_samples=1000000 \ 
    3435-view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d 
    3536 
     
    5859-view_cells_post_process_merge=false \ 
    5960-vsp_bsp_term_min_pvs=0 \ 
    60 -view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d 
    61  
    62 mv debug.log $LOG_PREFIX-$METHOD-debug.log 
     61-view_cells_evaluation_samples=1000000 \ 
     62-view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d 
     63 
     64mv debug.log $LOG_PREFIX-$METHOD-debug.log 
     65 
     66 
     67 
    6368 
    6469 
     
    8691 
    8792mv debug.log $LOG_PREFIX-$METHOD-debug.log 
     93 
     94 
    8895 
    8996 
     
    110117-vsp_bsp_max_poly_candidates=0 \ 
    111118-vsp_bsp_breath_first_splits=true \ 
    112 -vsp_bsp_term_min_pvs=15 \ 
     119-vsp_bsp_term_min_pvs=50 \ 
    113120-view_cells_construction_samples=0 \ 
    114121-vsp_bsp_use_split_cost_queue=false \ 
    115 -vsp_bsp_term_max_depth=20 \ 
     122-vsp_bsp_term_max_depth=19 \ 
    116123-view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d  
    117124 
     
    271278 
    272279################################################################ 
    273 #             vspbsptree - many samples                        # 
     280#             vspbsptree - many samples - no queue             # 
    274281################################################################ 
    275282 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r674 r675  
    11801180                                 optBool, 
    11811181                                 "vss_enlarge_viewspace=", 
    1182                                  "true"); 
     1182                                 "false"); 
    11831183 
    11841184   RegisterOption("VssPreprocessor.loadInitialSamples", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r664 r675  
    3030  environment->GetBoolValue("Preprocessor.loadPolygonsAsMeshes", mLoadPolygonsAsMeshes); 
    3131  environment->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish); 
     32  Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl; 
    3233 
    3334} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r666 r675  
    621621        } 
    622622 
     623         
    623624        // adjust stats and reset queue one final time 
    624625        mExpectedCost = realExpectedCost; 
     
    628629        UpdateActiveViewCells(activeViewCells); 
    629630 
     631         
    630632        // refine view cells and reset costs 
    631633        if (mRefineViewCells) 
     
    659661                mMergeQueue.pop(); 
    660662        } 
    661          
    662          
     663 
    663664        // TODO delete because makes no sense here 
    664665        mergeStats.expectedRenderCost = realExpectedCost; 
     
    676677        // assign colors for the view cells so that at least one is always consistent 
    677678        AssignRandomColors(); 
     679         
    678680        //TODO: should return sample contributions? 
    679681        return mergeStats.merged; 
     
    16801682void ViewCellsTree::AssignRandomColors() 
    16811683{ 
    1682   TraversalQueue tqueue; 
    1683   tqueue.push(mRoot); 
    1684   mRoot->SetColor(RandomColor(0.3f, 1.0f)); 
    1685  
    1686   while (!tqueue.empty()) 
    1687         { 
    1688           ViewCell *vc = tqueue.top(); 
    1689           tqueue.pop(); 
    1690  
    1691           // save the view cells if it is a leaf or if enough view cells have already been traversed 
    1692           // because of the priority queue, this will be the optimal set of v 
    1693           if (!vc->IsLeaf()) {   
    1694                 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
    1695                  
    1696                 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    1697                 float maxProbability = -1.0f; 
    1698                 ViewCell *maxViewCell = NULL; 
    1699                 for (it = interior->mChildren.begin(); it != it_end; ++ it) { 
    1700                   ViewCell *v = *it; 
    1701                   // set random color 
    1702                   v->SetColor(RandomColor(0.3f, 1.0f)); 
    1703                   if (v->GetVolume() > maxProbability) { 
    1704                         maxProbability = v->GetVolume(); 
    1705                         maxViewCell = v; 
    1706                   } 
    1707                   maxViewCell->SetColor(vc->GetColor()); 
    1708                   tqueue.push(v); 
    1709                 } 
    1710                  
    1711           } 
    1712           
    1713         } 
    1714 } 
     1684        TraversalQueue tqueue; 
     1685         
     1686        tqueue.push(mRoot); 
     1687        mRoot->SetColor(RandomColor(0.3f, 1.0f)); 
     1688         
     1689        while (!tqueue.empty()) 
     1690        { 
     1691                ViewCell *vc = tqueue.top(); 
     1692                tqueue.pop(); 
     1693 
     1694                // save the view cells if it is a leaf or if enough view cells have already been traversed 
     1695                // because of the priority queue, this will be the optimal set of v 
     1696                if (!vc->IsLeaf())  
     1697                {        
     1698                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1699                   
     1700                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1701                   
     1702                        float maxProbability = -1.0f; 
     1703                   
     1704                        ViewCell *maxViewCell = NULL; 
     1705                        for (it = interior->mChildren.begin(); it != it_end; ++ it)  
     1706                        { 
     1707                                ViewCell *v = *it; 
     1708                           
     1709                                // set random color 
     1710                                v->SetColor(RandomColor(0.3f, 1.0f)); 
     1711                           
     1712                                if (v->GetVolume() > maxProbability)  
     1713                                { 
     1714                                        maxProbability = v->GetVolume(); 
     1715                                        maxViewCell = v; 
     1716                                } 
     1717 
     1718                                if (maxViewCell) 
     1719                                        maxViewCell->SetColor(vc->GetColor()); 
     1720                                 
     1721                                tqueue.push(v); 
     1722                        } 
     1723                }         
     1724        } 
     1725} 
     1726 
    17151727 
    17161728/** Get costs resulting from each merge step. */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r667 r675  
    980980                viewCell->mLeaf = leaf; 
    981981 
     982                float probability = max(0.0f, tData.mProbability); 
     983 
    982984                if (mUseAreaForPvs) 
    983                         viewCell->SetArea(tData.mProbability); 
     985                        viewCell->SetArea(probability); 
    984986                else 
    985                         viewCell->SetVolume(tData.mProbability); 
    986                  
     987                        viewCell->SetVolume(probability); 
     988 
    987989                //-- add pvs 
    988990                if (viewCell != mOutOfBoundsCell) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r670 r675  
    396396 
    397397        mBspStats.polys = (int)polys.size(); 
    398  
    399398        mGlobalCostMisses = 0; 
    400399 
     
    739738                        if (1) 
    740739                        { 
     740 
    741741                                float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 
    742742                                float cBack = (float)tBackData.mPvs * tBackData.mProbability; 
     
    859859                        float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 
    860860                        float cBack = (float)tBackData.mPvs * tBackData.mProbability; 
    861                         float cData = (float)tData.mPvs * tData.mProbability;; 
    862  
     861                        float cData = (float)tData.mPvs * tData.mProbability; 
     862 
     863                         
    863864                        float costDecr =  
    864865                                (cFront + cBack - cData) / mBox.GetVolume(); 
     
    926927                        viewCell->SetVolume(tData.mProbability); 
    927928 
    928                 leaf->mProbability = tData.mProbability; 
     929        leaf->mProbability = tData.mProbability; 
    929930 
    930931                EvaluateLeafStats(tData);                
     
    10101011                                                                           splitPlane, 
    10111012                                                                           mBox, 
    1012                                                                            mEpsilon); 
     1013                                                                           0.0000001f); 
     1014                                                                           //mEpsilon); 
    10131015                 
    10141016                if (mUseAreaForPvs) 
     
    10211023                        frontData.mProbability = frontData.mGeometry->GetVolume(); 
    10221024                        backData.mProbability = tData.mProbability - frontData.mProbability; 
     1025                        // clamp because of precision issues 
     1026                        if (frontData.mProbability < 0) frontData.mProbability = 0; 
     1027                        if (backData.mProbability < 0) backData.mProbability = 0; 
    10231028                } 
    10241029        } 
     
    16871692                                                                  candidatePlane, 
    16881693                                                                  mBox, 
    1689                                                                   mEpsilon); 
     1694                                                                  0.0000001f); 
     1695                                                                  //mEpsilon); 
    16901696 
    16911697        if (!mUseAreaForPvs) // use front and back cell areas to approximate volume 
     
    16931699                pFront = geomFront.GetVolume(); 
    16941700                pBack = pOverall - pFront; 
     1701 
     1702                // clamp because of possible precision issues 
     1703                if (pFront < 0) pFront = 0; 
     1704                if (pBack < 0) pBack = 0; 
    16951705        } 
    16961706        else 
     
    17751785                                                                  candidatePlane, 
    17761786                                                                  mBox, 
     1787 
    17771788                                                                  mEpsilon); 
    17781789 
     
    17831794                pFront = geomFront.GetVolume(); 
    17841795                pBack = pOverall - pFront; 
     1796                 
     1797                // clamp because of possible precision issues 
     1798                if (pFront < 0) pFront = 0; 
     1799                if (pBack < 0) pBack = 0; 
    17851800        } 
    17861801        else 
     
    26722687                                                                interior->GetPlane(), 
    26732688                                                                mBox, 
     2689                                                                //0.0000001f); 
    26742690                                                                mEpsilon); 
    26752691                 
     
    27632779                                                                interior->GetPlane(), 
    27642780                                                                mBox, 
     2781                                                                //0.0000001f); 
    27652782                                                                mEpsilon); 
    27662783                 
     
    32533270                                                                        interior->GetPlane(), 
    32543271                                                                        mBox, 
     3272                                                                        //0.0000001f); 
    32553273                                                                        mEpsilon); 
    32563274 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r674 r675  
    3636  useViewspacePlane = mUseViewSpaceBox; //hack 
    3737 
     38   
     39  Debug << "*********** vss preprocessor options **************" << endl; 
     40  Debug << "use view space box=" << mUseViewSpaceBox << endl; 
     41  Debug << "enlarge view space=" << mEnlargeViewSpace << endl; 
     42  Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 
     43 
     44  Debug << "*********** end vss preprocessor options **************" << endl; 
     45 
    3846  mStats.open("stats.log"); 
    3947} 
     
    7785 
    7886    int hits = 0; 
    79   static Ray ray; 
    80   AxisAlignedBox3 box =  mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 
    81  
    82   AxisAlignedBox3 sbox = box; 
    83   sbox.Enlarge(Vector3(-Limits::Small)); 
    84   if (!sbox.IsInside(viewPoint)) 
    85         return 0; 
    86          
    87   SetupRay(ray, viewPoint, direction); 
    88   // cast ray to KD tree to find intersection with other objects 
    89   Intersectable *objectA, *objectB; 
    90   Vector3 pointA, pointB; 
    91   float bsize = Magnitude(box.Size()); 
    92  
     87        static Ray ray; 
     88         
     89        AxisAlignedBox3 box =  mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 
     90        AxisAlignedBox3 sbox = box; 
     91     
     92        sbox.Enlarge(Vector3(-Limits::Small)); 
     93         
     94        if (!sbox.IsInside(viewPoint)) 
     95                return 0; 
     96         
     97        SetupRay(ray, viewPoint, direction); 
     98         
     99        // cast ray to KD tree to find intersection with other objects 
     100        Intersectable *objectA, *objectB; 
     101        Vector3 pointA, pointB; 
     102        float bsize = Magnitude(box.Size()); 
    93103 
    94104        if (!mDetectEmptyViewSpace) 
    95           ray.mFlags &= ~Ray::CULL_BACKFACES; 
     105                ray.mFlags &= ~Ray::CULL_BACKFACES; 
    96106        else 
    97           ray.mFlags |= Ray::CULL_BACKFACES; 
    98  
    99   if (mKdTree->CastRay(ray)) { 
    100         objectA = ray.intersections[0].mObject; 
    101         pointA = ray.Extrap(ray.intersections[0].mT); 
    102   } else { 
    103         objectA = NULL; 
    104         // compute intersection with the scene bounding box 
    105         float tmin, tmax; 
    106         if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 
    107           pointA = ray.Extrap(tmax); 
     107                ray.mFlags |= Ray::CULL_BACKFACES; 
     108 
     109        if (mKdTree->CastRay(ray))  
     110        { 
     111                objectA = ray.intersections[0].mObject; 
     112                pointA = ray.Extrap(ray.intersections[0].mT); 
     113        }  
     114        else  
     115        { 
     116                objectA = NULL; 
     117                // compute intersection with the scene bounding box 
     118                float tmin, tmax; 
     119                if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 
     120                        pointA = ray.Extrap(tmax); 
     121                else 
     122                        return 0; 
     123        } 
     124 
     125         
     126        if (mDetectEmptyViewSpace) { 
     127                SetupRay(ray, pointA, -direction); 
     128        } else 
     129                SetupRay(ray, viewPoint, -direction); 
     130   
     131        if (!mDetectEmptyViewSpace) 
     132                ray.mFlags &= ~Ray::CULL_BACKFACES; 
    108133        else 
    109           return 0; 
    110   } 
    111  
    112          
    113   if (mDetectEmptyViewSpace) { 
    114         SetupRay(ray, pointA, -direction); 
    115   } else 
    116         SetupRay(ray, viewPoint, -direction); 
    117    
    118   if (!mDetectEmptyViewSpace) 
    119         ray.mFlags &= ~Ray::CULL_BACKFACES; 
    120   else 
    121          ray.mFlags |= Ray::CULL_BACKFACES; 
    122  
    123   if (mKdTree->CastRay(ray)) { 
    124         objectB = ray.intersections[0].mObject; 
    125         pointB = ray.Extrap(ray.intersections[0].mT); 
    126   } else { 
    127         objectB = NULL; 
    128         float tmin, tmax; 
    129         if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 
    130           pointB = ray.Extrap(tmax); 
    131         else 
    132           return 0; 
    133   } 
    134    
    135   //  if (objectA == NULL && objectB != NULL) { 
    136   if (mDetectEmptyViewSpace) { 
    137         // cast again to ensure that there is no objectA 
    138         SetupRay(ray, pointB, direction); 
    139           ray.mFlags |= Ray::CULL_BACKFACES; 
    140         if (mKdTree->CastRay(ray)) { 
    141           objectA = ray.intersections[0].mObject; 
    142           pointA = ray.Extrap(ray.intersections[0].mT); 
    143         } 
    144   } 
    145  
    146    
    147   VssRay *vssRay  = NULL; 
    148  
    149   bool validSample = (objectA != objectB); 
    150   if (0 && mDetectEmptyViewSpace) {   // consider all samples valid 
    151         // check if the viewpoint lies on the line segment AB 
    152         if (Distance(pointA, pointB) < 
    153                 Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) { 
    154           validSample = false; 
    155         } 
    156   } 
    157          
    158   if (validSample) { 
    159         if (objectA) { 
    160           vssRay = new VssRay(pointB, 
    161                                                   pointA, 
    162                                                   objectB, 
    163                                                   objectA, 
    164                                                   mPass 
    165                                                   ); 
    166           vssRays.push_back(vssRay); 
    167           hits ++; 
    168         } 
    169          
    170         if (objectB) { 
    171           vssRay = new VssRay(pointA, 
    172                                                   pointB, 
    173                                                   objectA, 
    174                                                   objectB, 
    175                                                   mPass 
    176                                                   ); 
    177           vssRays.push_back(vssRay); 
    178           hits ++; 
    179         } 
    180   } 
    181          
    182   return hits; 
     134                ray.mFlags |= Ray::CULL_BACKFACES; 
     135 
     136        if (mKdTree->CastRay(ray))  
     137        { 
     138                objectB = ray.intersections[0].mObject; 
     139                pointB = ray.Extrap(ray.intersections[0].mT); 
     140        }  
     141        else  
     142        { 
     143                objectB = NULL; 
     144                float tmin, tmax; 
     145                 
     146                if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 
     147                        pointB = ray.Extrap(tmax); 
     148                else 
     149                        return 0; 
     150        } 
     151   
     152        //  if (objectA == NULL && objectB != NULL) { 
     153        if (mDetectEmptyViewSpace)  
     154        { 
     155                // cast again to ensure that there is no objectA 
     156                SetupRay(ray, pointB, direction); 
     157                ray.mFlags |= Ray::CULL_BACKFACES; 
     158                 
     159                if (mKdTree->CastRay(ray))  
     160                { 
     161                        objectA = ray.intersections[0].mObject; 
     162                        pointA = ray.Extrap(ray.intersections[0].mT); 
     163                } 
     164        } 
     165 
     166   
     167        VssRay *vssRay  = NULL; 
     168 
     169        bool validSample = (objectA != objectB); 
     170 
     171        if (0 && mDetectEmptyViewSpace)  
     172        {    
     173                // consider all samples valid 
     174                // check if the viewpoint lies on the line segment AB 
     175                if (Distance(pointA, pointB) < 
     176                        Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small)  
     177                { 
     178                        validSample = false; 
     179                } 
     180        } 
     181         
     182        if (validSample)  
     183        {        
     184                if (objectA)  
     185                { 
     186                        vssRay = new VssRay(pointB, 
     187                                                                pointA, 
     188                                                                objectB, 
     189                                                                objectA, 
     190                                                                mPass); 
     191                        vssRays.push_back(vssRay); 
     192                        hits ++; 
     193                } 
     194 
     195                if (objectB)  
     196                { 
     197                        vssRay = new VssRay(pointA, 
     198                                                                pointB, 
     199                                                                objectA, 
     200                                                                objectB, 
     201                                                                mPass); 
     202                        vssRays.push_back(vssRay); 
     203                        hits ++; 
     204                } 
     205        } 
     206         
     207        return hits; 
    183208} 
    184209 
     
    528553 
    529554  cout<<"mUseViewSpaceBox="<<mUseViewSpaceBox<<endl; 
    530   Debug << "use view space box=" << mUseViewSpaceBox << endl; 
     555 
    531556 
    532557  if (mUseViewSpaceBox) 
  • GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp

    r670 r675  
    3838 
    3939        int currentTag = NO_TAG; 
    40          
     40 
    4141        while (!(getline(file, buf)).eof()) 
    4242        { 
     
    106106                         //<< "#TotalRenderCostGain\n" << 100.0f - costRatio * 100.0f << endl 
    107107                         //<< "#AvgRenderCostGain\n" << 100.0f - avgCostRatio * 100.0f << endl << endl; 
    108                          << "#TotalRenderCostGain\n" << 100.0f * costRatio - 100.0f<< endl 
    109                          << "#AvgRenderCostGain\n" << 100.0f * avgCostRatio -100.0f << endl << endl; 
    110 } 
    111  
     108                         << "#TotalRenderCostRatio\n" << costRatio << endl 
     109                         << "#AvgRenderCostRatio\n" << avgCostRatio << endl << endl; 
     110} 
     111 
     112 
     113int ComputeNoViewCells(const StatsContainer &firstStats,  
     114                                           const StatsContainer &currentStats) 
     115{ 
     116        const int n = min((int)firstStats.size(), (int)currentStats.size()); 
     117 
     118        const float renderCost = (int)currentStats[n - 1].mRenderCost; 
     119 
     120        int i = 0; 
     121        while ((i ++ < (int)firstStats.size()) && (renderCost > (int)firstStats[i].mRenderCost)); 
     122         
     123        return i; 
     124} 
    112125 
    113126 
     
    129142                StatsContainer currentStats; 
    130143       
    131                 ifstream file(argv[i]); 
     144                ifstream file; 
     145                file.open(argv[i]); 
    132146 
    133147                // extract the render cost 
    134148                cout << "extracting render cost of file " << argv[i] << endl; 
    135                 cout.flush(); 
    136  
    137                 extractRenderStats(file, currentStats); 
    138                 renderStats.push_back(currentStats); 
    139  
    140                 // create output file name 
    141                 string fn = argv[i]; 
    142                  
    143                 string::size_type pos = fn.find(".log", 0); 
    144                 fn.erase(pos, 4); 
    145                 //sscanf(argv[i], "%s.log", fn); 
    146                 string outFilename = string(fn) + string("-ratio.log"); 
    147  
    148                 outFilenames.push_back(outFilename); 
     149         
     150                if (extractRenderStats(file, currentStats)) 
     151                { 
     152                        renderStats.push_back(currentStats); 
     153 
     154                        // create output file name 
     155                        string fn = argv[i]; 
     156                 
     157                        string::size_type pos = fn.find(".log", 0); 
     158                        fn.erase(pos, 4); 
     159                        //sscanf(argv[i], "%s.log", fn); 
     160                        string outFilename = string(fn) + string("-ratio.log"); 
     161 
     162                        outFilenames.push_back(outFilename); 
     163                } 
     164                else 
     165                { 
     166                        cout << "could not open file!" << endl; 
     167                } 
    149168        } 
    150169 
     
    159178 
    160179        // don't compare with itself 
    161         ++ it; 
    162         ++ sit; 
     180        //++ it; 
     181        //++ sit; 
    163182 
    164183        for (it; it != it_end; ++ it) 
    165184        { 
    166                 cout << "writing output to file " << *sit << endl; 
    167                 ofstream statsOut((*sit).c_str()); 
    168                 ++ sit; 
     185                cout << "now writing output to file " << *sit << endl; 
     186                ofstream statsOut; 
     187                statsOut.open((*sit).c_str()); 
    169188 
    170189                // compute size of output vector 
     
    176195                } 
    177196                 
     197                int vc = ComputeNoViewCells(firstStats, *it); 
     198                cout << "need " << vc << " view cells to reach rendercost of method " << i << " with " << n << " view cells" << endl; 
     199 
    178200                statsOut.close(); 
     201                 
     202                ++ sit; 
    179203        } 
    180204 
Note: See TracChangeset for help on using the changeset viewer.