Changeset 85 for trunk/VUT/Ogre


Ignore:
Timestamp:
05/04/05 17:58:13 (19 years ago)
Author:
mattausch
Message:

corrected bug so chc is much faster than stop and wait

Location:
trunk/VUT/Ogre
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h

    r71 r85  
    7777        */ 
    7878        void RenderBoundingBox(AxisAlignedBox *box); 
    79         /** Returns one half of the bounding box. 
    80                 @param half the half index of the bouding box (0 or 1) 
     79        /** Returns pointer to current renderable half bounding box geometry 
    8180        */ 
    82         SolidHalfBoundingBox *GetSolidHalfBoundingBox(int half); 
     81        SolidHalfBoundingBox *GetSolidHalfBoundingBox(); 
    8382 
    84         /** two halfes of an aabb.  
     83        /** one renderable half of an aabb.  
    8584        */ 
    86         SolidHalfBoundingBox *mHalfBoundingBox[2];       
     85        SolidHalfBoundingBox *mSolidHalfBoundingBox; 
    8786 
    8887        SceneManager *mSceneManager; 
     
    9190        Camera *mCamera; 
    9291        AxisAlignedBox mBox; 
    93  
     92         
    9493        std::vector<PlatformOcclusionQuery *> mOcclusionQueries; 
    9594}; 
  • trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h

    r74 r85  
    3636 
    3737        AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node); 
    38  
    39 protected: 
    40          
    41          
    4238}; 
    4339 
  • trunk/VUT/Ogre/include/OgreSolidHalfBoundingBox.h

    r59 r85  
    1515public: 
    1616 
    17         SolidHalfBoundingBox(bool isFirstHalf); 
    18         void setupBoundingBox(const AxisAlignedBox& aabb); 
    19         /** Override this method to prevent parent transforms (rotation,translation,scale) 
    20                 and to make it public. 
     17        SolidHalfBoundingBox(); 
     18        /** Sets up the first or second half of a solid bounding box. 
     19                @param aab the axis aligned bounding box 
     20                @param isFirstHalf if it is the first or the second half 
     21        */ 
     22        void SetupBoundingBox(const AxisAlignedBox& aabb, const bool isFirstHalf); 
     23         
     24protected: 
     25    /** Builds the wireframe line list. 
     26                @param aab the axis aligned bounding box for setting up the vertices 
     27                @param first or second half of the box 
    2128    */ 
    22         void getWorldTransforms(Matrix4* xform) const; 
    23  
    24 protected: 
    25      
    26     /** Builds the wireframe line list. 
    27                 @param aab the axis aligned bounding box for setting up the list. 
    28     */ 
    29         void setupBoundingBoxVertices(const AxisAlignedBox& aab); 
     29        void SetupBoundingBoxVertices(const AxisAlignedBox& aab, const bool isFirstHalf); 
    3030        /**  
    3131                Sets the material used for occlusion queries.  
     
    3333                uses no lighting, no depth write, and no colours 
    3434        */ 
    35         void setOcclusionQueryMaterial(); 
     35        void SetOcclusionQueryMaterial(); 
    3636        /** Whether this half box is the first or the second half of the bounding box.  
    3737        */ 
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r74 r85  
    140140AxisAlignedBox *OctreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 
    141141{ 
    142         static_cast<Octree *>(node)->_getCullBounds(&mBox); 
     142        if(node != mPreviousNode) 
     143        { 
     144                mPreviousNode = node; 
     145                static_cast<Octree *>(node)->_getCullBounds(&mBox); 
     146        } 
    143147 
    144148        return &mBox; 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r74 r85  
    1111//----------------------------------------------------------------------- 
    1212PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 
    13 mSceneManager(sm), mRenderSystem(rsys) 
    14 {                
    15         mHalfBoundingBox[0] = mHalfBoundingBox[1] = NULL; 
     13mSceneManager(sm), mRenderSystem(rsys), mSolidHalfBoundingBox(NULL) 
     14{ 
    1615} 
    1716//----------------------------------------------------------------------- 
     
    1918{ 
    2019        DeleteQueries(); 
    21          
    22         if (mHalfBoundingBox[0])  
    23                 delete mHalfBoundingBox[0]; 
    2420 
    25         if (mHalfBoundingBox[1])  
    26                 delete mHalfBoundingBox[1]; 
     21        if(mSolidHalfBoundingBox) 
     22                delete mSolidHalfBoundingBox; 
    2723} 
    2824//----------------------------------------------------------------------- 
     
    3834{ 
    3935        // Render two halfes of the bounding box (using triangle fans) 
    40         for(int half = 0; half < 2; half ++) 
     36        for(int halfIdx = 0; halfIdx < 2; ++halfIdx) 
    4137        { 
    42                 static Matrix4 xform[256]; 
    43                 //TODO: this should be full bounding box 
    44                 SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(half); 
    45                 halfbox->setupBoundingBox(*box); 
    46                  
     38                //TODO: this should be the full bounding box 
     39                SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 
     40                halfbox->SetupBoundingBox(*box, halfIdx == 1); 
     41                                 
    4742                mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
    4843                 
     
    5045 
    5146        mSceneManager->useRenderableViewProjMode(halfbox); 
    52                 mSceneManager->setPass(halfbox->getTechnique()->getPass(0)); 
     47                mSceneManager->setPass(GetSolidHalfBoundingBox()->getTechnique()->getPass(0)); 
    5348                halfbox->getRenderOperation(ro); 
    54                 ro.srcRenderable = halfbox;  
     49                ro.srcRenderable = halfbox; 
    5550                mRenderSystem->_render(ro); 
    56                  
    57                 // matt: change this 
    58 //              mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half),  
    59 //                      getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), true); 
    6051        } 
    61 } 
    62 //----------------------------------------------------------------------- 
    63 SolidHalfBoundingBox *PlatformHierarchyInterface::GetSolidHalfBoundingBox(int half) 
    64 { 
    65         if(!mHalfBoundingBox[half]) 
    66                 mHalfBoundingBox[half] = new Ogre::SolidHalfBoundingBox(half == 1); 
    67  
    68         return mHalfBoundingBox[half];   
    6952} 
    7053//----------------------------------------------------------------------- 
     
    10083} 
    10184//----------------------------------------------------------------------- 
    102 bool PlatformHierarchyInterface::CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects) 
     85bool PlatformHierarchyInterface::CheckFrustumVisible(GtpVisibility::HierarchyNode *node,  
     86                                                                                                         bool &intersects) 
    10387{ 
    10488#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     
    10993} 
    11094//----------------------------------------------------------------------- 
    111 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery(GtpVisibility::HierarchyNode *node)  
     95GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 
     96        GtpVisibility::HierarchyNode *node)  
    11297{ 
    11398        // get next available test id 
     
    123108        return query; 
    124109} 
     110//----------------------------------------------------------------------- 
     111SolidHalfBoundingBox *PlatformHierarchyInterface::GetSolidHalfBoundingBox() 
     112{ 
     113        if(!mSolidHalfBoundingBox) 
     114                mSolidHalfBoundingBox = new SolidHalfBoundingBox; 
     115 
     116        return mSolidHalfBoundingBox; 
     117} 
    125118 
    126119} // namespace Ogre 
  • trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp

    r74 r85  
    123123AxisAlignedBox *SceneNodeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 
    124124{ 
    125         SceneNode *sceneNode = static_cast<SceneNode *>(node); 
     125        if(node != mPreviousNode) 
     126        { 
     127                mPreviousNode = node; 
     128 
     129                mBox = static_cast<SceneNode *>(node)->_getWorldAABB(); 
     130        } 
     131 
    126132        return &mBox; 
    127133} 
  • trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp

    r59 r85  
    1212#define POSITION_BINDING 0 
    1313//----------------------------------------------------------------------- 
    14 SolidHalfBoundingBox::SolidHalfBoundingBox(bool isFirstHalf) 
    15         :WireBoundingBox(), mIsFirstHalf(isFirstHalf) 
     14SolidHalfBoundingBox::SolidHalfBoundingBox() 
    1615{ 
    17         setOcclusionQueryMaterial(); 
     16        SetOcclusionQueryMaterial(); 
    1817         
    1918        mRenderOp.vertexData->vertexCount = 8; 
     
    2120} 
    2221//----------------------------------------------------------------------- 
    23 void SolidHalfBoundingBox::setupBoundingBoxVertices(const AxisAlignedBox& aab) { 
    24  
     22void SolidHalfBoundingBox::SetupBoundingBoxVertices(const AxisAlignedBox& aab,  
     23                                                                                                        const bool isFirstHalf)  
     24{ 
    2525        Vector3 vmax = aab.getMaximum(); 
    2626        Vector3 vmin = aab.getMinimum(); 
    27          
    28          
     27                 
    2928        Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); 
    3029    mRadius = Math::Sqrt(sqLen); 
     
    3837        Real minz = vmin.z; 
    3938         
    40         // fill in the Vertex buffer: 12 lines with 2 endpoints each make up a box 
     39        // fill the vertex buffer: 12 lines with 2 endpoints each make up a box 
    4140    HardwareVertexBufferSharedPtr vbuf = 
    4241        mRenderOp.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING);      
     
    5554 
    5655        // fan 1 
    57         if(mIsFirstHalf) 
     56        if(isFirstHalf) 
    5857        { 
    5958                *pPos++ = minx; *pPos++ = maxy; *pPos++ = maxz; //011 
     
    6665                *pPos++ = minx; *pPos++ = miny; *pPos++ = minz; //000 
    6766                *pPos++ = minx; *pPos++ = miny; *pPos++ = maxz; //001 
    68  
    6967        } 
    7068        else 
     
    8482    vbuf->unlock(); 
    8583} 
    86  
    87 void SolidHalfBoundingBox::setupBoundingBox(const AxisAlignedBox& aabb)  
     84//----------------------------------------------------------------------- 
     85void SolidHalfBoundingBox::SetupBoundingBox(const AxisAlignedBox& aabb,  
     86                                                                                        const bool isFirstHalf)  
    8887{ 
    8988        // init the vertices to the aabb 
    90         SolidHalfBoundingBox::setupBoundingBoxVertices(aabb); 
     89        SetupBoundingBoxVertices(aabb, isFirstHalf); 
    9190 
    9291    // setup the bounding box of this SimpleRenderable 
    9392        setBoundingBox(aabb); 
    9493} 
    95 // Override this method to prevent parent transforms (rotation,translation,scale) 
    96 void SolidHalfBoundingBox::getWorldTransforms( Matrix4* xform ) const 
    97 { 
    98         // return identity matrix to prevent parent transforms 
    99     *xform = Matrix4::IDENTITY; 
    100 } 
    101  
    102 void SolidHalfBoundingBox::setOcclusionQueryMaterial( void ) 
     94//----------------------------------------------------------------------- 
     95void SolidHalfBoundingBox::SetOcclusionQueryMaterial( void ) 
    10396{ 
    10497        m_pMaterial = MaterialManager::getSingleton().getByName("OcclusionQuery"); 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r74 r85  
    1919 
    2020        setVisibilityManager(visManager); 
    21         mShowBoxes = true; 
     21        //mShowBoxes = true; 
    2222        //mDisplayNodes = true; 
    23         mShowBoundingBoxes = true; 
     23        //mShowBoundingBoxes = true; 
    2424        mMaxDepth = 20; 
    2525} 
Note: See TracChangeset for help on using the changeset viewer.