Hi,
I wanted to check if there is a specific order to adding and building objects within the world(!) on an ongoing basis.
My application is dynamically creating and building objects based on a download, and then adding them into the world, but very quickly this results in the message
There's a problem with the object list not being consistent during rendering. This is often caused by concurrent modification of jPCT objects on a thread different from the rendering thread!
I am trying to store the un-built objects built within an arraylist as they are downloaded and created, and then based on a timer within the onDrawFrame() method rattle through the list adding them into the world to try and ensure that the render thread is in control, but this doesn't help.
What seems to happen is that (for example) 1300 objects are created, then the addObject timer kicks in and adds them to the world - this is fine. The next time the addObject timer kicks in, it adds another 20 objects to the world, at which point the above error happens and kills the application. (Previously the objects were added as they were downloaded)
I have tried calling theWorld.buildAllObjects(); and theWorld.compileAllObjects(frameBuffer); after the objects are added, which helps stability for the first set of objects, but the error still happens the second time around.
public void onDrawFrame(GL10 arg0) {
long thisFrameTime = System.currentTimeMillis();
// Render the scene
theWorld.renderScene(frameBuffer);
theWorld.draw(frameBuffer);
frameBuffer.display();
if (thisFrameTime - addTime >= 5000) addObjectsToWorld();
}
private void addObjectsToWorld() {
//if (runed) return;
int i=0;
for (Dataset ds : theApp.getTheRegistry().getDataContainer()) {
for (Feature f : ds.getFeatureCollection()) {
if (f.isBuilt() && f.isVisible() && !f.isInWorld()) {
for (A_Object3D o : f.get3DObjects()) {
f.setInWorld(true);
theWorld.addObject(o);
}
i++;
}
}
}
if (i>0) {
theWorld.buildAllObjects();
try {
theWorld.compileAllObjects(frameBuffer);
} catch (Exception e) {
e.printStackTrace();
}
}
Log.i("Render","Added "+i+" objects to world");
addTime = System.currentTimeMillis();
}
Any help would be much appreciated