[fixed]Cameras showing up in collisions

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.
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

[fixed]Cameras showing up in collisions

Post by robmar »

Should isVisible return true for the scene camera? I can't see why it should but maybe someone knows a reason?

Maybe we could add:

if (IsVisible && getType != ESNT_CAMERA)
return IsVisible;
return IsVisibile;

Or is there a better patch to ignore cameras in the code that sets this flag?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ISceneNode:: isVisible returning true for cameras

Post by CuteAlien »

It's a little tricky as isVisible() is not exactly defined in Irrlicht. For most nodes it has 2 meanings - register this node for rendering _and_ call OnRegisterSceneNode for children. For the default Irrlicht camera it only has the second meaning as registration depends on the camera being the active camera instead. Thought custom cameras can decide to do different.

I think just returning the IsVisible flag makes most sense. Why you want/need a change?
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
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: ISceneNode:: isVisible returning true for cameras

Post by robmar »

Thanks, that´s good to know!

I added the code above to have the camera return not visible and everything seems to work fine.

Could it be the camera isn't registering now? What would be the effects?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ISceneNode:: isVisible returning true for cameras

Post by CuteAlien »

No, what I meant to write above is - the camera is the one node that doesn't use this for registering itself (the active scenecamera is always registered instead). It only uses it for registering it's children (same as other nodes - if you make a node invisible then all it's children are invisible as well).
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
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: ISceneNode:: isVisible returning true for cameras

Post by robmar »

Okay thanks for that. But usually cameras don't have children right? I mean why would they?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ISceneNode:: isVisible returning true for cameras

Post by CuteAlien »

One place where I know it's used: Put a mesh at the camera positions in 3d-editors.
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
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: [no bug]ISceneNode:: isVisible returning true for camera

Post by robmar »

But for that a call to get activecamera would do, no?

Okay so maybe rather than doing the check in all call to is visible, I could add an isVisible function to ICameraSceneNode, would be more efficient and flexible?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [no bug]ISceneNode:: isVisible returning true for camera

Post by CuteAlien »

I don't think you understood what I meant. In 3D editors you can have a lot of cameras placed all over the scene. And you want to see them all at once - so you attach a node with a mesh below them. And yeah - there are other ways.

But I still don't understand something - what problem are you actually having with this? I don't get yet where this causes trouble for you.
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
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: [no bug]ISceneNode:: isVisible returning true for camera

Post by robmar »

Okay so with editors there are cameras for all the views, and they can be switched to, but are cameras rendered, like in Blender, as a sort of outline camera?

During hits where you have a point in 3D space and a vector, calling the usual function... what's its name,... even though I have one camera, it finds the camera first each time, so I thought I would just have it invisible, then I get the correct node in the line.

I guess I could use mask bits, but I wanted to find any node in the line, apart from the camera.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [no bug]ISceneNode:: isVisible returning true for camera

Post by CuteAlien »

Cameras have no geometry, but maybe they get hit by their bounding-box in some functions. Please try to find out that function's name, maybe it can be solved in another way :-)

edit: You can also work with node-id's to exclude nodes. But shouldn't be necessary for cameras.
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
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: [no bug]ISceneNode:: isVisible returning true for camera

Post by robmar »

I call getSceneNodeFromScreenCoordinatesBB(), that function then calls another ending in BB which hits the camera.

I tried to hit the skydome but tracing through found that it has no bounding box. The idea is to be able to detect whatever object was hit.

Why would a camera without geometry have a bounding box? Or am I missing something?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [no bug]ISceneNode:: isVisible returning true for camera

Post by CuteAlien »

Don't know yet - I'll have to write a test-case and debug it myself.
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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [no bug]ISceneNode:: isVisible returning true for camera

Post by CuteAlien »

I see - it returns the bounding-box of the frustum. Which is kinda pointless as one can get that already from the frustum and it messes up this situation. But changing it now might break existing code. *sigh*... maintaining code is frustrating.

edit: *doublesigh* - it was different originally, but changed a few years ago without a single comment in the log as to why it might have been necessary to change it.
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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [no bug]ISceneNode:: isVisible returning true for camera

Post by CuteAlien »

OK, I've added a few changes in svn trunk (r5094) which should make this work for you. The camera has now an empty boundingbox and the collision functions ignore empty boundingboxes. I'm rather surprised no one complained about this before - it's a rather strange default behavior.

I hope those changes don't break code. It's pretty crazy - someone even wrote a few tests for exactly that behavior. But again they are all without any explanation as to _why_ this behavior would make any sense. So maybe there was a good reason - but I really can't see it. I mean who expects camera-frustum boundingboxes to show up in node-collisions?
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
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: [fixed]Cameras showing up in collisions

Post by Seven »

I always just set the cameras to debugobjects and then not collide against them
Post Reply