Late-Binding Data
-
wynnj
- Halfling
- Posts: 44
- Joined: Sun Aug 13, 2006 4:04 pm
- Location: Norman, OK, USA
- Contact:
Late-Binding Data
I was reading an article in the Feb '05 issue of GD Mag about late binding data. It basically senses automatically when a file is updated and then reloads it into memory. I've done some preliminary tests integrating the code from the article into Ogre and it seems fairly straight forward. I have the meshes and textures automatically updating whenever the file is replaced. I think that with a little work the materials could be reloaded as well, but messing with the interpreters was a little hairy for my tests.
Is this functionality that many people would like to see in Ogre? I think its really handy, personally, and many studios have integrated it into their pipelines already.
Is this functionality that many people would like to see in Ogre? I think its really handy, personally, and many studios have integrated it into their pipelines already.
-
wynnj
- Halfling
- Posts: 44
- Joined: Sun Aug 13, 2006 4:04 pm
- Location: Norman, OK, USA
- Contact:
Ok, I just found a similar topic (should start performing more thorough searches) at http://www.ogre3d.org/phpBB2/viewtopic.php?t=37967 so I'm obviously not the first one to ask about this. Should I just post a "how-to" on the topic, or could this actually become a feature? I don't mind doing the work, as I want the feature for myself anyways.
Also, I noticed that when I call reload on a mesh it crashes the system. I was able to get around this by detaching and destroying all the entities referencing the mesh before i called reload, and then recreated them, but this is rather cumbersome. Is there a simpler way to do this?
Also, I noticed that when I call reload on a mesh it crashes the system. I was able to get around this by detaching and destroying all the entities referencing the mesh before i called reload, and then recreated them, but this is rather cumbersome. Is there a simpler way to do this?
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
I'd like to support this, but I've never found the time to do it before. So any contribution will be welcome, be it an example in the wiki or a patch. The mahor consideration if it's a patch is to make it cross-platform, you will probably need different implementations per platform. If you can't do that right now, a wiki article might be better until someone has the chance to round it out to full platform support.
-
wynnj
- Halfling
- Posts: 44
- Joined: Sun Aug 13, 2006 4:04 pm
- Location: Norman, OK, USA
- Contact:
Ok, I will start with the win32 implementation, but I think I can probably use the pnotify library to add support for linux/OSX. That would add yet another dependency though.
It was my understanding that when you reload a resource all the references are supposed to keep, but when you reload a mesh it appears to invalidate them. Is this a bug, or is it how it is supposed to function?
It was my understanding that when you reload a resource all the references are supposed to keep, but when you reload a mesh it appears to invalidate them. Is this a bug, or is it how it is supposed to function?
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
The top-level reference will stay valid, the problem is likely to be with the SubMeshes and the references Entity keeps - this is unavoidable as you may change the number of SubMeshes for example.
Resource was enhanced fairly recently to deal better with reloaded resources so that dependents can check and rebuild derived data - see Resource::getStateCount. Entity now checks this before rendering to rebuild it's local SubEntities etc so in HEAD you should hopefully find this improved.
Resource was enhanced fairly recently to deal better with reloaded resources so that dependents can check and rebuild derived data - see Resource::getStateCount. Entity now checks this before rendering to rebuild it's local SubEntities etc so in HEAD you should hopefully find this improved.
- Game_Ender
- Ogre Magi
- Posts: 1269
- Joined: Wed May 25, 2005 2:31 am
- Location: Rockville, MD, USA
For linux you should just be able to use inotify directly, no need to use a library in between. IBM has a tutorial here.
Robotics @ Maryland AUV Team - Software Lead
- Game_Ender
- Ogre Magi
- Posts: 1269
- Joined: Wed May 25, 2005 2:31 am
- Location: Rockville, MD, USA
Yes buts its also another dependency. It really depends on how much Ogre wants to support non Linux/Win/OSX platforms. pnotify makes that easily possible. If we want to go the pnotify way I think it would be better to add Windows support to pnotify, and send the changes upstream.
Robotics @ Maryland AUV Team - Software Lead
-
wynnj
- Halfling
- Posts: 44
- Joined: Sun Aug 13, 2006 4:04 pm
- Location: Norman, OK, USA
- Contact:
Re: Late-Binding Data
It took me a year to get back to this, but now I actually have something working. Or at least enough to launch into trying to more closely integrate with Ogre. I decided to not use pnotify simply because its implementation was blocking and I definitely didnt want to mess with threads. This also means there are no extra dependencies in the code that I've written.
One thing that I've not been able to puzzle out is reloading material files. If I try to load them a second time, it just says it already exists and throws an error, but reload doesn't work on them either because they are listed by material name not filename. Not sure how I can solve this without making changes deep into the material system.
One thing that I've not been able to puzzle out is reloading material files. If I try to load them a second time, it just says it already exists and throws an error, but reload doesn't work on them either because they are listed by material name not filename. Not sure how I can solve this without making changes deep into the material system.
- madmarx
- OGRE Expert User

- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 51
Re: Late-Binding Data
Two weeks ago i made a helper class that check for latest modification time of files in the disk, and reloads the material even when they are applied , and also give an output string with errors that were logged in the log ("myshader.cg made an error line 20...").
The whole thing is damn easy to use, and reloads efficiently material, shaders, textures...
I posted the full source code of this class in the Yaose Topic + example of a call and setup.
This is in the topic :
http://www.ogre3d.org/forums/viewtopic.php?f=5&t=46787
I hope this helps!
The whole thing is damn easy to use, and reloads efficiently material, shaders, textures...
I posted the full source code of this class in the Yaose Topic + example of a call and setup.
This is in the topic :
http://www.ogre3d.org/forums/viewtopic.php?f=5&t=46787
I hope this helps!
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
- Misterblue
- Gnoblar
- Posts: 17
- Joined: Sun Dec 21, 2008 8:36 pm
- Location: Oregon, USA
- Contact:
Re: Late-Binding Data
I have spent some time figuring out how to have on demand resources in Ogre. I wrote up a description and code of my solution at http://misterblue.com/programming/dynam ... -resources. What worked for me is adding an Archive class to catch the requests for meshes and textures and used one of the listener classes to capture material requests.
I'm sure it's not the most efficient solution but it is working for me.
I'm sure it's not the most efficient solution but it is working for me.
- xavier
- OGRE Retired Moderator

- Posts: 9481
- Joined: Fri Feb 18, 2005 2:03 am
- Location: Dublin, CA, US
- x 22
Re: Late-Binding Data
The problem everyone is going to run into, is the fact that Ogre inherently caches pointers to its resources -- nothing (other than textures, which use name) are dealt with in terms of "handles". It's all direct pointer access. Until you figure out how to overcome this one, you're probably going to spend a lot of time chasing your tail in pursuit of this.
I'd recommend looking forward to the 2.0 timeframe and laying out an approach to refactor Ogre out of its cached-pointer-ness.
I'd recommend looking forward to the 2.0 timeframe and laying out an approach to refactor Ogre out of its cached-pointer-ness.
-
wynnj
- Halfling
- Posts: 44
- Joined: Sun Aug 13, 2006 4:04 pm
- Location: Norman, OK, USA
- Contact:
Re: Late-Binding Data
Is there a reason that textures are looked up by name instead of a pointer? It seems that if it was terribly performance intensive to use a handle rather than a pointer then they too would be using pointers. If that is not the case, then is there a reason to not use handles (mesh name, material name, etc) for other resources as well? It would make it much easier to do streaming, caching, hot-reloading, etc. if it was all handle based.
