smgr->getMesh seg

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mistral
Posts: 14
Joined: Mon Jan 23, 2017 9:35 am

smgr->getMesh seg

Post by mistral »

Every now and again I don't seem to be able to load anything using the following, it just segs. I've tried different model formats, with and without animation keys, no compression. The variable smgr appears to be valid. I'm at a loss at what to try :D

Code: Select all

 
IAnimatedMesh *mesh = smgr->getMesh("media/box.x");
 

Thanks
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: smgr->getMesh seg

Post by CuteAlien »

If the same file sometimes works and sometimes fails the bug is very likely in your code. Divide and conquer - reduce your code until no more lines can be removed but the bug is still in there. Then you got an example which still compiles and only contains the bug - that's the one we need to see here to help you.

That line you posted above is simply the code everyone uses to load their meshes, that's not the bug.
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
mistral
Posts: 14
Joined: Mon Jan 23, 2017 9:35 am

Re: smgr->getMesh seg

Post by mistral »

Yeah that's been my dilemma... nothing has changed to that (surrounding) code, also this has appeared before and disappeared. That line is so fundamental, I am sure it works, just confused where else to look now. But I'll take your advice and rip it apart, it'll only get stronger.


Something I have planned but not got around to doing yet, is to use the named method of loading media and reusing. I mention this since I read about issues loading the same image twice for the gui. So wondered if this is along the same lines? But what else affects this?

Oh, until I rip it apart, there's way too much to post here, I can let you see it privately though, but, I'm self taught so it'll be an experience :D
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: smgr->getMesh seg

Post by CuteAlien »

Well - maybe your callstack in the debugger can give you some idea? It should at least be easy to see there if any pointers look strange (most likely pointer with troubles here is obviously "smgr").

What is the "named method of loading media and reusing"? Sorry, i'm not getting what you are talking about 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
Blueman27
Posts: 5
Joined: Sat Nov 21, 2015 1:17 am

Re: smgr->getMesh seg

Post by Blueman27 »

I've found that defining these variables inside of a function causes issues when passing them to a class or another function. Variables such as IrrlichtDevice, IVideoDriver, and ISceneManager should be defined globally.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: smgr->getMesh seg

Post by CuteAlien »

@Blueman27: No, they behave like any objects in c++. Meaning - you have to learn about scopes in c++ and about passing variables and pointers. There is nothing special there about Irrlicht.
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
mistral
Posts: 14
Joined: Mon Jan 23, 2017 9:35 am

Re: smgr->getMesh seg

Post by mistral »

CuteAlien wrote:Well - maybe your callstack in the debugger can give you some idea? It should at least be easy to see there if any pointers look strange (most likely pointer with troubles here is obviously "smgr").

What is the "named method of loading media and reusing"? Sorry, i'm not getting what you are talking about there :-)

A) I'll look into it, but I have tested smgr with other functions and it's working fine. It's also the root pointer for the device.

B) er, probably me, like with textures where you can load them once whilst giving name, then use by name... Its something I'm aware of but not made full use of yet, I "assumed" it'd be the same with meshes, but hmm not seeing them now I'm looking.


I had a quick play last night, and this is only happening with one game class, so I have new routes to track down, but later.

Thanks, I'll report back once I find my issue...


@Blueman27, this singleton class holds the original pointer to each irr device*, then it also provides direct access to them. Never had an issue with the device pointers and testing here doesn't indicate that being the issue here.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: smgr->getMesh seg

Post by CuteAlien »

getTexture in IVideoDriver does cache textures by name. So it works like meshes. If that's what you mean.
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
mistral
Posts: 14
Joined: Mon Jan 23, 2017 9:35 am

Re: smgr->getMesh seg

Post by mistral »

:D

Schoolboy error if I ever was!

A manager class wasn't checking for a valid pointer in its event handler.


Big thanks!


Oh, CuteAlien, I had a look at Tübingen online last night, looks very nice indeed!
Post Reply