renderScene() not applying changes to objects

Started by keaukraine, November 25, 2010, 08:32:53 PM

Previous topic - Next topic

keaukraine

After opening another instance of activity previously launched activity makes some re-initialization stuff after which renderScene() call seems to be ignoring rotation made to objects.
Camera rotates as usual, but transformations are not applied to objects, they keep their old transformations applied.

In short, it behaves like renderScene() doesn't do any work.
Calling world.buildAllObjects() before renderScene() doesn't work as well.
Please explain what needed stuff can be lost after re-initialization or may be if it's a bug in JPCT-AE, fix it.

EgonOlsen

#1
No idea what you are doing in the re-init step, but IMHO the only way in which this might happen is, if you don't translate the right object instances. Maybe you are recreating them without assigning them to the world, so that the objects you are rendering are no longer the objects that you transform? If renderScene() wouldn't work, you won't see anything at all.

keaukraine

Thanks for giving me explanations and hints, now it works fine.

To fix the problem I'm calling world.removeAllObjects() and then world.addObject() 10 times on every frame redraw. I hope adding objects to world isn't very expensive thing, I suppose it should only set up references to them in some array. At least I didn't notice any performance drop if I perform adding 10 objects to world every frame.

EgonOlsen

Adding isn't very expensive, but it doesn't sound right to me to do this every frame. There has to be a better solution than this...