Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreRenderQueue.cpp

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright © 2000-2002 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025 #include "OgreStableHeaders.h"
    00026
    00027 #include "OgreRenderQueue.h"
    00028
    00029 #include "OgreRenderable.h"
    00030 #include "OgreMaterial.h"
    00031 #include "OgreRenderQueueSortingGrouping.h"
    00032 #include "OgrePass.h"
    00033
    00034 namespace Ogre {
    00035
    00036     //---------------------------------------------------------------------
    00037     RenderQueue::RenderQueue() : mSplitPassesByLightingType(false), mSplitNoShadowPasses(false)
    00038     {
    00039         // Create the 'main' queue up-front since we'll always need that
    00040         mGroups.insert(
    00041             RenderQueueGroupMap::value_type(
    00042                 RENDER_QUEUE_MAIN,
    00043                 new RenderQueueGroup(this, mSplitPassesByLightingType, mSplitNoShadowPasses)
    00044                 )
    00045             );
    00046
    00047         // set default queue
    00048         mDefaultQueueGroup = RENDER_QUEUE_MAIN;
    00049         mDefaultRenderablePriority = RENDERABLE_DEFAULT_PRIORITY;
    00050
    00051     }
    00052     //---------------------------------------------------------------------
    00053     RenderQueue::~RenderQueue()
    00054     {
    00055
    00056         // trigger the pending pass updates, otherwise we could leak
    00057         Pass::processPendingPassUpdates();
    00058
    00059         // Destroy the queues for good
    00060         RenderQueueGroupMap::iterator i, iend;
    00061         i = mGroups.begin();
    00062         iend = mGroups.end();
    00063         for (; i != iend; ++i)
    00064         {
    00065             delete i->second;
    00066         }
    00067         mGroups.clear();
    00068
    00069
    00070
    00071
    00072     }
    00073     //-----------------------------------------------------------------------
    00074     void RenderQueue::addRenderable(Renderable* pRend, RenderQueueGroupID groupID, ushort priority)
    00075     {
    00076         // Find group
    00077         RenderQueueGroup* pGroup = getQueueGroup(groupID);
    00078
    00079         // tell material it's been used
    00080         pRend->getMaterial()->touch();
    00081         pGroup->addRenderable(pRend, priority);
    00082
    00083     }
    00084     //-----------------------------------------------------------------------
    00085     void RenderQueue::clear(void)
    00086     {
    00087         // Clear the queues
    00088         RenderQueueGroupMap::iterator i, iend;
    00089         i = mGroups.begin();
    00090         iend = mGroups.end();
    00091         for (; i != iend; ++i)
    00092         {
    00093             i->second->clear();
    00094         }
    00095
    00096         // Now trigger the pending pass updates
    00097         Pass::processPendingPassUpdates();
    00098
    00099         // NB this leaves the items present (but empty)
    00100         // We're assuming that frame-by-frame, the same groups are likely to
    00101         //  be used, so no point destroying the vectors and incurring the overhead
    00102         //  that would cause, let them be destroyed in the destructor.
    00103     }
    00104     //-----------------------------------------------------------------------
    00105     RenderQueue::QueueGroupIterator RenderQueue::_getQueueGroupIterator(void)
    00106     {
    00107         return QueueGroupIterator(mGroups.begin(), mGroups.end());
    00108     }
    00109     //-----------------------------------------------------------------------
    00110     void RenderQueue::addRenderable(Renderable* pRend, RenderQueueGroupID groupID)
    00111     {
    00112         addRenderable(pRend, groupID, mDefaultRenderablePriority);
    00113     }
    00114     //-----------------------------------------------------------------------
    00115     void RenderQueue::addRenderable(Renderable* pRend)
    00116     {
    00117         addRenderable(pRend, mDefaultQueueGroup, mDefaultRenderablePriority);
    00118     }
    00119     //-----------------------------------------------------------------------
    00120     RenderQueueGroupID RenderQueue::getDefaultQueueGroup(void) const
    00121     {
    00122         return mDefaultQueueGroup;
    00123     }
    00124     //-----------------------------------------------------------------------
    00125     void RenderQueue::setDefaultQueueGroup(RenderQueueGroupID grp)
    00126     {
    00127         mDefaultQueueGroup = grp;
    00128     }
    00129     //-----------------------------------------------------------------------
    00130     ushort RenderQueue::getDefaultRenderablePriority(void) const
    00131     {
    00132         return mDefaultRenderablePriority;
    00133     }
    00134     //-----------------------------------------------------------------------
    00135     void RenderQueue::setDefaultRenderablePriority(ushort priority)
    00136     {
    00137         mDefaultRenderablePriority = priority;
    00138     }
    00139
    00140
    00141     //-----------------------------------------------------------------------
    00142     RenderQueueGroup* RenderQueue::getQueueGroup(RenderQueueGroupID groupID)
    00143     {
    00144         // Find group
    00145         RenderQueueGroupMap::iterator groupIt;
    00146         RenderQueueGroup* pGroup;
    00147
    00148         groupIt = mGroups.find(groupID);
    00149         if (groupIt == mGroups.end())
    00150         {
    00151             // Insert new
    00152             pGroup = new RenderQueueGroup(this, mSplitPassesByLightingType, mSplitNoShadowPasses);
    00153             mGroups.insert(RenderQueueGroupMap::value_type(groupID, pGroup));
    00154         }
    00155         else
    00156         {
    00157             pGroup = groupIt->second;
    00158         }
    00159
    00160         return pGroup;
    00161
    00162     }
    00163     //-----------------------------------------------------------------------
    00164     void RenderQueue::setSplitPassesByLightingType(bool split)
    00165     {
    00166         mSplitPassesByLightingType = split;
    00167
    00168         RenderQueueGroupMap::iterator i, iend;
    00169         i = mGroups.begin();
    00170         iend = mGroups.end();
    00171         for (; i != iend; ++i)
    00172         {
    00173             i->second->setSplitPassesByLightingType(split);
    00174         }
    00175     }
    00176     //-----------------------------------------------------------------------
    00177     void RenderQueue::setSplitNoShadowPasses(bool split)
    00178     {
    00179         mSplitNoShadowPasses = split;
    00180
    00181         RenderQueueGroupMap::iterator i, iend;
    00182         i = mGroups.begin();
    00183         iend = mGroups.end();
    00184         for (; i != iend; ++i)
    00185         {
    00186             i->second->setSplitNoShadowPasses(split);
    00187         }
    00188     }
    00189
    00190 }
    00191

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:42 2004