LOD Listener
-
- Google Summer of Code Student
- Posts: 56
- Joined: Wed Jun 07, 2006 8:33 pm
- x 1
LOD Listener
A while back there was some discussion of providing a listener for LOD changes. After reading the posts on the subject and doing some preliminary work to see what’s involved, I’d like to proceed with this feature.
The initial implementation would be relatively simple, but could be extended later if required. Each scene manager would maintain a set of LodListeners which may implement the meshLodChanged method. This method would be called whenever the mesh level of detail for an entity changes with respect to a camera (triggered from Entity::_notifyCurrentCamera) and would accept a MeshLodChangedEvent argument. This argument would contain the entity and camera in question along with the previous and new lod indexes and the squared depth of the entity relative to the camera.
I will need to finish the basic implementation and perform testing before releasing a patch. Let me know what you think of my plan and how it could be improved.
The initial implementation would be relatively simple, but could be extended later if required. Each scene manager would maintain a set of LodListeners which may implement the meshLodChanged method. This method would be called whenever the mesh level of detail for an entity changes with respect to a camera (triggered from Entity::_notifyCurrentCamera) and would accept a MeshLodChangedEvent argument. This argument would contain the entity and camera in question along with the previous and new lod indexes and the squared depth of the entity relative to the camera.
I will need to finish the basic implementation and perform testing before releasing a patch. Let me know what you think of my plan and how it could be improved.
- tuan kuranes
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
- Contact:
-
- Google Summer of Code Student
- Posts: 56
- Joined: Wed Jun 07, 2006 8:33 pm
- x 1
Initially, billboard sets, particle systems, and static geometry would not produce events for the listener. Each subclass implements it's own level of detail system, so a single event is probably not desirable (unless I'm missing something). However, the listener could be extended with methods which could be called from other objects. I had not planned to implement this functionality in the initial release, but if it is an integral feature, I would be willing to work on it now.
- tuan kuranes
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
- Contact:
Well those implements "_notifycamera" but LodListener idea would be more 'userspace' so that if an user can switch from billboard to a static geometry to mesh, etc, using listener events.each subclass implements it's own level of detail system, so a single event is probably not desirable (unless I'm missing something).
And that has to be done async by the 'user' otherwise It would break current render.
if listener fire event in the middle of a render, and that user change part of the render (few isolated mesh becomes static geometry meshes.)
-
- Google Summer of Code Student
- Posts: 56
- Joined: Wed Jun 07, 2006 8:33 pm
- x 1
Thank you for your feedback.
I will try to unify the listener to all MovableObjects which implement LOD.
In my initial implementation I had assumed the user would be responsible for synchronization (not modifying the scene during the listener), as some listeners might not need to change the scene. However, I understand that it would be desirable not to burden the user with this task. Would an event queue which is handled after the scene is rendered be a good choice here?
I will try to unify the listener to all MovableObjects which implement LOD.
In my initial implementation I had assumed the user would be responsible for synchronization (not modifying the scene during the listener), as some listeners might not need to change the scene. However, I understand that it would be desirable not to burden the user with this task. Would an event queue which is handled after the scene is rendered be a good choice here?
- tuan kuranes
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
- Contact:
If you make sure the performance/memory is not impacted when there's no user-listener provided...Would an event queue which is handled after the scene is rendered be a good choice here?
Could be in two part, where user give a prequeueListener that return true if has to be queued... and a postqueuelistener that really fire event once culling/rendering pass is finished.
Otherwise documentation, comments, code has to prevent at maximum user mix renderqueue...
-
- Google Summer of Code Student
- Posts: 56
- Joined: Wed Jun 07, 2006 8:33 pm
- x 1
I'm going to go ahead and post what I have so far. I've implemented lod listeners with methods for movable object lod events. As tuan suggested, a pre-queue method is called during rendering to determine if the event should be added to the event queue. If it is, the post-queue method will be called after rendering is complete.
To use this, you will need to put OgreLodListener.h in your OgreMain/include directory and apply the supplied patch.
I've also included a simple demo.
Download:
(Required) OgreLodListener.h - http://www.mediafire.com/?fugtus122rg
(Required) Patch - http://www.mediafire.com/?hd1n9yl5gzt
(Optional) Demo - http://www.mediafire.com/?eg9egd9gjhd
Let me know what you think and how it could be improved.
To use this, you will need to put OgreLodListener.h in your OgreMain/include directory and apply the supplied patch.
I've also included a simple demo.
Download:
(Required) OgreLodListener.h - http://www.mediafire.com/?fugtus122rg
(Required) Patch - http://www.mediafire.com/?hd1n9yl5gzt
(Optional) Demo - http://www.mediafire.com/?eg9egd9gjhd
Let me know what you think and how it could be improved.
- tuan kuranes
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
- Contact:
-
- Google Summer of Code Student
- Posts: 56
- Joined: Wed Jun 07, 2006 8:33 pm
- x 1
After looking through the code, it appears _notifyCurrentCamera is performed before the render queue invocations, so it doesn't have that info. The notifications could be moved to the render queue invocation level, but at that point, it is no longer dealing with MovableObjects, but Renderables. As a result, I don't see how to supply both the MovableObject and the RenderQueueInvocation to the listeners. Let me know if I'm missing something here.
If all you want is the render queue group id, that is available through MovableObject::getRenderQueueGroup.
I'm going to go ahead and submit this on SourceForge.
If all you want is the render queue group id, that is available through MovableObject::getRenderQueueGroup.
I'm going to go ahead and submit this on SourceForge.
- tuan kuranes
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
- Contact:
-
- Google Summer of Code Student
- Posts: 56
- Joined: Wed Jun 07, 2006 8:33 pm
- x 1
I looked at RenderQueueListener, and it doesn't appear to have any information about MovableObjects (which I assume is desirable for LOD). Unless I'm mistaken, the RenderQueue contains Renderables, not MovableObjects, and is at a lower level. I'm not quite sure why individual invocations of the queue should each produce LOD events.
- tuan kuranes
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
- Contact:
-
- Google Summer of Code Student
- Posts: 56
- Joined: Wed Jun 07, 2006 8:33 pm
- x 1
I misunderstood what you were saying before. I can easily include render queue invocation events in the LOD listener. Would you prefer I do this or, as you suggested above, just include documentation stating that potentially useful render queue invocation events can be subscribed to with a RenderQueueListener?
- Praetor
- OGRE Retired Team Member
- Posts: 3335
- Joined: Tue Jun 21, 2005 8:26 pm
- Location: Rochester, New York, US
- x 3
- Contact:
-
- Google Summer of Code Student
- Posts: 56
- Joined: Wed Jun 07, 2006 8:33 pm
- x 1
Sinbad has suggested that this be incorporated into the Summer of Code lod strategy project, so any future discussion should probably take place there: http://www.ogre3d.org/phpBB2/viewtopic.php?t=40308.