[maybe BUG] in IMeshSceneNode->getMesh()->getBoundingBox()

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
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

[maybe BUG] in IMeshSceneNode->getMesh()->getBoundingBox()

Post by gerdb »

Hi,

i created a MeshSceneNode from another, to verify working, i just tried to render the boundingBox

in ctr i have

Code: Select all

BBox = other->getMesh()->getBoundingBox();
which does not work gives me a default constructed Box, then i tried

Code: Select all

 
for (u32 i=0; i<other->getMesh()->getMeshBufferCount(); i++)
{
if (i==0)
       BBox.reset( other->getMesh()->getMeshBuffer(i)->getBoundingBox());
else
       BBox.addInternalBox( other->getMesh()->getMeshBuffer(i)->getBoundingBox());
}
 
and got the right BBox in size.

so my guess is, that giving a Mesh to IMeshSceneNode does not calculate the Mesh's BBox from its MeshBuffer children.

Question: is this a bug or wished behaviour?

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

Re: [maybe BUG] in IMeshSceneNode->getMesh()->getBoundingBox

Post by CuteAlien »

Hm, I'm confused right now. I thought IMesh would have a recalculateBoundingBox function, but it seems only SMesh and the Meshbuffers have that.

So the idea is - if you changed a meshbuffer then call recalculateBoundingBox afterward. And if the MeshBuffer is in a SMesh then also call recalculateBoundingBox for the SMesh (additionally). Maybe that helps you already in your case.

I'm just puzzled right now what to do if you have a meshbuffer and only a an IMesh* ...
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
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: [maybe BUG] in IMeshSceneNode->getMesh()->getBoundingBox

Post by gerdb »

hi, the problem is adding the meshbuffer to mesh, which does not call addInternalBox()

file://include/SMesh.h

Code: Select all

                //! adds a MeshBuffer
                void addMeshBuffer(IMeshBuffer* buf)
                {
                        if (buf)
                        {
                                buf->grab();
                                MeshBuffers.push_back(buf);
                        }
                }
change to

Code: Select all

                //! adds a MeshBuffer
                void addMeshBuffer(IMeshBuffer* buf)
                {
                        if (buf)
                        {
                                buf->grab();
                                MeshBuffers.push_back(buf);
                                //! fix
                                BoundingBox.addInternalBox ( buf->getBoundingBox());
                        }
                }
cya
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: [maybe BUG] in IMeshSceneNode->getMesh()->getBoundingBox

Post by REDDemon »

yes I think that should be the right behaviour this way. The problem is to check all other places in wich Irrlicht is using "addMeshBuffer" on SMesh and see if this will change something. For example in geomtry creator

I see few things that after that change should be done and some redundant code that can be removed. The most hard thing will be to update that for all the mesh loaders O_O.


would be nice to add few comments to specify the usage of IMesh class. For now can be safer specify in "addMeshBuffer" that the BB is not updated than apply that little change (wich can messup lot of things).
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [maybe BUG] in IMeshSceneNode->getMesh()->getBoundingBox

Post by hybrid »

Yeah, this is a problem with the long standing heritage of Irrlicht. Most interfaces were not properly documented in these regards, and additions developed in one or the other way. I assume that this update was left out for performance reasons. Also, when adding an empty buffer, the new box could be wrong. So I'd also prefer to first add a hint in the API docs and later on think about a better way to ease the use of meshbuffers.
Post Reply