- fixed worldPlane init to avoid NPE when camera is loaded from a saved file.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7504 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent ab10b457b0
commit bc8162104f
  1. 17
      engine/src/core/com/jme3/renderer/Camera.java

@ -210,12 +210,15 @@ public class Camera implements Savable, Cloneable {
/** The camera's name. */
protected String name;
/**
* Don't use this constructor, use Camera(int width, int height)
* This constructor is for serialization only
*/
public Camera() {
worldPlane = new Plane[MAX_WORLD_PLANES];
for (int i = 0; i < MAX_WORLD_PLANES; i++) {
worldPlane[i] = new Plane();
}
}
/**
@ -223,6 +226,7 @@ public class Camera implements Savable, Cloneable {
* values of the camera are set to default.
*/
public Camera(int width, int height) {
this();
location = new Vector3f();
rotation = new Quaternion();
@ -243,11 +247,6 @@ public class Camera implements Savable, Cloneable {
viewPortTop = 1.0f;
viewPortBottom = 0.0f;
worldPlane = new Plane[MAX_WORLD_PLANES];
for (int i = 0; i < MAX_WORLD_PLANES; i++) {
worldPlane[i] = new Plane();
}
this.width = width;
this.height = height;
@ -1363,7 +1362,7 @@ public class Camera implements Savable, Cloneable {
public void read(JmeImporter e) throws IOException {
InputCapsule capsule = e.getCapsule(this);
location = (Vector3f) capsule.readSavable("location", Vector3f.ZERO.clone());
rotation = (Quaternion) capsule.readSavable("rotation", Quaternion.DIRECTION_Z);
rotation = (Quaternion) capsule.readSavable("rotation", Quaternion.DIRECTION_Z.clone());
frustumNear = capsule.readFloat("frustumNear", 1);
frustumFar = capsule.readFloat("frustumFar", 2);
frustumLeft = capsule.readFloat("frustumLeft", -0.5f);
@ -1378,8 +1377,8 @@ public class Camera implements Savable, Cloneable {
viewPortRight = capsule.readFloat("viewPortRight", 1);
viewPortTop = capsule.readFloat("viewPortTop", 1);
viewPortBottom = capsule.readFloat("viewPortBottom", 0);
width = capsule.readInt("width", 0);
height = capsule.readInt("height", 0);
width = capsule.readInt("width", 1);
height = capsule.readInt("height", 1);
name = capsule.readString("name", null);
onFrustumChange();
onViewPortChange();

Loading…
Cancel
Save