Open Stinkfist0 opened 11 years ago
Bumping the issue as this has been on my mind lately and we (Admino) might be doing something regarding this.
The main problem with this setup is that EC_Mesh
casts the IAsset*
into OgreMeshAsset*
. It also requests the mesh with forced type OgreMesh
via the ref listener. This forced the Assimp integration to be quite ugly (although it already is a lot nicer with the new signal business), making the OgreMeshAsset emit a "conversion needed" signal and making something do something. It's not very structured.
So, how would this asset factory mod exactly fix this problem? EC_Mesh would still cast to the one asset type ptr even if we made AssimpMeshAsset
. Or is this some completely separate thing and does something else?
I think the easies solution to fix this mesh business is defining a OgreMeshAssetBase
or similar, that would have the needed shader variables EC_Mesh actually needs to load the mesh. As far as I can see that would be the CPU side cached geometry stuff (including the raycast func to it) and the actual Ogre::MeshPtr
.
This could then be inherited by Assimp modules AssimpOgreMeshAsset
and others, and EC_Mesh would cast to that and accept anything that implementes OgreMeshAssetBase
.
Don't think such base class would be needed. OgreMeshAsset can be considered source agnostic: once mesh data is loaded (and converted), an in-memory Ogre mesh is always an Ogre mesh and it doesn't know anything about its origins. Filename and file extension can be simply considered as metadata for identification.
I'd love to see in code a proposal how this would work, like how would the current asset request flow change. Those are nice words that everyone can agree on but are not a solution. But can you explain in detail how your factory changes would fix eg. the EC_Mesh "problem". I'm thinking in practical code change steps, you are just atm talking about a "ideal way of loading meshes" without any hint what would need to be changed.
You mean when the AssetPtr
loaded signal arrives to EC_Mesh it would query Ogre a MeshPtr with its sanitized name and use it if found? This is what you mean in the factory re-factoring that it would not actually produce any kind of IAsset but just load stuff to Ogre? Different code could handle different file extensions etc.?
That would surely work (after a fair amount of re-factoring) but the CPU side geometry caching would need to be moved somewhere per asset, maybe to OgreWorld.
This commit in the AngelScript branch is somewhat related: https://github.com/LudoCraft/Tundra/commit/d4bfce39d0a4ce13da5a71d88e9b126af3769587
This would allow getting rid of somewhat hackish integration of AssImp and Crunch and would be better for future usability when incorporating support for new asset types in Tundra. See related discussion in #513 and #532