[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef3d-commits] r419 - in branches/experimental_direct_2D_rendering: org.eclipse.draw3d/src/java/org/eclipse/draw3d org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/primitive org.eclipse.draw3d/src/java/org/eclipse/draw3d/util org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics

Author: kduske
Date: 2010-01-11 06:12:53 -0500 (Mon, 11 Jan 2010)
New Revision: 419

Modified:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/AbstractPosition3D.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math3DCache.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/ParaxialBoundingBoxImpl.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglExecutableQuads.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/OptimizingGraphics.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveSet.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/primitive/AbstractVertexPrimitive.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/Draw3DCache.java
Log:


Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -443,6 +443,61 @@
 
 	private ExecutableGraphics2D m_executable;
 
+	private static class ExecutableRenderFragment implements RenderFragment {
+
+		private IFigure3D m_figure;
+
+		public ExecutableRenderFragment(IFigure3D i_figure) {
+
+			m_figure = i_figure;
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see org.eclipse.draw3d.RenderFragment#getDistanceMeasure(org.eclipse.draw3d.RenderContext)
+		 */
+		public float getDistanceMeasure(RenderContext i_renderContext) {
+
+			Vector3f v = Draw3DCache.getVector3f();
+			try {
+				getCenter3D(m_figure, v);
+				return i_renderContext.getScene().getCamera().getDistance(v);
+			} finally {
+				Draw3DCache.returnVector3f(v);
+			}
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see org.eclipse.draw3d.RenderFragment#getRenderType()
+		 */
+		public RenderType getRenderType() {
+
+			return RenderType.getRenderType(m_figure.getAlpha(), false);
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see org.eclipse.draw3d.RenderFragment#render(org.eclipse.draw3d.RenderContext)
+		 */
+		public void render(RenderContext i_renderContext) {
+
+			m_executable.execute(i_renderContext.getGraphics3D());
+		}
+
+		private ExecutableGraphics2D m_executable;
+
+		public void setExecutable(ExecutableGraphics2D i_executable) {
+
+			m_executable = i_executable;
+		}
+	}
+
+	private ExecutableRenderFragment m_fragment;
+
 	/**
 	 * Paints the given 2D figures. This method was extracted from
 	 * {@link #paintChildren(Graphics)} to make that method easier to read and
@@ -496,37 +551,17 @@
 						m_executable = surface.deactivate(g3d);
 						m_executable.initialize(g3d);
 						log.info(StopWatch.stop());
+
+						if (m_fragment == null)
+							m_fragment = new ExecutableRenderFragment(figure);
+
+						m_fragment.setExecutable(m_executable);
 					}
 				}
 
-				if (m_executable != null)
-					renderContext.addRenderFragment(new RenderFragment() {
+				if (m_fragment != null)
+					renderContext.addRenderFragment(m_fragment);
 
-						public float getDistanceMeasure(
-							RenderContext i_renderContext) {
-
-							Vector3f v = Draw3DCache.getVector3f();
-							try {
-								getCenter3D(figure, v);
-								return renderContext.getScene().getCamera().getDistance(
-									v);
-							} finally {
-								Draw3DCache.returnVector3f(v);
-							}
-						}
-
-						public RenderType getRenderType() {
-
-							return RenderType.getRenderType(figure.getAlpha(),
-								false);
-						}
-
-						public void render(RenderContext i_renderContext) {
-
-							m_executable.execute(g3d);
-						}
-
-					});
 			} else {
 				Graphics graphics = i_graphics;
 				graphics.setFont(i_graphics.getFont());

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/OptimizingGraphics.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/OptimizingGraphics.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/OptimizingGraphics.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -214,7 +214,7 @@
 	public void drawRectangle(int i_x, int i_y, int i_width, int i_height) {
 
 		addPrimitive(QuadPrimitive.createOutlineQuad(getState(), i_x, i_y,
-			i_width + 1, i_height + 1));
+			i_width, i_height));
 	}
 
 	/**

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveSet.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveSet.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveSet.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -14,6 +14,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import org.eclipse.draw3d.geometry.IMatrix4f;
 import org.eclipse.draw3d.graphics.optimizer.classification.PrimitiveClass;
 import org.eclipse.draw3d.graphics.optimizer.primitive.Primitive;
 import org.eclipse.draw3d.graphics.optimizer.primitive.VertexPrimitive;

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/primitive/AbstractVertexPrimitive.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/primitive/AbstractVertexPrimitive.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/primitive/AbstractVertexPrimitive.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -30,6 +30,8 @@
 public abstract class AbstractVertexPrimitive extends AbstractPrimitive
 		implements VertexPrimitive {
 
+
+
 	private static float[] getVertices(PointList i_points) {
 
 		Point p = Draw3DCache.getPoint();

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/Draw3DCache.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/Draw3DCache.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/Draw3DCache.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -21,6 +21,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Queue;
+import java.util.logging.Logger;
 
 import org.eclipse.draw2d.geometry.Dimension;
 import org.eclipse.draw2d.geometry.Point;
@@ -38,107 +39,174 @@
  */
 public class Draw3DCache extends Math3DCache {
 
-	/**
-	 * Holds a buffer and information about its capacity.
-	 * 
-	 * @author Kristian Duske
-	 * @version $Revision$
-	 * @since 05.08.2009
-	 */
-	private static class BufferHolder {
+	private static final Logger log =
+		Logger.getLogger(Draw3DCache.class.getName());
 
-		private Buffer m_buffer;
+	private static final Comparator<Object> m_bufferComparator =
+		new Comparator<Object>() {
+			public int compare(Object i_o1, Object i_o2) {
 
-		private int m_capacity;
+				int i1, i2;
 
-		public BufferHolder(Buffer i_buffer) {
+				if (i_o1 instanceof Integer)
+					i1 = (Integer) i_o1;
+				else
+					i1 = ((Buffer) i_o1).capacity();
 
-			m_buffer = i_buffer;
-			m_capacity = m_buffer.capacity();
-		}
+				if (i_o2 instanceof Integer)
+					i2 = (Integer) i_o2;
+				else
+					i2 = ((Buffer) i_o2).capacity();
 
-		public BufferHolder(int i_capacity) {
+				if (i1 < i2)
+					return -1;
 
-			m_capacity = i_capacity;
+				return 0;
+			}
+		};
+
+	private static final List<ByteBuffer> m_byteBuffer =
+		new ArrayList<ByteBuffer>();
+
+	private static int m_byteBufferCounter;
+
+	private static final Queue<Dimension> m_dimension =
+		new LinkedList<Dimension>();
+
+	private static int m_dimensionCounter;
+
+	private static final List<DoubleBuffer> m_doubleBuffer =
+		new ArrayList<DoubleBuffer>();
+
+	private static int m_doubleBufferCounter;
+
+	private static final List<FloatBuffer> m_floatBuffer =
+		new ArrayList<FloatBuffer>();
+
+	private static int m_floatBufferCounter;
+
+	private static final List<IntBuffer> m_intBuffer =
+		new ArrayList<IntBuffer>();
+
+	private static int m_intBufferCounter;
+
+	private static final Queue<Point> m_point = new LinkedList<Point>();
+
+	private static int m_pointCounter;
+
+	private static Queue<Rectangle> m_rectangle = new LinkedList<Rectangle>();
+
+	private static int m_rectangleCounter;
+
+	private static ByteBuffer createByteBuffer(int i_capacity) {
+
+		if (m_count) {
+			m_byteBufferCounter++;
+			if (m_byteBufferCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " byte buffers, are you properly returning them?");
 		}
 
-		public Buffer getBuffer() {
+		return BufferUtils.createByteBuffer(i_capacity);
+	}
 
-			return m_buffer;
+	private static Dimension createDimension() {
+
+		if (m_count) {
+			m_dimensionCounter++;
+			if (m_dimensionCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " dimensions, are you properly returning them?");
 		}
 
-		public int getCapacity() {
+		return new Dimension();
+	}
 
-			return m_capacity;
+	private static DoubleBuffer createDoubleBuffer(int i_capacity) {
+
+		if (m_count) {
+			m_doubleBufferCounter++;
+			if (m_doubleBufferCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " double buffers, are you properly returning them?");
 		}
 
-		/**
-		 * {@inheritDoc}
-		 * 
-		 * @see java.lang.Object#toString()
-		 */
-		@Override
-		public String toString() {
+		return BufferUtils.createDoubleBuffer(i_capacity);
+	}
 
-			return "BufferHolder [capacity=" + m_capacity + "]";
+	private static FloatBuffer createFloatBuffer(int i_capacity) {
+
+		if (m_count) {
+			m_floatBufferCounter++;
+			if (m_floatBufferCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " float buffers, are you properly returning them?");
 		}
+
+		return BufferUtils.createFloatBuffer(i_capacity);
 	}
 
-	private static final Comparator<BufferHolder> m_bufferComparator =
-		new Comparator<BufferHolder>() {
-			public int compare(BufferHolder i_o1, BufferHolder i_o2) {
-				if (i_o1.getCapacity() < i_o2.getCapacity())
-					return -1;
-				return 0;
-			}
-		};
+	private static IntBuffer createIntBuffer(int i_capacity) {
 
-	private static final List<BufferHolder> m_byteBuffer =
-		new ArrayList<BufferHolder>();
+		if (m_count) {
+			m_intBufferCounter++;
+			if (m_intBufferCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " int buffers, are you properly returning them?");
+		}
 
-	private static final Queue<Dimension> m_dimension =
-		new LinkedList<Dimension>();
+		return BufferUtils.createIntBuffer(i_capacity);
+	}
 
-	private static final List<BufferHolder> m_doubleBuffer =
-		new ArrayList<BufferHolder>();
+	private static Point createPoint() {
 
-	private static final List<BufferHolder> m_floatBuffer =
-		new ArrayList<BufferHolder>();
+		if (m_count) {
+			m_pointCounter++;
+			if (m_pointCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " points, are you properly returning them?");
+		}
 
-	private static final List<BufferHolder> m_intBuffer =
-		new ArrayList<BufferHolder>();
+		return new Point();
+	}
 
-	private static final Queue<Point> m_point = new LinkedList<Point>();
+	private static Rectangle createRectangle() {
 
-	private static Queue<Rectangle> m_rectangle = new LinkedList<Rectangle>();
+		if (m_count) {
+			m_rectangleCounter++;
+			if (m_rectangleCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " rectangles, are you properly returning them?");
+		}
 
-	private static Buffer doGetBuffer(List<BufferHolder> i_buffers,
-		BufferHolder i_holder) {
+		return new Rectangle();
+	}
 
+	private static <T extends Buffer> T doGetBuffer(List<T> i_buffers,
+		int i_capacity) {
+
 		int index =
-			Collections.binarySearch(i_buffers, i_holder, m_bufferComparator);
+			Collections.binarySearch(i_buffers, i_capacity, m_bufferComparator);
 
 		if (index >= 0) {
-			BufferHolder holder = i_buffers.remove(index);
-			Buffer buffer = holder.getBuffer();
-			buffer.limit(i_holder.getCapacity());
+			T buffer = i_buffers.remove(index);
+			buffer.limit(i_capacity);
 			return buffer;
 		}
 
 		return null;
 	}
 
-	private static void doReturnBuffer(List<BufferHolder> i_buffers,
-		Buffer i_buffer) {
+	private static <T extends Buffer> void doReturnBuffer(List<T> i_buffers,
+		T i_buffer) {
 
-		BufferHolder holder = new BufferHolder(i_buffer);
 		int index =
-			Collections.binarySearch(i_buffers, holder, m_bufferComparator);
+			Collections.binarySearch(i_buffers, i_buffer, m_bufferComparator);
 
 		if (index < 0)
 			index = -index - 1;
 
-		i_buffers.add(index, holder);
+		i_buffers.add(index, i_buffer);
 	}
 
 	/**
@@ -150,17 +218,16 @@
 	 */
 	public static ByteBuffer getByteBuffer(int i_capacity) {
 
-		BufferHolder holder = new BufferHolder(i_capacity);
 		ByteBuffer buffer;
 		if (m_synchronized)
 			synchronized (m_byteBuffer) {
-				buffer = (ByteBuffer) doGetBuffer(m_byteBuffer, holder);
+				buffer = doGetBuffer(m_byteBuffer, i_capacity);
 			}
 		else
-			buffer = (ByteBuffer) doGetBuffer(m_byteBuffer, holder);
+			buffer = doGetBuffer(m_byteBuffer, i_capacity);
 
 		if (buffer == null)
-			buffer = BufferUtils.createByteBuffer(i_capacity);
+			buffer = createByteBuffer(i_capacity);
 		else
 			buffer.limit(i_capacity);
 
@@ -177,13 +244,13 @@
 		if (m_synchronized) {
 			synchronized (m_dimension) {
 				if (m_dimension.isEmpty())
-					return new Dimension();
+					return createDimension();
 				else
 					return m_dimension.remove();
 			}
 		} else {
 			if (m_dimension.isEmpty())
-				return new Dimension();
+				return createDimension();
 			else
 				return m_dimension.remove();
 		}
@@ -198,17 +265,16 @@
 	 */
 	public static DoubleBuffer getDoubleBuffer(int i_capacity) {
 
-		BufferHolder holder = new BufferHolder(i_capacity);
 		DoubleBuffer buffer;
 		if (m_synchronized)
 			synchronized (m_doubleBuffer) {
-				buffer = (DoubleBuffer) doGetBuffer(m_doubleBuffer, holder);
+				buffer = doGetBuffer(m_doubleBuffer, i_capacity);
 			}
 		else
-			buffer = (DoubleBuffer) doGetBuffer(m_doubleBuffer, holder);
+			buffer = doGetBuffer(m_doubleBuffer, i_capacity);
 
 		if (buffer == null)
-			buffer = BufferUtils.createDoubleBuffer(i_capacity);
+			buffer = createDoubleBuffer(i_capacity);
 		else
 			buffer.limit(i_capacity);
 
@@ -224,17 +290,16 @@
 	 */
 	public static FloatBuffer getFloatBuffer(int i_capacity) {
 
-		BufferHolder holder = new BufferHolder(i_capacity);
 		FloatBuffer buffer;
 		if (m_synchronized)
 			synchronized (m_floatBuffer) {
-				buffer = (FloatBuffer) doGetBuffer(m_floatBuffer, holder);
+				buffer = doGetBuffer(m_floatBuffer, i_capacity);
 			}
 		else
-			buffer = (FloatBuffer) doGetBuffer(m_floatBuffer, holder);
+			buffer = doGetBuffer(m_floatBuffer, i_capacity);
 
 		if (buffer == null)
-			buffer = BufferUtils.createFloatBuffer(i_capacity);
+			buffer = createFloatBuffer(i_capacity);
 		else
 			buffer.limit(i_capacity);
 
@@ -250,17 +315,16 @@
 	 */
 	public static IntBuffer getIntBuffer(int i_capacity) {
 
-		BufferHolder holder = new BufferHolder(i_capacity);
 		IntBuffer buffer;
 		if (m_synchronized)
 			synchronized (m_intBuffer) {
-				buffer = (IntBuffer) doGetBuffer(m_intBuffer, holder);
+				buffer = doGetBuffer(m_intBuffer, i_capacity);
 			}
 		else
-			buffer = (IntBuffer) doGetBuffer(m_intBuffer, holder);
+			buffer = doGetBuffer(m_intBuffer, i_capacity);
 
 		if (buffer == null)
-			buffer = BufferUtils.createIntBuffer(i_capacity);
+			buffer = createIntBuffer(i_capacity);
 		else
 			buffer.limit(i_capacity);
 
@@ -277,13 +341,13 @@
 		if (m_synchronized) {
 			synchronized (m_point) {
 				if (m_point.isEmpty())
-					return new Point();
+					return createPoint();
 				else
 					return m_point.remove();
 			}
 		} else {
 			if (m_point.isEmpty())
-				return new Point();
+				return createPoint();
 			else
 				return m_point.remove();
 		}
@@ -299,13 +363,13 @@
 		if (m_synchronized) {
 			synchronized (m_rectangle) {
 				if (m_rectangle.isEmpty())
-					return new Rectangle();
+					return createRectangle();
 				else
 					return m_rectangle.remove();
 			}
 		} else {
 			if (m_rectangle.isEmpty())
-				return new Rectangle();
+				return createRectangle();
 			else
 				return m_rectangle.remove();
 		}
@@ -330,6 +394,10 @@
 				if (b != null)
 					doReturnBuffer(m_byteBuffer, b);
 		}
+
+		if (m_count && m_byteBuffer.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " byte buffers");
 	}
 
 	/**
@@ -350,6 +418,10 @@
 			for (Dimension d : i_ds)
 				if (d != null)
 					m_dimension.offer(d);
+
+		if (m_count && m_dimension.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " dimensions");
 	}
 
 	/**
@@ -371,6 +443,11 @@
 				if (b != null)
 					doReturnBuffer(m_doubleBuffer, b);
 		}
+
+		if (m_count && m_doubleBuffer.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " double buffers");
+
 	}
 
 	/**
@@ -392,6 +469,10 @@
 				if (b != null)
 					doReturnBuffer(m_floatBuffer, b);
 		}
+
+		if (m_count && m_floatBuffer.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " float buffers");
 	}
 
 	/**
@@ -413,6 +494,10 @@
 				if (b != null)
 					doReturnBuffer(m_intBuffer, b);
 		}
+
+		if (m_count && m_intBuffer.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " int buffers");
 	}
 
 	/**
@@ -433,6 +518,10 @@
 			for (Point p : i_ps)
 				if (p != null)
 					m_point.offer(p);
+
+		if (m_count && m_point.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " points");
 	}
 
 	/**
@@ -453,5 +542,9 @@
 			for (Rectangle r : i_rs)
 				if (r != null)
 					m_rectangle.offer(r);
+
+		if (m_count && m_rectangle.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " rectangles");
 	}
 }

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/AbstractPosition3D.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/AbstractPosition3D.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/AbstractPosition3D.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -129,8 +129,6 @@
 		} else {
 			Vector3f location = Math3DCache.getVector3f();
 			Vector3f rotation = Math3DCache.getVector3f();
-			Vector3f halfSize = Math3DCache.getVector3f();
-			// Vector3f center = Math3DCache.getVector3f();
 			try {
 				Math3D.transform(IVector3f.NULLVEC3f,
 					getRotationLocationMatrix(), location);
@@ -149,8 +147,7 @@
 
 				return result;
 			} finally {
-				// Math3DCache
-				// .returnVector3f(location, rotation, halfSize, center);
+				Math3DCache.returnVector3f(location, rotation);
 			}
 		}
 
@@ -408,8 +405,7 @@
 			if (parent != null) {
 				Math3D.translate(parent.getRotationLocationMatrix(),
 					getLocation3D(), m_rotationLocationMatrix);
-				m_absoluteRotationMatrix
-					.set(parent.getAbsoluteRotationMatrix());
+				m_absoluteRotationMatrix.set(parent.getAbsoluteRotationMatrix());
 			} else {
 				Math3D.translate(IMatrix4f.IDENTITY, getLocation3D(),
 					m_rotationLocationMatrix);

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math3DCache.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math3DCache.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math3DCache.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -12,6 +12,7 @@
 
 import java.util.LinkedList;
 import java.util.Queue;
+import java.util.logging.Logger;
 
 /**
  * Caches objects that are often used as temporary variables during
@@ -23,24 +24,56 @@
  */
 public class Math3DCache {
 
+	private static final Logger log =
+		Logger.getLogger(Math3DCache.class.getName());
+
 	private static final Queue<BoundingBox> m_boundingBox =
 		new LinkedList<BoundingBox>();
 
+	private static int m_boundingBoxCounter = 0;
+
+	/**
+	 * Count instantiations and warn when they reach a threshold.
+	 */
+	protected static boolean m_count = true;
+
+	/**
+	 * If the number of instantiations for a specific class exceeds this number,
+	 * warnings are generated.
+	 */
+	protected static int m_counterThreshold = 100;
+
+	/**
+	 * If cache size for a specific class exceeds this number, warnings are
+	 * generated.
+	 */
+	protected static int m_instanceThreshold = 100;
+
 	private static final Queue<Matrix2f> m_matrix2f =
 		new LinkedList<Matrix2f>();
 
+	private static int m_matrix2fCounter = 0;
+
 	private static final Queue<Matrix3f> m_matrix3f =
 		new LinkedList<Matrix3f>();
 
+	private static int m_matrix3fCounter = 0;
+
 	private static final Queue<Matrix4f> m_matrix4f =
 		new LinkedList<Matrix4f>();
 
+	private static int m_matrix4fCounter = 0;
+
 	private static final Queue<ParaxialBoundingBox> m_paraxialBoundingBox =
 		new LinkedList<ParaxialBoundingBox>();
 
+	private static int m_paraxialBoundingBoxCounter = 0;
+
 	private static final Queue<Position3D> m_position3D =
 		new LinkedList<Position3D>();
 
+	private static int m_position3DCounter = 0;
+
 	/**
 	 * Synchronize access to the cache queues.
 	 */
@@ -49,12 +82,127 @@
 	private static final Queue<Vector2f> m_vector2f =
 		new LinkedList<Vector2f>();
 
+	private static int m_vector2fCounter = 0;
+
 	private static final Queue<Vector3f> m_vector3f =
 		new LinkedList<Vector3f>();
 
+	private static int m_vector3fCounter = 0;
+
 	private static final Queue<Vector4f> m_vector4f =
 		new LinkedList<Vector4f>();
 
+	private static int m_vector4fCounter = 0;
+
+	private static BoundingBox createBoundingBox() {
+
+		if (m_count) {
+			m_boundingBoxCounter++;
+			if (m_boundingBoxCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " bounding boxes, are you properly returning them?");
+		}
+
+		return new BoundingBoxImpl();
+	}
+
+	private static Matrix2fImpl createMatrix2f() {
+
+		if (m_count) {
+			m_matrix2fCounter++;
+			if (m_matrix2fCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " 2f matrices, are you properly returning them?");
+		}
+
+		return new Matrix2fImpl();
+	}
+
+	private static Matrix3fImpl createMatrix3f() {
+
+		if (m_count) {
+			m_matrix3fCounter++;
+			if (m_matrix3fCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " 3f matrices, are you properly returning them?");
+		}
+
+		return new Matrix3fImpl();
+	}
+
+	private static Matrix4fImpl createMatrix4f() {
+
+		if (m_count) {
+			m_matrix4fCounter++;
+			if (m_matrix4fCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " 4f matrices, are you properly returning them?");
+		}
+
+		return new Matrix4fImpl();
+	}
+
+	private static ParaxialBoundingBoxImpl createParaxialBoundingBox() {
+
+		if (m_count) {
+			m_paraxialBoundingBoxCounter++;
+			if (m_paraxialBoundingBoxCounter > m_counterThreshold)
+				log.warning("created more than "
+					+ m_counterThreshold
+					+ " paraxial bounding boxes, are you properly returning them?");
+		}
+
+		return new ParaxialBoundingBoxImpl();
+	}
+
+	private static Position3D createPosition3D() {
+
+		if (m_count) {
+			m_position3DCounter++;
+			if (m_position3DCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " 3D positions, are you properly returning them?");
+		}
+
+		return Position3DUtil.createAbsolutePosition();
+	}
+
+	private static Vector2fImpl createVector2f() {
+
+		if (m_count) {
+			m_vector2fCounter++;
+			if (m_vector2fCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " 2f vectors, are you properly returning them?");
+		}
+
+		return new Vector2fImpl();
+	}
+
+	private static Vector3fImpl createVector3f() {
+
+		if (m_count) {
+			m_vector3fCounter++;
+			if (m_vector3fCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " 3f vectors, are you properly returning them?");
+		}
+
+		return new Vector3fImpl();
+	}
+
+	private static Vector4fImpl createVector4f() {
+
+		if (m_count) {
+			m_vector4fCounter++;
+			if (m_vector4fCounter > m_counterThreshold)
+				log.warning("created more than " + m_counterThreshold
+					+ " 4f vectors, are you properly returning them?");
+		}
+
+		return new Vector4fImpl();
+	}
+
 	/**
 	 * Returns a cached {@link BoundingBox}.
 	 * 
@@ -65,13 +213,13 @@
 		if (m_synchronized) {
 			synchronized (m_boundingBox) {
 				if (m_boundingBox.isEmpty())
-					return new BoundingBoxImpl();
+					return createBoundingBox();
 				else
 					return m_boundingBox.remove();
 			}
 		} else {
 			if (m_boundingBox.isEmpty())
-				return new BoundingBoxImpl();
+				return createBoundingBox();
 			else
 				return m_boundingBox.remove();
 		}
@@ -87,13 +235,13 @@
 		if (m_synchronized) {
 			synchronized (m_matrix2f) {
 				if (m_matrix2f.isEmpty())
-					return new Matrix2fImpl();
+					return createMatrix2f();
 				else
 					return m_matrix2f.remove();
 			}
 		} else {
 			if (m_matrix2f.isEmpty())
-				return new Matrix2fImpl();
+				return createMatrix2f();
 			else
 				return m_matrix2f.remove();
 		}
@@ -109,13 +257,13 @@
 		if (m_synchronized) {
 			synchronized (m_matrix3f) {
 				if (m_matrix3f.isEmpty())
-					return new Matrix3fImpl();
+					return createMatrix3f();
 				else
 					return m_matrix3f.remove();
 			}
 		} else {
 			if (m_matrix3f.isEmpty())
-				return new Matrix3fImpl();
+				return createMatrix3f();
 			else
 				return m_matrix3f.remove();
 		}
@@ -131,13 +279,13 @@
 		if (m_synchronized) {
 			synchronized (m_matrix4f) {
 				if (m_matrix4f.isEmpty())
-					return new Matrix4fImpl();
+					return createMatrix4f();
 				else
 					return m_matrix4f.remove();
 			}
 		} else {
 			if (m_matrix4f.isEmpty())
-				return new Matrix4fImpl();
+				return createMatrix4f();
 			else
 				return m_matrix4f.remove();
 		}
@@ -153,13 +301,13 @@
 		if (m_synchronized) {
 			synchronized (m_paraxialBoundingBox) {
 				if (m_paraxialBoundingBox.isEmpty())
-					return new ParaxialBoundingBoxImpl();
+					return createParaxialBoundingBox();
 				else
 					return m_paraxialBoundingBox.remove();
 			}
 		} else {
 			if (m_paraxialBoundingBox.isEmpty())
-				return new ParaxialBoundingBoxImpl();
+				return createParaxialBoundingBox();
 			else
 				return m_paraxialBoundingBox.remove();
 		}
@@ -175,13 +323,13 @@
 		if (m_synchronized) {
 			synchronized (m_position3D) {
 				if (m_position3D.isEmpty())
-					return Position3DUtil.createAbsolutePosition();
+					return createPosition3D();
 				else
 					return m_position3D.remove();
 			}
 		} else {
 			if (m_position3D.isEmpty())
-				return Position3DUtil.createAbsolutePosition();
+				return createPosition3D();
 			else
 				return m_position3D.remove();
 		}
@@ -197,13 +345,13 @@
 		if (m_synchronized) {
 			synchronized (m_vector2f) {
 				if (m_vector2f.isEmpty())
-					return new Vector2fImpl();
+					return createVector2f();
 				else
 					return m_vector2f.remove();
 			}
 		} else {
 			if (m_vector2f.isEmpty())
-				return new Vector2fImpl();
+				return createVector2f();
 			else
 				return m_vector2f.remove();
 		}
@@ -219,13 +367,13 @@
 		if (m_synchronized) {
 			synchronized (m_vector3f) {
 				if (m_vector3f.isEmpty())
-					return new Vector3fImpl();
+					return createVector3f();
 				else
 					return m_vector3f.remove();
 			}
 		} else {
 			if (m_vector3f.isEmpty())
-				return new Vector3fImpl();
+				return createVector3f();
 			else
 				return m_vector3f.remove();
 		}
@@ -241,13 +389,13 @@
 		if (m_synchronized) {
 			synchronized (m_vector4f) {
 				if (m_vector4f.isEmpty())
-					return new Vector4fImpl();
+					return createVector4f();
 				else
 					return m_vector4f.remove();
 			}
 		} else {
 			if (m_vector4f.isEmpty())
-				return new Vector4fImpl();
+				return createVector4f();
 			else
 				return m_vector4f.remove();
 		}
@@ -271,6 +419,10 @@
 			for (BoundingBox b : i_bs)
 				if (b != null)
 					m_boundingBox.offer(b);
+
+		if (m_count && m_boundingBox.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " bounding boxes");
 	}
 
 	/**
@@ -291,6 +443,11 @@
 			for (Matrix2f m : i_ms)
 				if (m != null)
 					m_matrix2f.offer(m);
+
+		if (m_count && m_matrix2f.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " 2f matrices");
+
 	}
 
 	/**
@@ -311,6 +468,11 @@
 			for (Matrix3f m : i_ms)
 				if (m != null)
 					m_matrix3f.offer(m);
+
+		if (m_count && m_matrix3f.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " 3f matrices");
+
 	}
 
 	/**
@@ -331,6 +493,10 @@
 			for (Matrix4f m : i_ms)
 				if (m != null)
 					m_matrix4f.offer(m);
+
+		if (m_count && m_matrix4f.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " 4f matrices");
 	}
 
 	/**
@@ -351,6 +517,10 @@
 			for (ParaxialBoundingBox p : i_ps)
 				if (p != null)
 					m_paraxialBoundingBox.offer(p);
+
+		if (m_count && m_paraxialBoundingBox.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " paraxial bounding boxes");
 	}
 
 	/**
@@ -371,6 +541,10 @@
 			for (Position3D p : i_ps)
 				if (p != null)
 					m_position3D.offer(p);
+
+		if (m_count && m_position3D.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " 3D positions");
 	}
 
 	/**
@@ -391,6 +565,10 @@
 			for (Vector2f v : i_vs)
 				if (v != null)
 					m_vector2f.offer(v);
+
+		if (m_count && m_vector2f.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " 2f vectors");
 	}
 
 	/**
@@ -411,6 +589,10 @@
 			for (Vector3f v : i_vs)
 				if (v != null)
 					m_vector3f.offer(v);
+
+		if (m_count && m_vector3f.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " 3f vectors");
 	}
 
 	/**
@@ -431,5 +613,9 @@
 			for (Vector4f v : i_vs)
 				if (v != null)
 					m_vector4f.offer(v);
+
+		if (m_count && m_vector4f.size() > m_instanceThreshold)
+			log.warning("cache contains more than " + m_instanceThreshold
+				+ " 4f vectors");
 	}
 }

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/ParaxialBoundingBoxImpl.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/ParaxialBoundingBoxImpl.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/ParaxialBoundingBoxImpl.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -326,7 +326,8 @@
 
 			return (!(myPos.equals(m_position) && myOldEnd.equals(myEnd)));
 		} finally {
-			Math3DCache.returnVector3f(myPos, theirPos, myEnd, theirEnd);
+			Math3DCache.returnVector3f(myPos, myEnd, myOldEnd, theirPos,
+				theirEnd);
 		}
 	}
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -83,6 +83,11 @@
 		Logger.getLogger(Graphics3DLwjgl.class.getName());
 
 	/**
+	 * Translation offset for 2D rendering of non-polygon shapes.
+	 */
+	public static final float RASTER_OFFSET = 0.49f;
+
+	/**
 	 * Descriptor of this instance.
 	 */
 	protected Graphics3DDescriptor descriptor;

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglExecutableQuads.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglExecutableQuads.java	2010-01-08 10:14:28 UTC (rev 418)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglExecutableQuads.java	2010-01-11 11:12:53 UTC (rev 419)
@@ -15,6 +15,7 @@
 import org.eclipse.draw3d.graphics.optimizer.primitive.OutlineRenderRule;
 import org.eclipse.draw3d.graphics.optimizer.primitive.SolidRenderRule;
 import org.eclipse.draw3d.graphics3d.Graphics3D;
+import org.eclipse.draw3d.graphics3d.lwjgl.Graphics3DLwjgl;
 import org.eclipse.draw3d.util.ColorConverter;
 import org.lwjgl.opengl.GL11;
 
@@ -68,8 +69,11 @@
 
 		if (m_solid)
 			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
-		else
+		else {
+			GL11.glTranslatef(Graphics3DLwjgl.RASTER_OFFSET,
+				Graphics3DLwjgl.RASTER_OFFSET, 0);
 			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+		}
 
 		GL11.glDrawArrays(GL11.GL_QUADS, 0, m_vertexCount);
 	}