Page 1 of 2

[fixed]Cameras showing up in collisions

Posted: Fri Apr 17, 2015 8:05 am
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?

Re: ISceneNode:: isVisible returning true for cameras

Posted: Fri Apr 17, 2015 8:25 am
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?

Re: ISceneNode:: isVisible returning true for cameras

Posted: Sat Apr 18, 2015 8:58 am
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?

Re: ISceneNode:: isVisible returning true for cameras

Posted: Sat Apr 18, 2015 10:57 am
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).

Re: ISceneNode:: isVisible returning true for cameras

Posted: Sat Apr 18, 2015 6:02 pm
by robmar
Okay thanks for that. But usually cameras don't have children right? I mean why would they?

Re: ISceneNode:: isVisible returning true for cameras

Posted: Sun Apr 19, 2015 11:08 am
by CuteAlien
One place where I know it's used: Put a mesh at the camera positions in 3d-editors.

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

Posted: Sun Apr 19, 2015 11:16 am
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?

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

Posted: Sun Apr 19, 2015 11:44 am
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.

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

Posted: Sun Apr 19, 2015 12:16 pm
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.

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

Posted: Sun Apr 19, 2015 4:58 pm
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.

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

Posted: Sun Apr 19, 2015 5:21 pm
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?

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

Posted: Sun Apr 19, 2015 6:13 pm
by CuteAlien
Don't know yet - I'll have to write a test-case and debug it myself.

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

Posted: Sun Apr 19, 2015 6:21 pm
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.

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

Posted: Sun Apr 19, 2015 8:03 pm
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?

Re: [fixed]Cameras showing up in collisions

Posted: Sun Apr 19, 2015 9:23 pm
by Seven
I always just set the cameras to debugobjects and then not collide against them