return;
}
updateCounter = 0;
final int[] indexBuffer = new int[3];
final MeshData sphereMD = sphere.getMeshData();
final MeshData torusMD = torus.getMeshData();
final FloatBuffer color1 = sphere.getMeshData().getColorBuffer();
final FloatBuffer color2 = torus.getMeshData().getColorBuffer();
if (oldData != null) {
for (int j = 0; j < oldData.getSourcePrimitives().size(); j++) {
final PrimitiveKey key = oldData.getSourcePrimitives().get(j);
sphereMD.getPrimitiveIndices(key.getPrimitiveIndex(), key.getSection(), indexBuffer);
BufferUtils.setInBuffer(colorSpread[indexBuffer[0] % 3], color1, indexBuffer[0]);
BufferUtils.setInBuffer(colorSpread[indexBuffer[1] % 3], color1, indexBuffer[1]);
BufferUtils.setInBuffer(colorSpread[indexBuffer[2] % 3], color1, indexBuffer[2]);
}
for (int j = 0; j < oldData.getTargetPrimitives().size(); j++) {
final PrimitiveKey key = oldData.getTargetPrimitives().get(j);
torusMD.getPrimitiveIndices(key.getPrimitiveIndex(), key.getSection(), indexBuffer);
BufferUtils.setInBuffer(colorSpread[indexBuffer[0] % 3], color2, indexBuffer[0]);
BufferUtils.setInBuffer(colorSpread[indexBuffer[1] % 3], color2, indexBuffer[1]);
BufferUtils.setInBuffer(colorSpread[indexBuffer[2] % 3], color2, indexBuffer[2]);
}
}
results.clear();
PickingUtil.findCollisions(torusNode, sphereNode, results);
if (results.getNumber() > 0) {
oldData = results.getCollisionData(0);
for (int i = 0; i < oldData.getSourcePrimitives().size(); i++) {
final PrimitiveKey key = oldData.getSourcePrimitives().get(i);
sphereMD.getPrimitiveIndices(key.getPrimitiveIndex(), key.getSection(), indexBuffer);
BufferUtils.setInBuffer(ColorRGBA.RED, color1, indexBuffer[0]);
BufferUtils.setInBuffer(ColorRGBA.RED, color1, indexBuffer[1]);
BufferUtils.setInBuffer(ColorRGBA.RED, color1, indexBuffer[2]);
}
for (int i = 0; i < oldData.getTargetPrimitives().size(); i++) {
final PrimitiveKey key = oldData.getTargetPrimitives().get(i);
torusMD.getPrimitiveIndices(key.getPrimitiveIndex(), key.getSection(), indexBuffer);
BufferUtils.setInBuffer(ColorRGBA.BLUE, color2, indexBuffer[0]);
BufferUtils.setInBuffer(ColorRGBA.BLUE, color2, indexBuffer[1]);
BufferUtils.setInBuffer(ColorRGBA.BLUE, color2, indexBuffer[2]);
}
}