diff --git a/jme3-core/src/main/java/com/jme3/renderer/queue/GeometryList.java b/jme3-core/src/main/java/com/jme3/renderer/queue/GeometryList.java index 692674291..5529ac84e 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/queue/GeometryList.java +++ b/jme3-core/src/main/java/com/jme3/renderer/queue/GeometryList.java @@ -31,6 +31,9 @@ */ package com.jme3.renderer.queue; +import java.util.Iterator; +import java.util.NoSuchElementException; + import com.jme3.renderer.Camera; import com.jme3.scene.Geometry; import com.jme3.util.ListSort; @@ -43,7 +46,7 @@ import com.jme3.util.ListSort; * @author Three Rings - better sorting alg. * @author Kirill Vainer */ -public class GeometryList { +public class GeometryList implements Iterable{ private static final int DEFAULT_SIZE = 32; @@ -145,4 +148,28 @@ public class GeometryList { listSort.sort(geometries,comparator); } } + + public Iterator iterator() { + return new Iterator() { + + int index = 0; + + public boolean hasNext() { + return index < size(); + } + + + public Geometry next() { + if ( index >= size() ) { + throw new NoSuchElementException("Geometry list has only " + size() + " elements"); + } + return get(index++); + } + + public void remove() { + throw new UnsupportedOperationException("Geometry list doesn't support iterator removal"); + } + + }; + } } \ No newline at end of file