Irrlicht 1.3 crashing your custom scene nodes?

Maybe you've just switched to Irrlicht 1.3 and your custom scene nodes are crashing in the getMaterial method. That's because we've changed the single parameter from a s32 to an u32, so your overridden method won't get called. Solution: change your parameter in getMaterial to u32 as well.
Unfortunately, C++ doesn't have a Override keyword such as C# or Java 5 have, which would have prevented that problem. Sorry to write this specific thing here, but a lot of people kept asking this. Maybe I should add this into the wiki.

seven comments, already:

dude its 9 o’clock :P and youre sick …. GO TO BED ;)

Topic: well C++ has its problems too :)
halan - 12 04 07 - 08:57

Really? Could anyone tell me what override does?
Matthias - 12 04 07 - 10:12

Matthias, override tells the compiler to override a specifiy method ;) if there is no such method to override (like in this case: getMaterial(s32) ) than the compiler will throw errors.
In C++ the compiler does not know if you want to override a function or create a new one.
sanjin - 12 04 07 - 10:23

it will not trow errors because in C++ theres no “override” keyword as niko said. instead both functoins will exist getMaterial(s32) and getMaterial(u32)

if so the getMaterial(u32) (the new one) is only defined as empty “interface”-function and produces a crash when called…
halan - 12 04 07 - 10:55

well, “empty interface function”
actualy it is defined that way:
virtual video::SMaterial& getMaterial(u32 num)
return *((video::SMaterial*)0);
casting a nullpointer to a reference :D
i mean, if that doesn’t produce a crash i don’t know

hmm, maybe it should be pure virtual since if someone wants to code a scenenode which doesn’t have any material than he shall write something dangerous like this on his own so he knows what the code is doing.
sanjin - 12 04 07 - 12:40

yeah virtual is a good way to prevent such problems, nice idea!
halan - 12 04 07 - 19:17

Yeah, proper pure virtuals should be used.
BTW: Also annoying is the wrong instruction for renaming Pre/PostRender which should be named OnRegisterSceneNode and onAnimate, repectively.
hybrid - 14 04 07 - 00:24

Displayed name:  
Remember personal info?
Website (optional):
Enter "layered" (antispam):
Comment:Emoticons / Textile


Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Note: If you type in your email adress above, it will be visible to other visitors, although it will be hidden for bots using javaScript.