Unexpected Behavior: Camera.clone()

I’m not sure if this is intended behavior or not, but I noticed, in jME 3.1 Beta 1, when creating a new camera using Camera.clone() or Camera.copyFrom(Camera) changing the frustum on one effects both cameras.

P.S. Is this the proper place for bug reporting or should I be posting this somewhere else?

Yes, this is fine to trouble shoot issues like this.

…but looking in Camera.java, I can’t see how your assertion is true. So we will require a simple single class test case to verify that there isn’t some other strange thing at play.

I didn’t look at the source. Basically I took the game camera and cloned it to create another camera and viewport. Later I do setFrustumPerspective on the game camera with a wider field of view and the field of view for the cloned camera also changed. The cloned camera’s viewport is a post view so it’s rendered on top of the game viewport.

When I got rid of the code cloning the game camera and instead just setup the camera as new Camera(width, height) the problem ceased.

I could watch as the frustum of both cameras changed at the same time. The only code I changed was getting rid of Camera.clone() and replacing it with new Camera(width, height).

Well, I can’t see your source so I don’t know if you messed up a reference somewhere or any of a hundred other things I can’t see.

What I CAN see is that Camera clones every field including the arrays, matrixes, etc. So we will (again) need a single class test case that illustrates the issue.

This is unusual. Are you sure you don’t somehow refer to the first camera object?

You must have something going on that you haven’t noticed yet. I just tested this with 3.1 with two (overlaid) cams, different frustum FOVs (also different near/far) and it’s behaving exactly the way I’d expect. The only thing I didn’t change was the aspect ratio.

I changed it back and it doesn’t seem to be doing it any more which is odd since I haven’t changed any code relating to cameras and viewports.

Anyway while I have you here there is an issue with the scene composer. If you open a saved scene and one of the shaders used in the scene has errors it errors out saying the shader could not be compiled, however, upon closing the scene, fixing the error and reopening the scene it still will not display complaining of a failed shader compilation. You have to restart the SDK in order to open the scene again.

But this is SDK related and not JME 3.1 related. I guess it will be more @Darkchaos you have to ask.

Yep please open an issue on the SDK repo for that. I guess this is some how related to some caching, possibly the whole j3o due to the assetmanager