Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions jme3-core/src/main/java/com/jme3/scene/BatchNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,7 @@ protected void doBatch() {

//init the temp arrays if something has been batched only.
if (matMap.size() > 0) {
//TODO these arrays should be allocated by chunk instead to avoid recreating them each time the batch is changed.
//init temp float arrays
tmpFloat = new float[maxVertCount * 3];
tmpFloatN = new float[maxVertCount * 3];
if (useTangents) {
tmpFloatT = new float[maxVertCount * 4];
}
initTempFloatArrays();
}
}

Expand Down Expand Up @@ -387,7 +381,6 @@ private void mergeGeometries(Mesh outMesh, List<Geometry> geometries) {
int maxWeights = -1;

Mesh.Mode mode = null;
float lineWidth = 1f;
for (Geometry geom : geometries) {
totalVerts += geom.getVertexCount();
totalTris += geom.getTriangleCount();
Expand Down Expand Up @@ -537,6 +530,7 @@ private void doTransforms(FloatBuffer bindBufPos, FloatBuffer bindBufNorm, Float
Vector3f norm = vars.vect2;
Vector3f tan = vars.vect3;

validateTempFloatArrays(end - start);
int length = (end - start) * 3;
int tanLength = (end - start) * 4;

Expand Down Expand Up @@ -617,6 +611,22 @@ private void doTransforms(FloatBuffer bindBufPos, FloatBuffer bindBufNorm, Float
}
}

private void validateTempFloatArrays(int vertCount) {
if (maxVertCount < vertCount) {
maxVertCount = vertCount;
initTempFloatArrays();
}
}

private void initTempFloatArrays() {
//TODO these arrays should be allocated by chunk instead to avoid recreating them each time the batch is changed.
tmpFloat = new float[maxVertCount * 3];
tmpFloatN = new float[maxVertCount * 3];
if (useTangents) {
tmpFloatT = new float[maxVertCount * 4];
}
}

private void doCopyBuffer(FloatBuffer inBuf, int offset, FloatBuffer outBuf, int componentSize) {
TempVars vars = TempVars.get();
Vector3f pos = vars.vect1;
Expand Down