Modified to keep its projectionMatrixOverride around
to avoid garbage creation in setClipPlane().
This commit is contained in:
		
							parent
							
								
									ca6d3f4e73
								
							
						
					
					
						commit
						2d549ea833
					
				| @ -195,7 +195,8 @@ public class Camera implements Savable, Cloneable { | |||||||
|      * store the value for field parallelProjection |      * store the value for field parallelProjection | ||||||
|      */ |      */ | ||||||
|     private boolean parallelProjection = true; |     private boolean parallelProjection = true; | ||||||
|     protected Matrix4f projectionMatrixOverride; |     protected Matrix4f projectionMatrixOverride = new Matrix4f(); | ||||||
|  |     private boolean overrideProjection; | ||||||
|     protected Matrix4f viewMatrix = new Matrix4f(); |     protected Matrix4f viewMatrix = new Matrix4f(); | ||||||
|     protected Matrix4f projectionMatrix = new Matrix4f(); |     protected Matrix4f projectionMatrix = new Matrix4f(); | ||||||
|     protected Matrix4f viewProjectionMatrix = new Matrix4f(); |     protected Matrix4f viewProjectionMatrix = new Matrix4f(); | ||||||
| @ -328,15 +329,9 @@ public class Camera implements Savable, Cloneable { | |||||||
|         } |         } | ||||||
|          |          | ||||||
|         this.parallelProjection = cam.parallelProjection; |         this.parallelProjection = cam.parallelProjection; | ||||||
|         if (cam.projectionMatrixOverride != null) { |         this.overrideProjection = cam.overrideProjection; | ||||||
|             if (this.projectionMatrixOverride == null) { |         this.projectionMatrixOverride.set(cam.projectionMatrixOverride); | ||||||
|                 this.projectionMatrixOverride = cam.projectionMatrixOverride.clone(); |          | ||||||
|             } else { |  | ||||||
|                 this.projectionMatrixOverride.set(cam.projectionMatrixOverride); |  | ||||||
|             } |  | ||||||
|         } else { |  | ||||||
|             this.projectionMatrixOverride = null; |  | ||||||
|         } |  | ||||||
|         this.viewMatrix.set(cam.viewMatrix); |         this.viewMatrix.set(cam.viewMatrix); | ||||||
|         this.projectionMatrix.set(cam.projectionMatrix); |         this.projectionMatrix.set(cam.projectionMatrix); | ||||||
|         this.viewProjectionMatrix.set(cam.viewProjectionMatrix); |         this.viewProjectionMatrix.set(cam.viewProjectionMatrix); | ||||||
| @ -395,7 +390,7 @@ public class Camera implements Savable, Cloneable { | |||||||
|          |          | ||||||
|         TempVars vars = TempVars.get(); |         TempVars vars = TempVars.get(); | ||||||
|         try {         |         try {         | ||||||
|             Matrix4f p = projectionMatrix.clone(); |             Matrix4f p = projectionMatrixOverride.set(projectionMatrix); | ||||||
| 
 | 
 | ||||||
|             Matrix4f ivm = viewMatrix; |             Matrix4f ivm = viewMatrix; | ||||||
| 
 | 
 | ||||||
| @ -1091,7 +1086,13 @@ public class Camera implements Savable, Cloneable { | |||||||
|      * @param projMatrix |      * @param projMatrix | ||||||
|      */ |      */ | ||||||
|     public void setProjectionMatrix(Matrix4f projMatrix) { |     public void setProjectionMatrix(Matrix4f projMatrix) { | ||||||
|         projectionMatrixOverride = projMatrix; |         if (projMatrix == null) { | ||||||
|  |             overrideProjection = false; | ||||||
|  |             projectionMatrixOverride.loadIdentity();    | ||||||
|  |         } else { | ||||||
|  |             overrideProjection = true;             | ||||||
|  |             projectionMatrixOverride.set(projMatrix); | ||||||
|  |         }             | ||||||
|         updateViewProjection(); |         updateViewProjection(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1102,7 +1103,7 @@ public class Camera implements Savable, Cloneable { | |||||||
|      * of the camera. |      * of the camera. | ||||||
|      */ |      */ | ||||||
|     public Matrix4f getProjectionMatrix() { |     public Matrix4f getProjectionMatrix() { | ||||||
|         if (projectionMatrixOverride != null) { |         if (overrideProjection) { | ||||||
|             return projectionMatrixOverride; |             return projectionMatrixOverride; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -1113,7 +1114,7 @@ public class Camera implements Savable, Cloneable { | |||||||
|      * Updates the view projection matrix. |      * Updates the view projection matrix. | ||||||
|      */ |      */ | ||||||
|     public void updateViewProjection() { |     public void updateViewProjection() { | ||||||
|         if (projectionMatrixOverride != null) { |         if (overrideProjection) { | ||||||
|             viewProjectionMatrix.set(projectionMatrixOverride).multLocal(viewMatrix); |             viewProjectionMatrix.set(projectionMatrixOverride).multLocal(viewMatrix); | ||||||
|         } else { |         } else { | ||||||
|             //viewProjectionMatrix.set(viewMatrix).multLocal(projectionMatrix); |             //viewProjectionMatrix.set(viewMatrix).multLocal(projectionMatrix); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user