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
3.0
rem..om 13 years ago
parent 538b6edd35
commit cbd1248302
  1. 20
      engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java
  2. 9
      engine/src/core/com/jme3/scene/Mesh.java
  3. 7
      engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java

@ -59,6 +59,7 @@ import com.jme3.texture.Texture.WrapAxis;
import com.jme3.util.BufferUtils; import com.jme3.util.BufferUtils;
import com.jme3.util.ListMap; import com.jme3.util.ListMap;
import com.jme3.util.NativeObjectManager; import com.jme3.util.NativeObjectManager;
import com.jme3.util.SafeArrayList;
import java.nio.*; import java.nio.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
@ -2610,10 +2611,9 @@ public class OGLESShaderRenderer implements Renderer {
updateBufferData(interleavedData); updateBufferData(interleavedData);
} }
ArrayList<VertexBuffer> buffersList = mesh.getBufferList();
for (int i = 0; i < buffersList.size(); i++){ for (VertexBuffer vb : mesh.getBufferList().getArray()){
VertexBuffer vb = buffersList.get(i);
if (vb.getBufferType() == Type.InterleavedData if (vb.getBufferType() == Type.InterleavedData
|| vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
|| vb.getBufferType() == Type.Index) { || vb.getBufferType() == Type.Index) {
@ -2642,9 +2642,7 @@ public class OGLESShaderRenderer implements Renderer {
} }
// IntMap<VertexBuffer> buffers = mesh.getBuffers(); // IntMap<VertexBuffer> buffers = mesh.getBuffers();
ArrayList<VertexBuffer> buffersList = mesh.getBufferList(); for (VertexBuffer vb : mesh.getBufferList().getArray()){
for (int i = 0; i < buffersList.size(); i++){
VertexBuffer vb = buffersList.get(i);
if (vb.getBufferType() == Type.InterleavedData if (vb.getBufferType() == Type.InterleavedData
|| vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
@ -2694,16 +2692,14 @@ public class OGLESShaderRenderer implements Renderer {
updateBufferData(interleavedData); updateBufferData(interleavedData);
} }
//IntMap<VertexBuffer> buffers = mesh.getBuffers(); //IntMap<VertexBuffer> buffers = mesh.getBuffers(); ;
ArrayList<VertexBuffer> buffersList = mesh.getBufferList();
if (mesh.getNumLodLevels() > 0) { if (mesh.getNumLodLevels() > 0) {
indices = mesh.getLodLevel(lod); indices = mesh.getLodLevel(lod);
} else { } else {
indices = mesh.getBuffer(Type.Index);// buffers.get(Type.Index.ordinal()); indices = mesh.getBuffer(Type.Index);// buffers.get(Type.Index.ordinal());
} }
for (int i = 0; i < buffersList.size(); i++){ for (VertexBuffer vb : mesh.getBufferList().getArray()){
VertexBuffer vb = buffersList.get(i);
if (vb.getBufferType() == Type.InterleavedData if (vb.getBufferType() == Type.InterleavedData
|| vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
|| vb.getBufferType() == Type.Index) { || vb.getBufferType() == Type.Index) {

@ -50,6 +50,7 @@ import com.jme3.scene.mesh.*;
import com.jme3.util.BufferUtils; import com.jme3.util.BufferUtils;
import com.jme3.util.IntMap; import com.jme3.util.IntMap;
import com.jme3.util.IntMap.Entry; import com.jme3.util.IntMap.Entry;
import com.jme3.util.SafeArrayList;
import java.io.IOException; import java.io.IOException;
import java.nio.*; import java.nio.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -164,7 +165,7 @@ public class Mesh implements Savable, Cloneable {
private CollisionData collisionTree = null; private CollisionData collisionTree = null;
private ArrayList<VertexBuffer> buffersList = new ArrayList<VertexBuffer>(5); private SafeArrayList<VertexBuffer> buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class);
private IntMap<VertexBuffer> buffers = new IntMap<VertexBuffer>(); private IntMap<VertexBuffer> buffers = new IntMap<VertexBuffer>();
private VertexBuffer[] lodLevels; private VertexBuffer[] lodLevels;
private float pointSize = 1; private float pointSize = 1;
@ -201,7 +202,7 @@ public class Mesh implements Savable, Cloneable {
clone.meshBound = meshBound.clone(); clone.meshBound = meshBound.clone();
clone.collisionTree = collisionTree != null ? collisionTree : null; clone.collisionTree = collisionTree != null ? collisionTree : null;
clone.buffers = buffers.clone(); clone.buffers = buffers.clone();
clone.buffersList = new ArrayList<VertexBuffer>(buffersList); clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class,buffersList);
clone.vertexArrayID = -1; clone.vertexArrayID = -1;
if (elementLengths != null) { if (elementLengths != null) {
clone.elementLengths = elementLengths.clone(); 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.collisionTree = null; // it will get re-generated in any case
clone.buffers = new IntMap<VertexBuffer>(); clone.buffers = new IntMap<VertexBuffer>();
clone.buffersList = new ArrayList<VertexBuffer>(); clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class);
for (Entry<VertexBuffer> ent : buffers){ for (Entry<VertexBuffer> ent : buffers){
VertexBuffer bufClone = ent.getValue().clone(); VertexBuffer bufClone = ent.getValue().clone();
clone.buffers.put(ent.getKey(), bufClone); clone.buffers.put(ent.getKey(), bufClone);
@ -1129,7 +1130,7 @@ public class Mesh implements Savable, Cloneable {
return buffers; return buffers;
} }
public ArrayList<VertexBuffer> getBufferList(){ public SafeArrayList<VertexBuffer> getBufferList(){
return buffersList; return buffersList;
} }

@ -58,8 +58,8 @@ import com.jme3.util.IntMap;
import com.jme3.util.IntMap.Entry; import com.jme3.util.IntMap.Entry;
import com.jme3.util.ListMap; import com.jme3.util.ListMap;
import com.jme3.util.NativeObjectManager; import com.jme3.util.NativeObjectManager;
import com.jme3.util.SafeArrayList;
import java.nio.*; import java.nio.*;
import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -2410,7 +2410,7 @@ public class LwjglRenderer implements Renderer {
} }
//IntMap<VertexBuffer> buffers = mesh.getBuffers(); //IntMap<VertexBuffer> buffers = mesh.getBuffers();
ArrayList<VertexBuffer> buffersList = mesh.getBufferList(); SafeArrayList<VertexBuffer> buffersList = mesh.getBufferList();
if (mesh.getNumLodLevels() > 0) { if (mesh.getNumLodLevels() > 0) {
indices = mesh.getLodLevel(lod); indices = mesh.getLodLevel(lod);
@ -2419,8 +2419,7 @@ public class LwjglRenderer implements Renderer {
} }
//for (Entry<VertexBuffer> entry : buffers) { //for (Entry<VertexBuffer> entry : buffers) {
// VertexBuffer vb = entry.getValue(); // VertexBuffer vb = entry.getValue();
for (int i = 0; i < buffersList.size(); i++){ for (VertexBuffer vb : mesh.getBufferList().getArray()){
VertexBuffer vb = buffersList.get(i);
if (vb.getBufferType() == Type.InterleavedData if (vb.getBufferType() == Type.InterleavedData
|| vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers

Loading…
Cancel
Save