Przeglądaj źródła

- revert ByteBuffer changes for native bullet objects (not asset data!)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7847 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 14 lat temu
rodzic
commit
7cc3592f0f

+ 2 - 3
engine/src/bullet/com/jme3/bullet/collision/shapes/GImpactCollisionShape.java

@@ -39,7 +39,6 @@ import com.jme3.export.InputCapsule;
 import com.jme3.export.OutputCapsule;
 import com.jme3.export.OutputCapsule;
 import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.mesh.IndexBuffer;
 import com.jme3.scene.mesh.IndexBuffer;
-import com.jme3.util.BufferUtils;
 import java.io.IOException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.ByteOrder;
@@ -71,8 +70,8 @@ public class GImpactCollisionShape extends CollisionShape {
     }
     }
 
 
     private void createCollisionMesh(Mesh mesh) {
     private void createCollisionMesh(Mesh mesh) {
-        triangleIndexBase = BufferUtils.createByteBuffer(mesh.getTriangleCount() * 3 * 4);
-        vertexBase = BufferUtils.createByteBuffer(mesh.getVertexCount() * 3 * 4); 
+        triangleIndexBase = ByteBuffer.allocateDirect(mesh.getTriangleCount() * 3 * 4).order(ByteOrder.nativeOrder());
+        vertexBase = ByteBuffer.allocateDirect(mesh.getVertexCount() * 3 * 4).order(ByteOrder.nativeOrder());
 //        triangleIndexBase = ByteBuffer.allocate(mesh.getTriangleCount() * 3 * 4);
 //        triangleIndexBase = ByteBuffer.allocate(mesh.getTriangleCount() * 3 * 4);
 //        vertexBase = ByteBuffer.allocate(mesh.getVertexCount() * 3 * 4);
 //        vertexBase = ByteBuffer.allocate(mesh.getVertexCount() * 3 * 4);
         numVertices = mesh.getVertexCount();
         numVertices = mesh.getVertexCount();

+ 1 - 2
engine/src/bullet/com/jme3/bullet/collision/shapes/HeightfieldCollisionShape.java

@@ -11,7 +11,6 @@ import com.jme3.export.OutputCapsule;
 import com.jme3.math.FastMath;
 import com.jme3.math.FastMath;
 import com.jme3.math.Vector3f;
 import com.jme3.math.Vector3f;
 import com.jme3.scene.Mesh;
 import com.jme3.scene.Mesh;
-import com.jme3.util.BufferUtils;
 import java.io.IOException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.ByteOrder;
@@ -95,7 +94,7 @@ public class HeightfieldCollisionShape extends CollisionShape {
     }
     }
 
 
     protected void createShape() {
     protected void createShape() {
-        bbuf = BufferUtils.createByteBuffer(heightfieldData.length * 4); 
+        bbuf = ByteBuffer.allocateDirect(heightfieldData.length * 4).order(ByteOrder.nativeOrder());
 //        fbuf = bbuf.asFloatBuffer();//FloatBuffer.wrap(heightfieldData);
 //        fbuf = bbuf.asFloatBuffer();//FloatBuffer.wrap(heightfieldData);
 //        fbuf.rewind();
 //        fbuf.rewind();
 //        fbuf.put(heightfieldData);
 //        fbuf.put(heightfieldData);

+ 1 - 2
engine/src/bullet/com/jme3/bullet/collision/shapes/HullCollisionShape.java

@@ -7,7 +7,6 @@ import com.jme3.export.JmeImporter;
 import com.jme3.export.OutputCapsule;
 import com.jme3.export.OutputCapsule;
 import com.jme3.scene.Mesh;
 import com.jme3.scene.Mesh;
 import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.VertexBuffer.Type;
-import com.jme3.util.BufferUtils;
 import java.io.IOException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.ByteOrder;
@@ -67,7 +66,7 @@ public class HullCollisionShape extends CollisionShape {
 //        objectId = new ConvexHullShape(pointList);
 //        objectId = new ConvexHullShape(pointList);
 //        objectId.setLocalScaling(Converter.convert(getScale()));
 //        objectId.setLocalScaling(Converter.convert(getScale()));
 //        objectId.setMargin(margin);
 //        objectId.setMargin(margin);
-        ByteBuffer bbuf=BufferUtils.createByteBuffer(points.length * 4); 
+        ByteBuffer bbuf=ByteBuffer.allocateDirect(points.length * 4).order(ByteOrder.nativeOrder());
 //        fbuf = bbuf.asFloatBuffer();
 //        fbuf = bbuf.asFloatBuffer();
 //        fbuf.rewind();
 //        fbuf.rewind();
 //        fbuf.put(points);
 //        fbuf.put(points);

+ 2 - 3
engine/src/bullet/com/jme3/bullet/collision/shapes/MeshCollisionShape.java

@@ -39,7 +39,6 @@ import com.jme3.export.InputCapsule;
 import com.jme3.export.OutputCapsule;
 import com.jme3.export.OutputCapsule;
 import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.mesh.IndexBuffer;
 import com.jme3.scene.mesh.IndexBuffer;
-import com.jme3.util.BufferUtils;
 import java.io.IOException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.ByteOrder;
@@ -69,8 +68,8 @@ public class MeshCollisionShape extends CollisionShape {
     }
     }
 
 
     private void createCollisionMesh(Mesh mesh) {
     private void createCollisionMesh(Mesh mesh) {
-        triangleIndexBase = BufferUtils.createByteBuffer(mesh.getTriangleCount() * 3 * 4);
-        vertexBase = BufferUtils.createByteBuffer(mesh.getVertexCount() * 3 * 4);
+        triangleIndexBase = ByteBuffer.allocateDirect(mesh.getTriangleCount() * 3 * 4).order(ByteOrder.nativeOrder());
+        vertexBase = ByteBuffer.allocateDirect(mesh.getVertexCount() * 3 * 4).order(ByteOrder.nativeOrder());
         numVertices = mesh.getVertexCount();
         numVertices = mesh.getVertexCount();
         vertexStride = 12; //3 verts * 4 bytes per.
         vertexStride = 12; //3 verts * 4 bytes per.
         numTriangles = mesh.getTriangleCount();
         numTriangles = mesh.getTriangleCount();

+ 3 - 3
engine/src/bullet/com/jme3/bullet/util/NativeMeshUtil.java

@@ -34,8 +34,8 @@ package com.jme3.bullet.util;
 import com.jme3.scene.Mesh;
 import com.jme3.scene.Mesh;
 import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.mesh.IndexBuffer;
 import com.jme3.scene.mesh.IndexBuffer;
-import com.jme3.util.BufferUtils;
 import java.nio.ByteBuffer;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 import java.nio.FloatBuffer;
 import java.nio.FloatBuffer;
 
 
 /**
 /**
@@ -45,8 +45,8 @@ import java.nio.FloatBuffer;
 public class NativeMeshUtil {
 public class NativeMeshUtil {
     
     
     public static long getTriangleIndexVertexArray(Mesh mesh){
     public static long getTriangleIndexVertexArray(Mesh mesh){
-        ByteBuffer triangleIndexBase = BufferUtils.createByteBuffer(mesh.getTriangleCount() * 3 * 4);
-        ByteBuffer vertexBase = BufferUtils.createByteBuffer(mesh.getVertexCount() * 3 * 4);
+        ByteBuffer triangleIndexBase = ByteBuffer.allocateDirect(mesh.getTriangleCount() * 3 * 4).order(ByteOrder.nativeOrder());
+        ByteBuffer vertexBase = ByteBuffer.allocateDirect(mesh.getVertexCount() * 3 * 4).order(ByteOrder.nativeOrder());
         int numVertices = mesh.getVertexCount();
         int numVertices = mesh.getVertexCount();
         int vertexStride = 12; //3 verts * 4 bytes per.
         int vertexStride = 12; //3 verts * 4 bytes per.
         int numTriangles = mesh.getTriangleCount();
         int numTriangles = mesh.getTriangleCount();