From 7cc3592f0fcbbd2d47e018816cb193299fcac3f3 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Sun, 10 Jul 2011 19:29:08 +0000 Subject: [PATCH] - 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 --- .../jme3/bullet/collision/shapes/GImpactCollisionShape.java | 5 ++--- .../bullet/collision/shapes/HeightfieldCollisionShape.java | 3 +-- .../jme3/bullet/collision/shapes/HullCollisionShape.java | 3 +-- .../jme3/bullet/collision/shapes/MeshCollisionShape.java | 5 ++--- engine/src/bullet/com/jme3/bullet/util/NativeMeshUtil.java | 6 +++--- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/engine/src/bullet/com/jme3/bullet/collision/shapes/GImpactCollisionShape.java b/engine/src/bullet/com/jme3/bullet/collision/shapes/GImpactCollisionShape.java index af97983e4..2e253d1e9 100644 --- a/engine/src/bullet/com/jme3/bullet/collision/shapes/GImpactCollisionShape.java +++ b/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.scene.VertexBuffer.Type; import com.jme3.scene.mesh.IndexBuffer; -import com.jme3.util.BufferUtils; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -71,8 +70,8 @@ public class GImpactCollisionShape extends CollisionShape { } 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); // vertexBase = ByteBuffer.allocate(mesh.getVertexCount() * 3 * 4); numVertices = mesh.getVertexCount(); diff --git a/engine/src/bullet/com/jme3/bullet/collision/shapes/HeightfieldCollisionShape.java b/engine/src/bullet/com/jme3/bullet/collision/shapes/HeightfieldCollisionShape.java index 4a7e43fb2..2c2da1323 100644 --- a/engine/src/bullet/com/jme3/bullet/collision/shapes/HeightfieldCollisionShape.java +++ b/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.Vector3f; import com.jme3.scene.Mesh; -import com.jme3.util.BufferUtils; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -95,7 +94,7 @@ public class HeightfieldCollisionShape extends CollisionShape { } 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.rewind(); // fbuf.put(heightfieldData); diff --git a/engine/src/bullet/com/jme3/bullet/collision/shapes/HullCollisionShape.java b/engine/src/bullet/com/jme3/bullet/collision/shapes/HullCollisionShape.java index c64969f27..3f27150ba 100644 --- a/engine/src/bullet/com/jme3/bullet/collision/shapes/HullCollisionShape.java +++ b/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.scene.Mesh; import com.jme3.scene.VertexBuffer.Type; -import com.jme3.util.BufferUtils; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -67,7 +66,7 @@ public class HullCollisionShape extends CollisionShape { // objectId = new ConvexHullShape(pointList); // objectId.setLocalScaling(Converter.convert(getScale())); // objectId.setMargin(margin); - ByteBuffer bbuf=BufferUtils.createByteBuffer(points.length * 4); + ByteBuffer bbuf=ByteBuffer.allocateDirect(points.length * 4).order(ByteOrder.nativeOrder()); // fbuf = bbuf.asFloatBuffer(); // fbuf.rewind(); // fbuf.put(points); diff --git a/engine/src/bullet/com/jme3/bullet/collision/shapes/MeshCollisionShape.java b/engine/src/bullet/com/jme3/bullet/collision/shapes/MeshCollisionShape.java index f262b2879..b7813a650 100644 --- a/engine/src/bullet/com/jme3/bullet/collision/shapes/MeshCollisionShape.java +++ b/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.scene.VertexBuffer.Type; import com.jme3.scene.mesh.IndexBuffer; -import com.jme3.util.BufferUtils; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -69,8 +68,8 @@ public class MeshCollisionShape extends CollisionShape { } 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(); vertexStride = 12; //3 verts * 4 bytes per. numTriangles = mesh.getTriangleCount(); diff --git a/engine/src/bullet/com/jme3/bullet/util/NativeMeshUtil.java b/engine/src/bullet/com/jme3/bullet/util/NativeMeshUtil.java index 75aa74005..83656d30a 100644 --- a/engine/src/bullet/com/jme3/bullet/util/NativeMeshUtil.java +++ b/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.VertexBuffer.Type; import com.jme3.scene.mesh.IndexBuffer; -import com.jme3.util.BufferUtils; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.FloatBuffer; /** @@ -45,8 +45,8 @@ import java.nio.FloatBuffer; public class NativeMeshUtil { 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 vertexStride = 12; //3 verts * 4 bytes per. int numTriangles = mesh.getTriangleCount();