Ignore:
Timestamp:
02/20/06 19:06:03 (19 years ago)
Author:
mattausch
Message:

added ogre dependencies and patched ogre sources

Location:
OGRE/trunk/ogre_changes/Plugins/OctreeSceneManager
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OGRE/trunk/ogre_changes/Plugins/OctreeSceneManager/include/OgreTerrainRenderable.h

    r316 r657  
    290290 
    291291        /** Overridden from MovableObject */ 
    292         Real getBoundingRadius(void) const { return 0; /* not needed */ } 
     292        Real getBoundingRadius(void) const { return mBoundingRadius; } 
    293293 
    294294        /** @copydoc Renderable::getLights */ 
     
    383383        /// Connection to tiles four neighbours 
    384384        TerrainRenderable *mNeighbors [ 4 ]; 
     385        /// Whether light list need to re-calculate 
     386        mutable bool mLightListDirty; 
     387        /// Cached light list 
     388        mutable LightList mLightList; 
     389        /// The bounding radius of this tile 
     390        Real mBoundingRadius; 
    385391        /// Bounding box of this tile 
    386392        AxisAlignedBox mBounds; 
  • OGRE/trunk/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp

    r318 r657  
    536536SceneNode * OctreeSceneManager::createSceneNode( const String &name ) 
    537537{ 
     538    // Check name not used 
     539    if (mSceneNodes.find(name) != mSceneNodes.end()) 
     540    { 
     541        OGRE_EXCEPT( 
     542            Exception::ERR_DUPLICATE_ITEM, 
     543            "A scene node with the name " + name + " already exists", 
     544            "OctreeSceneManager::createSceneNode" ); 
     545    } 
    538546    OctreeNode * on = new OctreeNode( this, name ); 
    539547    mSceneNodes[ on->getName() ] = on; 
     
    548556void OctreeSceneManager::_alertVisibleObjects( void ) 
    549557{ 
     558    OGRE_EXCEPT( Exception::UNIMPLEMENTED_FEATURE, 
     559        "Function doesn't do as advertised", 
     560        "OctreeSceneManager::_alertVisibleObjects" ); 
     561 
    550562    NodeList::iterator it = mVisible.begin(); 
    551563 
     
    570582 
    571583        if ( c != 0 ) 
    572             cam = getCamera( "CullCamera" ); 
     584            cam = c; 
    573585    } 
    574586 
     
    680692        } 
    681693 
    682         if ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) 
    683             walkOctree( camera, queue, octant -> mChildren[ 0 ][ 0 ][ 0 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 
    684  
    685         if ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) 
    686             walkOctree( camera, queue, octant -> mChildren[ 1 ][ 0 ][ 0 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 
    687  
    688         if ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) 
    689             walkOctree( camera, queue, octant -> mChildren[ 0 ][ 1 ][ 0 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 
    690  
    691         if ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) 
    692             walkOctree( camera, queue, octant -> mChildren[ 1 ][ 1 ][ 0 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 
    693  
    694         if ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) 
    695             walkOctree( camera, queue, octant -> mChildren[ 0 ][ 0 ][ 1 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 
    696  
    697         if ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) 
    698             walkOctree( camera, queue, octant -> mChildren[ 1 ][ 0 ][ 1 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 
    699  
    700         if ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) 
    701             walkOctree( camera, queue, octant -> mChildren[ 0 ][ 1 ][ 1 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 
    702  
    703         if ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) 
    704             walkOctree( camera, queue, octant -> mChildren[ 1 ][ 1 ][ 1 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 
     694        Octree* child; 
     695        bool childfoundvisible = (v == OctreeCamera::FULL); 
     696        if ( (child = octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 
     697            walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 
     698 
     699        if ( (child = octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 
     700            walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 
     701 
     702        if ( (child = octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 
     703            walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 
     704 
     705        if ( (child = octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 
     706            walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 
     707 
     708        if ( (child = octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 
     709            walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 
     710 
     711        if ( (child = octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 
     712            walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 
     713 
     714        if ( (child = octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 
     715            walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 
     716 
     717        if ( (child = octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 
     718            walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 
    705719 
    706720    } 
     
    754768        } 
    755769 
    756  
    757  
    758         if ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) 
    759                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ] ); 
    760  
    761         if ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) 
    762                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ] ); 
    763  
    764         if ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) 
    765                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ] ); 
    766  
    767         if ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) 
    768                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ] ); 
    769  
    770         if ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) 
    771                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ] ); 
    772  
    773         if ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) 
    774                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ] ); 
    775  
    776         if ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) 
    777                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ] ); 
    778  
    779         if ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) 
    780                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ] ); 
     770        Octree* child; 
     771 
     772        if ( (child=octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 
     773                _findNodes( t, list, exclude, full, child ); 
     774 
     775        if ( (child=octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 
     776                _findNodes( t, list, exclude, full, child ); 
     777 
     778        if ( (child=octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 
     779                _findNodes( t, list, exclude, full, child ); 
     780 
     781        if ( (child=octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 
     782                _findNodes( t, list, exclude, full, child ); 
     783 
     784        if ( (child=octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 
     785                _findNodes( t, list, exclude, full, child ); 
     786 
     787        if ( (child=octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 
     788                _findNodes( t, list, exclude, full, child ); 
     789 
     790        if ( (child=octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 
     791                _findNodes( t, list, exclude, full, child ); 
     792 
     793        if ( (child=octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 
     794                _findNodes( t, list, exclude, full, child ); 
    781795 
    782796} 
     
    827841        } 
    828842 
    829  
    830  
    831         if ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) 
    832                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ] ); 
    833  
    834         if ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) 
    835                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ] ); 
    836  
    837         if ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) 
    838                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ] ); 
    839  
    840         if ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) 
    841                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ] ); 
    842  
    843         if ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) 
    844                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ] ); 
    845  
    846         if ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) 
    847                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ] ); 
    848  
    849         if ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) 
    850                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ] ); 
    851  
    852         if ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) 
    853                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ] ); 
     843        Octree* child; 
     844 
     845        if ( (child=octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 
     846                _findNodes( t, list, exclude, full, child ); 
     847 
     848        if ( (child=octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 
     849                _findNodes( t, list, exclude, full, child ); 
     850 
     851        if ( (child=octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 
     852                _findNodes( t, list, exclude, full, child ); 
     853 
     854        if ( (child=octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 
     855                _findNodes( t, list, exclude, full, child ); 
     856 
     857        if ( (child=octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 
     858                _findNodes( t, list, exclude, full, child ); 
     859 
     860        if ( (child=octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 
     861                _findNodes( t, list, exclude, full, child ); 
     862 
     863        if ( (child=octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 
     864                _findNodes( t, list, exclude, full, child ); 
     865 
     866        if ( (child=octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 
     867                _findNodes( t, list, exclude, full, child ); 
    854868 
    855869} 
     
    901915        } 
    902916 
    903  
    904  
    905         if ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) 
    906                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ] ); 
    907  
    908         if ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) 
    909                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ] ); 
    910  
    911         if ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) 
    912                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ] ); 
    913  
    914         if ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) 
    915                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ] ); 
    916  
    917         if ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) 
    918                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ] ); 
    919  
    920         if ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) 
    921                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ] ); 
    922  
    923         if ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) 
    924                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ] ); 
    925  
    926         if ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) 
    927                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ] ); 
     917        Octree* child; 
     918 
     919        if ( (child=octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 
     920                _findNodes( t, list, exclude, full, child ); 
     921 
     922        if ( (child=octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 
     923                _findNodes( t, list, exclude, full, child ); 
     924 
     925        if ( (child=octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 
     926                _findNodes( t, list, exclude, full, child ); 
     927 
     928        if ( (child=octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 
     929                _findNodes( t, list, exclude, full, child ); 
     930 
     931        if ( (child=octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 
     932                _findNodes( t, list, exclude, full, child ); 
     933 
     934        if ( (child=octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 
     935                _findNodes( t, list, exclude, full, child ); 
     936 
     937        if ( (child=octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 
     938                _findNodes( t, list, exclude, full, child ); 
     939 
     940        if ( (child=octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 
     941                _findNodes( t, list, exclude, full, child ); 
    928942 
    929943} 
     
    974988        } 
    975989 
    976  
    977  
    978         if ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) 
    979                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ] ); 
    980  
    981         if ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) 
    982                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ] ); 
    983  
    984         if ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) 
    985                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ] ); 
    986  
    987         if ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) 
    988                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ] ); 
    989  
    990         if ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) 
    991                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ] ); 
    992  
    993         if ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) 
    994                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ] ); 
    995  
    996         if ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) 
    997                 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ] ); 
    998  
    999         if ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) 
    1000                 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ] ); 
     990        Octree* child; 
     991 
     992        if ( (child=octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 
     993                _findNodes( t, list, exclude, full, child ); 
     994 
     995        if ( (child=octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 
     996                _findNodes( t, list, exclude, full, child ); 
     997 
     998        if ( (child=octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 
     999                _findNodes( t, list, exclude, full, child ); 
     1000 
     1001        if ( (child=octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 
     1002                _findNodes( t, list, exclude, full, child ); 
     1003 
     1004        if ( (child=octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 
     1005                _findNodes( t, list, exclude, full, child ); 
     1006 
     1007        if ( (child=octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 
     1008                _findNodes( t, list, exclude, full, child ); 
     1009 
     1010        if ( (child=octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 
     1011                _findNodes( t, list, exclude, full, child ); 
     1012 
     1013        if ( (child=octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 
     1014                _findNodes( t, list, exclude, full, child ); 
    10011015 
    10021016} 
     
    10381052 
    10391053    mOctree->mBox = box; 
     1054 
     1055        const Vector3 min = box.getMinimum(); 
     1056        const Vector3 max = box.getMaximum(); 
     1057        mOctree->mHalfSize = ( max - min ) * 0.5f; 
    10401058 
    10411059    it = nodes.begin(); 
  • OGRE/trunk/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp

    r193 r657  
    7777 
    7878        mInit = false; 
     79        mLightListDirty = true; 
    7980                MovableObject::mCastShadows = false; 
    8081 
     
    251252            ( startz * msOptions->scale.z + (endz - 1) * msOptions->scale.z ) / 2 ); 
    252253 
     254        mBoundingRadius = 
     255            std::max(max - min, 
     256                std::max((endx - 1 - startx) * msOptions->scale.x, 
     257                         (endz - 1 - startz) * msOptions->scale.z)) / 2; 
     258 
    253259        // Create delta buffer list if required to morph 
    254260        if (msOptions->lodMorph) 
     
    344350 
    345351                Vector3 cpos = cam -> getDerivedPosition(); 
    346         Vector3 diff = mCenter - cpos; 
     352        const AxisAlignedBox& aabb = getWorldBoundingBox(true); 
     353        Vector3 diff(0, 0, 0); 
     354        diff.makeFloor(cpos - aabb.getMinimum()); 
     355        diff.makeCeil(cpos - aabb.getMaximum()); 
    347356 
    348357        Real L = diff.squaredLength(); 
     
    443452    void TerrainRenderable::_updateRenderQueue( RenderQueue* queue ) 
    444453    { 
     454        // Notify need to calculate light list when our sending to render queue 
     455        mLightListDirty = true; 
     456 
    445457        queue->addRenderable( this ); 
    446458    } 
     
    9941006    const LightList& TerrainRenderable::getLights(void) const 
    9951007    { 
    996         return getParentSceneNode()->findLights(this->getBoundingRadius()); 
     1008        if (mLightListDirty) 
     1009        { 
     1010            getParentSceneNode()->getCreator()->_populateLightList( 
     1011                mCenter, this->getBoundingRadius(), mLightList); 
     1012            mLightListDirty = false; 
     1013        } 
     1014        return mLightList; 
    9971015    } 
    9981016    //----------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.