Irrlicht 1.3 crashing your custom scene nodes?

Posted on:April 12 2007

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.





Comments:


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

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


Really? Could anyone tell me what override does?
Matthias
Quote
2007-04-12 10:12:00


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
Quote
2007-04-12 10:23:00


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
Quote
2007-04-12 10:55:00


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
Quote
2007-04-12 12:40:00


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


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
Quote
2007-04-14 00:24:00


Add comment:


Posted by:


Enter the missing letter in: "Intern?tional"


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons