IMeshLoader can now set hints to prefer 16/32 bit buffers. Obj loader can now load 32 bit buffers.

- IMeshLoader::setPreferredIndexType and getPreferredIndexType allow setting hints for the loaders if users prefer 16 or 32 bit meshbuffers. Loaders are free to ignore those hints (all but .obj will do that for now).
- obj meshloader loads now 32-bit buffers when setPreferredIndexType is set to EIT_32BIT.
NOTE: It's 16 bit meshes use now also an IDynamicMeshbuffer instead of an SMeshBuffer.
That will break the code of people who accessed meshbuffer before by casting to SMeshBuffer*
And might even be somewhat slower (lot's of virtual functions...), but shouldn't really matter and can maybe be a bit improved.
Sorry about that, I considered keeping SMeshBuffer for 16-bit (still considering it), but it would add some overhead in code and I don't think it's worth that. If there are any complains I'll maybe consider it again.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6333 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2022-04-14 14:03:39 +00:00
parent 456bf86e66
commit c58afe8038
5 changed files with 44 additions and 15 deletions

View File

@ -8,6 +8,7 @@
#include "IReferenceCounted.h"
#include "path.h"
#include "IMeshTextureLoader.h"
#include "SVertexIndex.h"
namespace irr
{
@ -29,7 +30,7 @@ class IMeshLoader : public virtual IReferenceCounted
public:
//! Constructor
IMeshLoader() : TextureLoader(0) {}
IMeshLoader() : TextureLoader(0), PreferredIndexType(video::EIT_16BIT) {}
//! Destructor
virtual ~IMeshLoader()
@ -78,8 +79,30 @@ public:
return TextureLoader;
}
//! Give loader a hint if you would prefer 16 or 32 bit meshbuffers.
/**
Generally Irrlicht works with 16-bit meshbuffers so far.
Rendering 32-bit meshbuffers works, other functions like
mesh-writing and mesh manipulation might not work yet.
NOTE: Most loaders will ignore this hint so far, but hopefully
will care about it in the future.
*/
void setPreferredIndexType(irr::video::E_INDEX_TYPE typeHint)
{
PreferredIndexType = typeHint;
}
//! Return current preference user has for the index-size of meshbuffers
/** Note that this is _not_ necessarily the type used by the meshloader */
irr::video::E_INDEX_TYPE getPreferredIndexType() const
{
return PreferredIndexType;
}
protected:
IMeshTextureLoader* TextureLoader;
irr::video::E_INDEX_TYPE PreferredIndexType;
};