Coverage Report

Created: 2025-11-04 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ogre/OgreMain/include/OgreRenderQueue.h
Line
Count
Source
1
/*
2
-----------------------------------------------------------------------------
3
This source file is part of OGRE
4
    (Object-oriented Graphics Rendering Engine)
5
For the latest info, see http://www.ogre3d.org/
6
7
Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9
Permission is hereby granted, free of charge, to any person obtaining a copy
10
of this software and associated documentation files (the "Software"), to deal
11
in the Software without restriction, including without limitation the rights
12
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
copies of the Software, and to permit persons to whom the Software is
14
furnished to do so, subject to the following conditions:
15
16
The above copyright notice and this permission notice shall be included in
17
all copies or substantial portions of the Software.
18
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
THE SOFTWARE.
26
-----------------------------------------------------------------------------
27
*/
28
#ifndef __RenderQueue_H__
29
#define __RenderQueue_H__
30
31
#include "OgrePrerequisites.h"
32
#include "OgreHeaderPrefix.h"
33
34
namespace Ogre {
35
36
    class Camera;
37
    class MovableObject;
38
    struct VisibleObjectsBoundsInfo;
39
40
    /** \addtogroup Core
41
    *  @{
42
    */
43
    /** \addtogroup RenderSystem
44
    *  @{
45
    */
46
    /** Enumeration of queue groups, by which the application may group queued renderables
47
        so that they are rendered together with events in between
48
49
        When passed into methods these are actually passed as a uint8 to allow you
50
        to use values in between if you want to.
51
    */
52
    enum RenderQueueGroupID
53
    {
54
        /// Use this queue for objects which must be rendered first e.g. backgrounds
55
        RENDER_QUEUE_BACKGROUND = 0,
56
        /// First queue (after backgrounds), used for skyboxes if rendered first
57
        RENDER_QUEUE_SKIES_EARLY = 5,
58
        RENDER_QUEUE_1 = 10,
59
        RENDER_QUEUE_2 = 20,
60
        RENDER_QUEUE_WORLD_GEOMETRY_1 = 25,
61
        RENDER_QUEUE_3 = 30,
62
        RENDER_QUEUE_4 = 40,
63
        /// The default render queue
64
        RENDER_QUEUE_MAIN = 50,
65
        RENDER_QUEUE_6 = 60,
66
        RENDER_QUEUE_7 = 70,
67
        RENDER_QUEUE_WORLD_GEOMETRY_2 = 75,
68
        RENDER_QUEUE_8 = 80,
69
        /// Used for skyboxes if rendered last
70
        RENDER_QUEUE_SKIES_LATE = 90,
71
        /// Penultimate queue(before overlays)
72
        RENDER_QUEUE_TRANSPARENTS = 95,
73
        /// Use this queue for objects which must be rendered last e.g. overlays
74
        RENDER_QUEUE_OVERLAY = 100, 
75
        /// Final possible render queue, don't exceed this
76
        RENDER_QUEUE_MAX = 105,
77
        RENDER_QUEUE_COUNT
78
    };
79
80
    /// @deprecated
81
    #define OGRE_RENDERABLE_DEFAULT_PRIORITY  Ogre::Renderable::DEFAULT_PRIORITY
82
83
    /** Class to manage the scene object rendering queue.
84
85
        Objects are grouped by material to minimise rendering state changes. The map from
86
        material to renderable object is wrapped in a class for ease of use.
87
        @par
88
            This class now includes the concept of 'queue groups' which allows the application
89
            adding the renderable to specifically schedule it so that it is included in 
90
            a discrete group. Good for separating renderables into the main scene,
91
            backgrounds and overlays, and also could be used in the future for more
92
            complex multipass routines like stenciling.
93
    */
94
    class _OgreExport RenderQueue : public RenderQueueAlloc
95
    {
96
    public:
97
98
        typedef std::unique_ptr<RenderQueueGroup> RenderQueueGroupMap[RENDER_QUEUE_COUNT];
99
100
        /** Class to listen in on items being added to the render queue. 
101
102
            Use RenderQueue::setRenderableListener to get callbacks when an item
103
            is added to the render queue.
104
        */
105
        class _OgreExport RenderableListener
106
        {
107
        public:
108
0
            RenderableListener() {}
109
0
            virtual ~RenderableListener() {}
110
111
            /** Method called when a Renderable is added to the queue.
112
113
                You can use this event hook to alter the Technique used to
114
                render a Renderable as the item is added to the queue. This is
115
                a low-level way to override the material settings for a given
116
                Renderable on the fly.
117
            @param rend The Renderable being added to the queue
118
            @param groupID The render queue group this Renderable is being added to
119
            @param priority The priority the Renderable has been given
120
            @param ppTech A pointer to the pointer to the Technique that is 
121
                intended to be used; you can alter this to an alternate Technique
122
                if you so wish (the Technique doesn't have to be from the same
123
                Material either).
124
            @param pQueue Pointer to the render queue that this object is being
125
                added to. You can for example call this back to duplicate the 
126
                object with a different technique
127
            @return true to allow the Renderable to be added to the queue, 
128
                false if you want to prevent it being added
129
            */
130
            virtual bool renderableQueued(Renderable* rend, uint8 groupID, 
131
                ushort priority, Technique** ppTech, RenderQueue* pQueue) = 0;
132
        };
133
    private:
134
        RenderQueueGroupMap mGroups;
135
        /// The current default queue group
136
        uint8 mDefaultQueueGroup;
137
        /// The default priority
138
        ushort mDefaultRenderablePriority;
139
140
        bool mSplitPassesByLightingType;
141
        bool mSplitNoShadowPasses;
142
        bool mShadowCastersCannotBeReceivers;
143
144
        RenderableListener* mRenderableListener;
145
    public:
146
        RenderQueue();
147
        virtual ~RenderQueue();
148
149
        /** Empty the queue - should only be called by SceneManagers.
150
        @param destroyPassMaps Set to true to destroy all pass maps so that
151
            the queue is completely clean (useful when switching scene managers)
152
        */
153
        void clear(bool destroyPassMaps = false);
154
155
        /** Get a render queue group.
156
157
            OGRE registers new queue groups as they are requested, 
158
            therefore this method will always return a valid group.
159
        */
160
        RenderQueueGroup* getQueueGroup(uint8 qid);
161
162
        /** Add a renderable object to the queue.
163
164
            This methods adds a Renderable to the queue, which will be rendered later by 
165
            the SceneManager. This is the advanced version of the call which allows the renderable
166
            to be added to any queue.
167
        @note
168
            Called by implementation of MovableObject::_updateRenderQueue.
169
        @param
170
            pRend Pointer to the Renderable to be added to the queue
171
        @param
172
            groupID The group the renderable is to be added to. This
173
            can be used to schedule renderable objects in separate groups such that the SceneManager
174
            respects the divisions between the groupings and does not reorder them outside these
175
            boundaries. This can be handy for overlays where no matter what you want the overlay to 
176
            be rendered last.
177
        @param
178
            priority Controls the priority of the renderable within the queue group. If this number
179
            is raised, the renderable will be rendered later in the group compared to it's peers.
180
            Don't use this unless you really need to, manually ordering renderables prevents OGRE
181
            from sorting them for best efficiency. However this could be useful for ordering 2D
182
            elements manually for example.
183
        */
184
        void addRenderable(Renderable* pRend, uint8 groupID, ushort priority);
185
186
        /** Add a renderable object to the queue.
187
188
            This methods adds a Renderable to the queue, which will be rendered later by 
189
            the SceneManager. This is the simplified version of the call which does not 
190
            require a priority to be specified. The queue priority is take from the
191
            current default (see setDefaultRenderablePriority).
192
        @note
193
            Called by implementation of MovableObject::_updateRenderQueue.
194
        @param pRend
195
            Pointer to the Renderable to be added to the queue
196
        @param groupId
197
            The group the renderable is to be added to. This
198
            can be used to schedule renderable objects in separate groups such that the SceneManager
199
            respects the divisions between the groupings and does not reorder them outside these
200
            boundaries. This can be handy for overlays where no matter what you want the overlay to 
201
            be rendered last.
202
        */
203
        void addRenderable(Renderable* pRend, uint8 groupId);
204
205
        /** Add a renderable object to the queue.
206
207
            This methods adds a Renderable to the queue, which will be rendered later by 
208
            the SceneManager. This is the simplified version of the call which does not 
209
            require a queue or priority to be specified. The queue group is taken from the
210
            current default (see setDefaultQueueGroup).  The queue priority is take from the
211
            current default (see setDefaultRenderablePriority).
212
        @note
213
            Called by implementation of MovableObject::_updateRenderQueue.
214
        @param
215
            pRend Pointer to the Renderable to be added to the queue
216
        */
217
        void addRenderable(Renderable* pRend);
218
        
219
        /** Gets the current default queue group, which will be used for all renderable which do not
220
            specify which group they wish to be on.
221
        */
222
        uint8 getDefaultQueueGroup(void) const;
223
224
        /** Sets the current default renderable priority, 
225
            which will be used for all renderables which do not
226
            specify which priority they wish to use.
227
        */
228
        void setDefaultRenderablePriority(ushort priority);
229
230
        /** Gets the current default renderable priority, which will be used for all renderables which do not
231
            specify which priority they wish to use.
232
        */
233
        ushort getDefaultRenderablePriority(void) const;
234
235
        /** Sets the current default queue group, which will be used for all renderable which do not
236
            specify which group they wish to be on. See the enum RenderQueueGroupID for what kind of
237
            values can be used here.
238
        */
239
        void setDefaultQueueGroup(uint8 grp);
240
        
241
        /** Internal method, returns the queue groups. */
242
0
        const RenderQueueGroupMap& _getQueueGroups() const {
243
0
            return mGroups;
244
0
        }
245
246
        /** Sets whether or not the queue will split passes by their lighting type,
247
            ie ambient, per-light and decal. 
248
        */
249
        void setSplitPassesByLightingType(bool split);
250
251
        /** Gets whether or not the queue will split passes by their lighting type,
252
            ie ambient, per-light and decal. 
253
        */
254
        bool getSplitPassesByLightingType(void) const;
255
256
        /** Sets whether or not the queue will split passes which have shadow receive
257
        turned off (in their parent material), which is needed when certain shadow
258
        techniques are used.
259
        */
260
        void setSplitNoShadowPasses(bool split);
261
262
        /** Gets whether or not the queue will split passes which have shadow receive
263
        turned off (in their parent material), which is needed when certain shadow
264
        techniques are used.
265
        */
266
        bool getSplitNoShadowPasses(void) const;
267
268
        /** Sets whether or not objects which cast shadows should be treated as
269
        never receiving shadows. 
270
        */
271
        void setShadowCastersCannotBeReceivers(bool ind);
272
273
        /** Gets whether or not objects which cast shadows should be treated as
274
        never receiving shadows. 
275
        */
276
        bool getShadowCastersCannotBeReceivers(void) const;
277
278
        /** Set a renderable listener on the queue.
279
280
            There can only be a single renderable listener on the queue, since
281
            that listener has complete control over the techniques in use.
282
        */
283
        void setRenderableListener(RenderableListener* listener)
284
0
        { mRenderableListener = listener; }
285
286
        RenderableListener* getRenderableListener(void) const
287
0
        { return mRenderableListener; }
288
289
        /** Merge render queue.
290
        */
291
        void merge( const RenderQueue* rhs );
292
        /** Utility method to perform the standard actions associated with 
293
            getting a visible object to add itself to the queue. This is 
294
            a replacement for SceneManager implementations of the associated
295
            tasks related to calling MovableObject::_updateRenderQueue.
296
        */
297
        void processVisibleObject(MovableObject* mo, 
298
            Camera* cam, 
299
            bool onlyShadowCasters, 
300
            VisibleObjectsBoundsInfo* visibleBounds);
301
302
    };
303
304
    /** @} */
305
    /** @} */
306
307
}
308
309
#include "OgreHeaderSuffix.h"
310
311
#endif