Clearing all objects upon config change

Started by deqleos, April 05, 2018, 04:18:13 PM

Previous topic - Next topic

deqleos

Hi,

I'm currently creating an app where a high number of objects are created and removed during the usage.
Now I want to make sure that config changes don't create weird scenarios.
The objects that I create are dependant on the lifetime of a real world object. When the real world object isn't present anymore, the on screen object also has to be removed.
Now this works perfectly fine during the usage of the app. However, when the real world object is present and a config change occurs, the objects stay on the screen and don't get deleted. The problem lays in that the world gets deleted before the app has the chance to remove the objects.
The error i get is: 
ERROR: Can't remove object #1, because it doesn't belong to this World!

TLDR: How can I delete individual objects independent of the world they are in, instead of having to call world.removeObject();

EgonOlsen

I'm not sure, if I understand the problem. If an object belongs to a world, it will be rendered if that world is. If not...then not. Where do you want to remove the object from if not the world? If the exception bothers you and you feel that it's save what you are doing, then just catch and ignore it. However, that might just be a symptom of the actual problem...that I somehow don't get...!?

deqleos

I guess the issue is that onSurfaceCreated gets called and a new world gets initialised.
The 3D objects stay in memory for some reason and then I'm trying to delete them from the new world, which obviously won't work.
So the reason I asked for a way to delete individual objects is that I lose reference to the original world.

Anyways, the issue is pretty insignificant for now and is probably very specific to my situation. Thanks though

EgonOlsen

Maybe just reuse the world instance? At least that's what I'm doing.

deqleos