My main problem was that I needed to do some special handling in the AutoParamDataSource class (which provides information about the scene to the shaders - used by GpuProgram).
Unfortunately AutoParamDataSource is not subclass-able, so I ended up having to write a "special mode" for it. When the "special mode" is enabled some extra calculations are done that are specific to my scene manager.
I propose that all "relevent" AutoParamDataSource methods are made virtual so that scene managers can include their own AutoParamDataSource class (which subclasses from the class provided with ogre). This removes the requirement to modify the ogre source for scene manager development.
Unfortunately the AutoParamDataSource instance is "contained" within the Ogre::SceneManager class and then passed through to the GpuProgram instance via a couple of "const AutoParamDataSource&" method parameters.
For AutoParamDataSource to be subclass-able the Ogre::SceneManager class would need to contain a reference (ie: pointer) to its associated AutoParamDataSource. Also the AutoParamDataSource class needs to be passed around using "const AutoParamDataSource*".
This way scene managers could "new" their own instance of a AutoParamDataSource class and everything would work correctly.
I do have one small implementation question: how would you prefer the base Ogre::SceneManager create its AutoParamDataSource instance?
1) It could be created by using "p = new AutoParamDataSource" in the constructor, but I personally am not a huge fan of "new's" in constructors.
- this would also mean that overwriting scene managers would actually have to "delete" the base classes AutoParamDataSource instance and "new" their own in their constructor. Also not a huge fan of this either.
2) It could be created through a overwritable method of Ogre::SceneManager, for example:
Code: Select all
virtual AutoParamDataSource* AutoParamDataSourceFactory() const
{
return new AutoParamDataSource();
}
What other options do I have?
I also propose to add some more methods to the AutoParamDataSource class so that it acts more like an "interface" to the scene information for the GpuProgram class. Currently the GpuProgram class calls methods of Ogre::Light like getDerivedPosition and getAs4DVector which I also had to find work-arounds for when creating a new scene manager. I would prefer if GpuProgram called AutoParamDataSource for all of its information instead of digging around in the scenegraph. This would be solved by adding methods like getLightPostion(int i) and getLightPosition4D(int i) to AutoParamDataSource.
I just thought I'd ask for advice before submitting a patch, so if you have any thoughts let me know.

