* Camera.update() now uses TempVars instead of allocation
* IntMap now contains a resettable iterator instead of allocating a new one each time. As a downside, The same IntMap cannot be iterated recursively git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8541 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
		
							parent
							
								
									c590b8d054
								
							
						
					
					
						commit
						bd5620bf16
					
				| @ -1219,9 +1219,11 @@ public class Camera implements Savable, Cloneable { | |||||||
|      * <code>onFrameChange</code> updates the view frame of the camera. |      * <code>onFrameChange</code> updates the view frame of the camera. | ||||||
|      */ |      */ | ||||||
|     public void onFrameChange() { |     public void onFrameChange() { | ||||||
|         Vector3f left = getLeft(); |         TempVars vars = TempVars.get(); | ||||||
|         Vector3f direction = getDirection(); |          | ||||||
|         Vector3f up = getUp(); |         Vector3f left = getLeft(vars.vect1); | ||||||
|  |         Vector3f direction = getDirection(vars.vect2); | ||||||
|  |         Vector3f up = getUp(vars.vect3); | ||||||
| 
 | 
 | ||||||
|         float dirDotLocation = direction.dot(location); |         float dirDotLocation = direction.dot(location); | ||||||
| 
 | 
 | ||||||
| @ -1278,6 +1280,9 @@ public class Camera implements Savable, Cloneable { | |||||||
|         worldPlane[NEAR_PLANE].setConstant(dirDotLocation + frustumNear); |         worldPlane[NEAR_PLANE].setConstant(dirDotLocation + frustumNear); | ||||||
| 
 | 
 | ||||||
|         viewMatrix.fromFrame(location, direction, up, left); |         viewMatrix.fromFrame(location, direction, up, left); | ||||||
|  |          | ||||||
|  |         vars.release(); | ||||||
|  |          | ||||||
| //        viewMatrix.transposeLocal(); | //        viewMatrix.transposeLocal(); | ||||||
|         updateViewProjection(); |         updateViewProjection(); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -45,6 +45,8 @@ import java.util.Map; | |||||||
|  */ |  */ | ||||||
| public final class IntMap<T> implements Iterable<Entry<T>>, Cloneable { | public final class IntMap<T> implements Iterable<Entry<T>>, Cloneable { | ||||||
| 
 | 
 | ||||||
|  |     private final IntMapIterator iterator = new IntMapIterator(); | ||||||
|  |              | ||||||
|     private Entry[] table; |     private Entry[] table; | ||||||
|     private final float loadFactor; |     private final float loadFactor; | ||||||
|     private int size, mask, capacity, threshold; |     private int size, mask, capacity, threshold; | ||||||
| @ -198,7 +200,8 @@ public final class IntMap<T> implements Iterable<Entry<T>>, Cloneable { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Iterator<Entry<T>> iterator() { |     public Iterator<Entry<T>> iterator() { | ||||||
|         return (Iterator<Entry<T>>) new IntMapIterator(); |         iterator.beginUse(); | ||||||
|  |         return iterator; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     final class IntMapIterator implements Iterator<Entry<T>> { |     final class IntMapIterator implements Iterator<Entry<T>> { | ||||||
| @ -219,9 +222,14 @@ public final class IntMap<T> implements Iterable<Entry<T>>, Cloneable { | |||||||
|         private int el  = 0; |         private int el  = 0; | ||||||
| 
 | 
 | ||||||
|         public IntMapIterator() { |         public IntMapIterator() { | ||||||
|             cur = table[0]; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public void beginUse(){ | ||||||
|  |             cur = table[0]; | ||||||
|  |             idx = 0; | ||||||
|  |             el = 0; | ||||||
|  |         } | ||||||
|  |          | ||||||
|         public boolean hasNext() { |         public boolean hasNext() { | ||||||
|             return el < size; |             return el < size; | ||||||
|         } |         } | ||||||
| @ -248,9 +256,11 @@ public final class IntMap<T> implements Iterable<Entry<T>>, Cloneable { | |||||||
|                 // the entry was null. find another non-null entry. |                 // the entry was null. find another non-null entry. | ||||||
|                 cur = table[++idx]; |                 cur = table[++idx]; | ||||||
|             } while (cur == null); |             } while (cur == null); | ||||||
|  |              | ||||||
|             Entry e = cur; |             Entry e = cur; | ||||||
|             cur = cur.next; |             cur = cur.next; | ||||||
|             el ++; |             el ++; | ||||||
|  |              | ||||||
|             return e; |             return e; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user