Dirty Ogre::Pass cleanup not happening correctly with multiple SceneManagers

Description

Original author: MattStevens

How to reproduce: You need to use 2 scene managers and render with both of them. Then, modify some Ogre:ass that is being used to mark it as dirty (something like the TextureUnitState so that the Pass's hash changes).

If the bug happens, you will either get an assert (in debug), or memory will start to leak (in release).

The following is a smaller repost of the forum thread where I exposed the problem. I added the thread link in the "Additional Information" field.

The issue is related to the RenderQueue cleanup when Passes are tagged as dirty. The usual behavior is that the Ogre::RenderPriorityGroup are cleared by the Ogre::RenderQueue at the beginning of a render to remove the dirty Ogre:ass from the QueuedRenderableCollection::mGrouped map. (See RenderPriorityGroup::clear in OgreRenderQueueSortingGrouping.cpp) If this is not done, and the Pass's hash changed, the mGrouped map's key will be messed up and troubles happen. This works perfectly when using a single SceneManager, not when using 2 or more. The reason is that the dirty Pass list is static and cleared by the RenderQueue and by having 2 SceneManager you have 2 RenderQueue. With the current code, only 1 RenderQueue will be able to clean itself correctly, and the second one will cause a lot of troubles (Likely crash, memory leak or assert).

Forum thread explaining in greater details:
http://www.ogre3d.org/forums/viewtopic.php?f=4&t=73193

Original Mantis Ticket: http://www.ogre3d.org/mantis/view.php?id=581

Environment

None

Assignee

Unassigned

Reporter

Philip Allgaier

Labels

None

Components

Fix versions

Affects versions

Priority

Major
Configure