Changeset 86 for trunk/VUT/Ogre/src


Ignore:
Timestamp:
05/06/05 01:39:32 (20 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/Ogre/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r85 r86  
    5757                                                                                                  GtpVisibility::HierarchyNode *node2) const 
    5858{ 
    59         // matt: change this (inefficient) 
    60         AxisAlignedBox box1, box2; 
    61  
    62         static_cast<Octree *>(node1)->_getCullBounds(&box1); 
    63         static_cast<Octree *>(node2)->_getCullBounds(&box2); 
    64  
    65         return GetSquaredViewDepth(mCamera, &box1) > GetSquaredViewDepth(mCamera, &box2); 
     59        return GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node1)->mBox) >  
     60                   GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node2)->mBox); 
    6661} 
    6762//----------------------------------------------------------------------- 
     
    7065{ 
    7166        Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 
    72         return (cam->getDerivedPosition() - mid).squaredLength();                                                                    
     67        // use nearest point rather than midpoint 
     68        Vector3 camPos = cam->getDerivedPosition(); 
     69 
     70        Vector3 minPos(camPos.x < mid.x ? box->getMinimum().x : box->getMaximum().x, 
     71                                   camPos.y < mid.y ? box->getMinimum().y : box->getMaximum().y, 
     72                                   camPos.z < mid.z ? box->getMinimum().z : box->getMaximum().z); 
     73         
     74        return (camPos - minPos).squaredLength();                                                                    
    7375} 
    7476//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r85 r86  
    66#include "OgrePlatformHierarchyInterface.h" 
    77#include "OgrePlatformOcclusionQuery.h" 
     8#include <windows.h> 
    89 
    910namespace Ogre { 
     
    3334void PlatformHierarchyInterface::RenderBoundingBox(AxisAlignedBox *box) 
    3435{ 
     36        static RenderOperation ro; 
     37 
     38        //TODO: this should be the full bounding box 
     39        SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 
     40         
     41        mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
     42        mSceneManager->useRenderableViewProjMode(halfbox); 
     43    mSceneManager->setPass(halfbox->getTechnique()->getPass(0)); 
     44 
    3545        // Render two halfes of the bounding box (using triangle fans) 
    3646        for(int halfIdx = 0; halfIdx < 2; ++halfIdx) 
    3747        { 
    38                 //TODO: this should be the full bounding box 
    39                 SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 
    40                 halfbox->SetupBoundingBox(*box, halfIdx == 1); 
     48                halfbox->SetupBoundingBoxVertices(*box, halfIdx == 1); 
    4149                                 
    42                 mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
    43                  
    44                 static RenderOperation ro; 
    45  
    46         mSceneManager->useRenderableViewProjMode(halfbox); 
    47                 mSceneManager->setPass(GetSolidHalfBoundingBox()->getTechnique()->getPass(0)); 
    4850                halfbox->getRenderOperation(ro); 
    4951                ro.srcRenderable = halfbox; 
    50                 mRenderSystem->_render(ro); 
     52                mRenderSystem->_render(ro);      
    5153        } 
    5254} 
     
    7072{ 
    7173        GtpVisibility::HierarchyInterface::InitFrame(root); 
     74        mPreviousNode = NULL; 
    7275        SetCamera(cam); 
    7376} 
     
    9497//----------------------------------------------------------------------- 
    9598GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 
    96         GtpVisibility::HierarchyNode *node)  
     99        GtpVisibility::HierarchyNode *node, const bool wasVisible)  
    97100{ 
    98101        // get next available test id 
     
    102105        query->BeginQuery(); 
    103106                         
    104         RenderBoundingBox(GetBoundingBox(node)); 
     107        // if leaf and was visible => will be rendered anyway, thus we 
     108        // can also test with the real geometry  
     109        if(mUseOptimization && wasVisible && IsLeaf(node)) 
     110        { 
     111        //      OutputDebugString("Using optimization!!\n"); 
     112                RenderNode(node); 
     113        } 
     114        else 
     115        { 
     116        //      OutputDebugString("Not optimized!!\n"); 
     117                RenderBoundingBox(GetBoundingBox(node)); 
     118        } 
    105119 
    106120        query->EndQuery(); 
  • trunk/VUT/Ogre/src/OgrePlatformOcclusionQuery.cpp

    r59 r86  
    11#include "OgrePlatformOcclusionQuery.h" 
    2  
     2#include <windows.h> 
    33namespace Ogre { 
    44 
     
    2424} 
    2525//----------------------------------------------------------------------- 
    26 unsigned int PlatformOcclusionQuery::GetQueryResult() const 
     26bool PlatformOcclusionQuery::GetQueryResult(unsigned int &visiblePixels,  
     27                                                                                        const bool waitForResult) const 
    2728{ 
    28         unsigned int visiblePixels = 0; 
    29         // wait if result not available 
    30         mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels); 
    31  
    32         return visiblePixels; 
    33 } 
    34 //----------------------------------------------------------------------- 
    35 bool PlatformOcclusionQuery::ResultAvailable() const 
    36 { 
    37 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    38         return mHardwareOcclusionQuery->resultAvailable(); 
    39 #else 
    40         return true; 
    41 #endif 
     29        return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels, waitForResult); 
    4230} 
    4331 
  • trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp

    r85 r86  
    2626        Vector3 vmin = aab.getMinimum(); 
    2727                 
    28         Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); 
    29     mRadius = Math::Sqrt(sqLen); 
     28        //Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); 
     29    //mRadius = Math::Sqrt(sqLen); 
    3030         
    3131        Real maxx = vmax.x; 
     
    9090 
    9191    // setup the bounding box of this SimpleRenderable 
    92         setBoundingBox(aabb); 
     92        //setBoundingBox(aabb); 
    9393} 
    9494//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r74 r86  
    1818 
    1919        //mDisplayNodes = true; 
    20         mShowBoundingBoxes = true; 
    21         mShowBoxes = true; 
    22         //mMaxDepth = 20; 
     20        //mShowBoundingBoxes = true; 
     21        //mShowBoxes = true; 
     22        mMaxDepth = 20; 
    2323} 
    2424//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp

    r75 r86  
    2020        { 
    2121                mVisibilityManager->SetVisibilityCullingThreshold(*static_cast<const int *>(val)); 
    22  
     22                return true; 
     23        } 
     24        if (key == "UseOptimization") 
     25        { 
     26                mHierarchyInterface->SetUseOptimization(*static_cast<const bool *>(val)); 
    2327                return true; 
    2428        } 
     
    5357                return true; 
    5458        } 
     59         
    5560        return false; 
    5661} 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r85 r86  
    1212//namespace GtpVisibility { 
    1313//----------------------------------------------------------------------- 
    14 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(GtpVisibility::VisibilityManager *visManager) 
    15 :mVisibilityManager(visManager) 
     14VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 
     15        GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 
    1616{ 
    1717        mHierarchyInterface =  
    1818                new OctreeHierarchyInterface(this, mDestRenderSystem); 
    1919 
    20         setVisibilityManager(visManager); 
    2120        //mShowBoxes = true; 
    2221        //mDisplayNodes = true; 
Note: See TracChangeset for help on using the changeset viewer.