Modified Camera.setClipPlane() to avoid garbage
creation using tempvars. Only a new matrix is created now and I think I can get rid of that, too.
This commit is contained in:
		
							parent
							
								
									e0ee685466
								
							
						
					
					
						commit
						ed443bcfa2
					
				| @ -392,30 +392,36 @@ public class Camera implements Savable, Cloneable { | |||||||
|         if (clipPlane.whichSide(location) == side) { |         if (clipPlane.whichSide(location) == side) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         Matrix4f p = projectionMatrix.clone(); |  | ||||||
|          |          | ||||||
|         Matrix4f ivm = viewMatrix.clone(); |         TempVars vars = TempVars.get(); | ||||||
|  |         try {         | ||||||
|  |             Matrix4f p = projectionMatrix.clone(); | ||||||
| 
 | 
 | ||||||
|         Vector3f point = clipPlane.getNormal().mult(clipPlane.getConstant()); |             Matrix4f ivm = viewMatrix; | ||||||
|         Vector3f pp = ivm.mult(point); |  | ||||||
|         Vector3f pn = ivm.multNormal(clipPlane.getNormal(), null); |  | ||||||
|         Vector4f clipPlaneV = new Vector4f(pn.x * sideFactor, pn.y * sideFactor, pn.z * sideFactor, -(pp.dot(pn)) * sideFactor); |  | ||||||
| 
 | 
 | ||||||
|         Vector4f v = new Vector4f(0, 0, 0, 0); |             Vector3f point = clipPlane.getNormal().mult(clipPlane.getConstant(), vars.vect1); | ||||||
|  |             Vector3f pp = ivm.mult(point, vars.vect2); | ||||||
|  |             Vector3f pn = ivm.multNormal(clipPlane.getNormal(), vars.vect3); | ||||||
|  |             Vector4f clipPlaneV = vars.vect4f1.set(pn.x * sideFactor, pn.y * sideFactor, pn.z * sideFactor, -(pp.dot(pn)) * sideFactor); | ||||||
|      |      | ||||||
|         v.x = (Math.signum(clipPlaneV.x) + p.m02) / p.m00; |             Vector4f v = vars.vect4f2.set(0, 0, 0, 0); | ||||||
|         v.y = (Math.signum(clipPlaneV.y) + p.m12) / p.m11; |  | ||||||
|         v.z = -1.0f; |  | ||||||
|         v.w = (1.0f + p.m22) / p.m23; |  | ||||||
|      |      | ||||||
|         float dot = clipPlaneV.dot(v);//clipPlaneV.x * v.x + clipPlaneV.y * v.y + clipPlaneV.z * v.z + clipPlaneV.w * v.w; |             v.x = (Math.signum(clipPlaneV.x) + p.m02) / p.m00; | ||||||
|         Vector4f c = clipPlaneV.mult(2.0f / dot); |             v.y = (Math.signum(clipPlaneV.y) + p.m12) / p.m11; | ||||||
|  |             v.z = -1.0f; | ||||||
|  |             v.w = (1.0f + p.m22) / p.m23; | ||||||
|      |      | ||||||
|         p.m20 = c.x - p.m30; |             float dot = clipPlaneV.dot(v);//clipPlaneV.x * v.x + clipPlaneV.y * v.y + clipPlaneV.z * v.z + clipPlaneV.w * v.w; | ||||||
|         p.m21 = c.y - p.m31; |             Vector4f c = clipPlaneV.multLocal(2.0f / dot); | ||||||
|         p.m22 = c.z - p.m32; |      | ||||||
|         p.m23 = c.w - p.m33; |             p.m20 = c.x - p.m30; | ||||||
|         setProjectionMatrix(p); |             p.m21 = c.y - p.m31; | ||||||
|  |             p.m22 = c.z - p.m32; | ||||||
|  |             p.m23 = c.w - p.m33; | ||||||
|  |             setProjectionMatrix(p); | ||||||
|  |         } finally { | ||||||
|  |             vars.release(); | ||||||
|  |         }             | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user