From cbd1248302ad2c7b1f530bb3897dffc1526d8a3e Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Mon, 5 Dec 2011 20:27:28 +0000 Subject: [PATCH] Mesh bufferList is now a SafeArrayList instead of an ArrayList git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8869 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../renderer/android/OGLESShaderRenderer.java | 20 ++++++++----------- engine/src/core/com/jme3/scene/Mesh.java | 9 +++++---- .../jme3/renderer/lwjgl/LwjglRenderer.java | 7 +++---- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java b/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java index cf1e3856e..ac12c0a9c 100644 --- a/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java +++ b/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java @@ -59,6 +59,7 @@ import com.jme3.texture.Texture.WrapAxis; import com.jme3.util.BufferUtils; import com.jme3.util.ListMap; import com.jme3.util.NativeObjectManager; +import com.jme3.util.SafeArrayList; import java.nio.*; import java.util.ArrayList; import java.util.EnumSet; @@ -2610,10 +2611,9 @@ public class OGLESShaderRenderer implements Renderer { updateBufferData(interleavedData); } - ArrayList buffersList = mesh.getBufferList(); - for (int i = 0; i < buffersList.size(); i++){ - VertexBuffer vb = buffersList.get(i); - + + for (VertexBuffer vb : mesh.getBufferList().getArray()){ + if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getBufferType() == Type.Index) { @@ -2642,9 +2642,7 @@ public class OGLESShaderRenderer implements Renderer { } // IntMap buffers = mesh.getBuffers(); - ArrayList buffersList = mesh.getBufferList(); - for (int i = 0; i < buffersList.size(); i++){ - VertexBuffer vb = buffersList.get(i); + for (VertexBuffer vb : mesh.getBufferList().getArray()){ if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers @@ -2694,16 +2692,14 @@ public class OGLESShaderRenderer implements Renderer { updateBufferData(interleavedData); } - //IntMap buffers = mesh.getBuffers(); - ArrayList buffersList = mesh.getBufferList(); + //IntMap buffers = mesh.getBuffers(); ; if (mesh.getNumLodLevels() > 0) { indices = mesh.getLodLevel(lod); } else { indices = mesh.getBuffer(Type.Index);// buffers.get(Type.Index.ordinal()); } - for (int i = 0; i < buffersList.size(); i++){ - VertexBuffer vb = buffersList.get(i); - + for (VertexBuffer vb : mesh.getBufferList().getArray()){ + if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getBufferType() == Type.Index) { diff --git a/engine/src/core/com/jme3/scene/Mesh.java b/engine/src/core/com/jme3/scene/Mesh.java index dce7937df..d2e29493a 100644 --- a/engine/src/core/com/jme3/scene/Mesh.java +++ b/engine/src/core/com/jme3/scene/Mesh.java @@ -50,6 +50,7 @@ import com.jme3.scene.mesh.*; import com.jme3.util.BufferUtils; import com.jme3.util.IntMap; import com.jme3.util.IntMap.Entry; +import com.jme3.util.SafeArrayList; import java.io.IOException; import java.nio.*; import java.util.ArrayList; @@ -164,7 +165,7 @@ public class Mesh implements Savable, Cloneable { private CollisionData collisionTree = null; - private ArrayList buffersList = new ArrayList(5); + private SafeArrayList buffersList = new SafeArrayList(VertexBuffer.class); private IntMap buffers = new IntMap(); private VertexBuffer[] lodLevels; private float pointSize = 1; @@ -201,7 +202,7 @@ public class Mesh implements Savable, Cloneable { clone.meshBound = meshBound.clone(); clone.collisionTree = collisionTree != null ? collisionTree : null; clone.buffers = buffers.clone(); - clone.buffersList = new ArrayList(buffersList); + clone.buffersList = new SafeArrayList(VertexBuffer.class,buffersList); clone.vertexArrayID = -1; if (elementLengths != null) { clone.elementLengths = elementLengths.clone(); @@ -232,7 +233,7 @@ public class Mesh implements Savable, Cloneable { clone.collisionTree = null; // it will get re-generated in any case clone.buffers = new IntMap(); - clone.buffersList = new ArrayList(); + clone.buffersList = new SafeArrayList(VertexBuffer.class); for (Entry ent : buffers){ VertexBuffer bufClone = ent.getValue().clone(); clone.buffers.put(ent.getKey(), bufClone); @@ -1129,7 +1130,7 @@ public class Mesh implements Savable, Cloneable { return buffers; } - public ArrayList getBufferList(){ + public SafeArrayList getBufferList(){ return buffersList; } diff --git a/engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java b/engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java index c7d5f6c05..7b02b556e 100644 --- a/engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java +++ b/engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java @@ -58,8 +58,8 @@ import com.jme3.util.IntMap; import com.jme3.util.IntMap.Entry; import com.jme3.util.ListMap; import com.jme3.util.NativeObjectManager; +import com.jme3.util.SafeArrayList; import java.nio.*; -import java.util.ArrayList; import java.util.EnumSet; import java.util.List; import java.util.logging.Level; @@ -2410,7 +2410,7 @@ public class LwjglRenderer implements Renderer { } //IntMap buffers = mesh.getBuffers(); - ArrayList buffersList = mesh.getBufferList(); + SafeArrayList buffersList = mesh.getBufferList(); if (mesh.getNumLodLevels() > 0) { indices = mesh.getLodLevel(lod); @@ -2419,8 +2419,7 @@ public class LwjglRenderer implements Renderer { } //for (Entry entry : buffers) { // VertexBuffer vb = entry.getValue(); - for (int i = 0; i < buffersList.size(); i++){ - VertexBuffer vb = buffersList.get(i); + for (VertexBuffer vb : mesh.getBufferList().getArray()){ if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers