FloatBuffer clonePosition = clone.getFloatBuffer(Type.Position);
FloatBuffer cloneBindPosePosition = clone.getFloatBuffer(Type.BindPosePosition);
FloatBuffer cloneNormals = clone.getFloatBuffer(Type.Normal);
FloatBuffer cloneBindPoseNormals = clone.getFloatBuffer(Type.BindPoseNormal);
Buffer cloneIndexes = clone.getBuffer(Type.Index).getData();
for (int i = 0; i < cloneIndexes.limit(); ++i) {
int index = cloneIndexes instanceof ShortBuffer ? ((ShortBuffer) cloneIndexes).get(i) : ((IntBuffer) cloneIndexes).get(i);
if (!modifiedIndexes.contains(index)) {
modifiedIndexes.add(index);
this.get(clonePosition, index, point);
if (mirrorAtPoint0) {
d = Math.abs(point.get(mirrorIndex));
shiftVector.set(0, 0, 0).set(mirrorIndex, -point.get(mirrorIndex));
} else {
d = this.computeDistanceFromPlane(point, mirrorPlaneCenter, mirrorPlaneNormal);
mirrorPlaneNormal.mult(d, shiftVector);
}
if (merge && d <= tolerance) {
point.addLocal(shiftVector);
this.set(index, point, clonePosition, cloneBindPosePosition, position, bindPosePosition);
if (cloneNormals != null) {
this.get(cloneNormals, index, normal);
normal.set(mirrorIndex, 0);
this.set(index, normal, cloneNormals, cloneBindPoseNormals);
}
} else {
point.addLocal(shiftVector.multLocal(2));
this.set(index, point, clonePosition, cloneBindPosePosition);
if (cloneNormals != null) {
this.get(cloneNormals, index, normal);
normal.set(mirrorIndex, -normal.get(mirrorIndex));
this.set(index, normal, cloneNormals, cloneBindPoseNormals);
}
}
}
}
modifiedIndexes.clear();
LOGGER.finer("Flipping index order.");
switch (mesh.getMode()) {
case Points:
cloneIndexes.flip();
break;
case Lines:
for (int i = 0; i < cloneIndexes.limit(); i += 2) {
if (cloneIndexes instanceof ShortBuffer) {
short index = ((ShortBuffer) cloneIndexes).get(i + 1);
((ShortBuffer) cloneIndexes).put(i + 1, ((ShortBuffer) cloneIndexes).get(i));
((ShortBuffer) cloneIndexes).put(i, index);
} else {
int index = ((IntBuffer) cloneIndexes).get(i + 1);
((IntBuffer) cloneIndexes).put(i + 1, ((IntBuffer) cloneIndexes).get(i));
((IntBuffer) cloneIndexes).put(i, index);
}
}
break;
case Triangles:
for (int i = 0; i < cloneIndexes.limit(); i += 3) {
if (cloneIndexes instanceof ShortBuffer) {
short index = ((ShortBuffer) cloneIndexes).get(i + 2);
((ShortBuffer) cloneIndexes).put(i + 2, ((ShortBuffer) cloneIndexes).get(i + 1));
((ShortBuffer) cloneIndexes).put(i + 1, index);
} else {