diff options
author | renanse <[email protected]> | 2013-01-20 00:51:00 -0600 |
---|---|---|
committer | renanse <[email protected]> | 2013-01-20 00:51:00 -0600 |
commit | be8f02e0593bf0f0a86082b3bdfc2c5805a57e59 (patch) | |
tree | 011383de3e280f1a960b17f818dfad2e012a31c1 /ardor3d-extras/src/main/java/com | |
parent | 8908ac9904c3acc8bd40b4c16b13d0934ca81ee5 (diff) |
Switched more code to using more efficient index buffers.
Diffstat (limited to 'ardor3d-extras/src/main/java/com')
-rw-r--r-- | ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java | 17 | ||||
-rw-r--r-- | ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java | 8 |
2 files changed, 9 insertions, 16 deletions
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java index 887f415..6609544 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java @@ -12,11 +12,11 @@ package com.ardor3d.extension.model.util; import java.io.IOException;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.logging.Logger;
import com.ardor3d.scenegraph.FloatBufferData;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.Spatial;
import com.ardor3d.scenegraph.controller.ComplexSpatialController;
@@ -379,17 +379,18 @@ public class KeyframeController<T extends Spatial> extends ComplexSpatialControl dcNorms.put(mmNorms);
dcNorms.flip();
}
- if (_morphMesh.getMeshData().getIndexBuffer() != null) {
- IntBuffer dcInds = (IntBuffer) dataCopy.getMeshData().getIndexBuffer();
+ if (_morphMesh.getMeshData().getIndices() != null) {
+ IndexBufferData<?> dcInds = dataCopy.getMeshData().getIndices();
if (dcInds != null) {
- dcInds.clear();
+ dcInds.rewind();
}
- final IntBuffer mmInds = (IntBuffer) _morphMesh.getMeshData().getIndexBuffer();
+ final IndexBufferData<?> mmInds = _morphMesh.getMeshData().getIndices();
mmInds.clear();
- if (dcInds == null || dcInds.capacity() != mmInds.capacity()) {
- dcInds = BufferUtils.createIntBuffer(mmInds.capacity());
+ if (dcInds == null || dcInds.capacity() != mmInds.capacity() || dcInds.getClass() != mmInds.getClass()) {
+ dcInds = BufferUtils.createIndexBufferData(mmInds.capacity(), _morphMesh.getMeshData()
+ .getVertexBuffer().capacity() - 1);
dcInds.clear();
- dataCopy.getMeshData().setIndexBuffer(dcInds);
+ dataCopy.getMeshData().setIndices(dcInds);
}
dcInds.put(mmInds);
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java index 8a9f483..558d9fb 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java @@ -19,7 +19,6 @@ import com.ardor3d.math.Vector3; import com.ardor3d.math.type.ReadOnlyVector3; import com.ardor3d.renderer.IndexMode; import com.ardor3d.scenegraph.FloatBufferData; -import com.ardor3d.scenegraph.IndexBufferData; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.util.export.InputCapsule; import com.ardor3d.util.export.OutputCapsule; @@ -299,13 +298,6 @@ public class TrailMesh extends Mesh { private void setIndexData() { getMeshData().setIndexMode(IndexMode.TriangleStrip); - if (getMeshData().getIndexBuffer() == null) { - getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(trailVertices)); - final IndexBufferData<?> indexBuf = getMeshData().getIndices(); - for (int i = 0; i < trailVertices; i++) { - indexBuf.put(i); - } - } } @Override |