[fixed]SSharedMeshBuffer, cannot instantiate abstract class

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
henko
Posts: 6
Joined: Mon Sep 19, 2011 3:08 pm

[fixed]SSharedMeshBuffer, cannot instantiate abstract class

Post by henko »

Irrlicht trunk r3920:
'irr::scene::SSharedMeshBuffer' : cannot instantiate abstract class
Visual Studio 2010

It does not implement the following methods of the IMeshBuffer interface:

Code: Select all

 
//! returns position of vertex i
virtual const core::vector3df& getPosition(u32 i) const = 0;
 
//! returns position of vertex i
virtual core::vector3df& getPosition(u32 i) = 0;
 
//! returns normal of vertex i
virtual const core::vector3df& getNormal(u32 i) const = 0;
 
//! returns normal of vertex i
virtual core::vector3df& getNormal(u32 i) = 0;
 
//! returns texture coord of vertex i
virtual const core::vector2df& getTCoords(u32 i) const = 0;
 
//! returns texture coord of vertex i
virtual core::vector2df& getTCoords(u32 i) = 0;
 
Is this class intended to be abstract?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: SSharedMeshBuffer, cannot instantiate abstract class

Post by hybrid »

Yeah, you're right. It's fixed now in the 1.7 branch. Will be merged to trunk in the next weeks. I guess I should also implement a test case which simply instantiates all S* classes from include/ to check their proper implementations.
henko
Posts: 6
Joined: Mon Sep 19, 2011 3:08 pm

Re: SSharedMeshBuffer, cannot instantiate abstract class

Post by henko »

Thanks. I have one more question about IMeshBuffer:

The index format seems to be constrained by the interface itself:
virtual u16 * getIndices ()=0
virtual const u16 * getIndices () const =0

It seemed to me that only 16 bit indices are allowed when using the IMeshBuffer or any of its implementations. But then what is the point of the following method:
virtual video::E_INDEX_TYPE getIndexType () const =0

I needed a MeshBuffer that supports 32 bit indices, so I implemented the getIndices by returning my u32* index array casted into u16* pointer. It actually seems to work, but I just don't get it. Do I miss something?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: SSharedMeshBuffer, cannot instantiate abstract class

Post by hybrid »

You'd have to cast this to u32* in case the type is 32BIT. You cannot use this with any mesh buffer, though, only the dynamic ones with 32bit support.
henko
Posts: 6
Joined: Mon Sep 19, 2011 3:08 pm

Re: [fixed]SSharedMeshBuffer, cannot instantiate abstract cl

Post by henko »

One more method is missing from SSharedMeshBuffer:

Code: Select all

 
//! Get type of index data which is stored in this meshbuffer.
/** \return Index type of this buffer. */
virtual video::E_INDEX_TYPE getIndexType() const =0;
 
I checked your modifications in r3922 and getIndexType() is still missing.

And for the index type question. Shouldn't getIndices() also return a void* pointer like getVertices() ?

void* getVertices()
instead of u16* getIndices()
void* getIndices()

So it would allow any type of indices determined by getIndexType().
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [fixed]SSharedMeshBuffer, cannot instantiate abstract cl

Post by hybrid »

Yeah, I added only the methods you mentioned before. I did not yet instantiate all those classes in a test case, that will follow later. getIndexType is now also added.
The return type was not changed due to backward compatibility reasons. So you need to cast to u32* if the index type says you have 32bit.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [fixed]SSharedMeshBuffer, cannot instantiate abstract cl

Post by CuteAlien »

Is it OK if I remove the checks in those new functions (if (Vertices) etc)? We don't do them in CMeshBuffer and we get warnings because of returning a reference to a local variable. Could also add an empty vector2df as done otherwhere if you prefer that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [fixed]SSharedMeshBuffer, cannot instantiate abstract cl

Post by hybrid »

No I don't think that we need the checks. Don't know why those errors didn't come up in the first test. Probably it simply didn't instantiate those classes at all...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [fixed]SSharedMeshBuffer, cannot instantiate abstract cl

Post by CuteAlien »

I see you just removed them, but only in trunk - the checks got also added in 1.7 so still in there.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [fixed]SSharedMeshBuffer, cannot instantiate abstract cl

Post by hybrid »

Ah, damn it. I was just working on trunk and was remembered by the warning. I'll remove them from the branch as well.
Post Reply