www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Uncle Ray on April 24, 2015, 04:26:21 am

Title: why world.removeObject not destroy object3D?
Post by: Uncle Ray on April 24, 2015, 04:26:21 am
When i use world.removeObject(obj),and later use world.addObject(obj),the obj  is still there.

i thought removeobject() will clear object from memory,in fact i am wrong?

so,if i want to destroy obj,i just use,
obj.clearobject();
obj.clearrotation();
obj.cleartranslation();
obj=null;


is that right?

in a shorting say,if i want destroy a object3D,which method will free memory,and really set the obj clear?
Title: Re: why world.removeObject not destroy object3D?
Post by: EgonOlsen on April 24, 2015, 06:52:44 am
The object will be unloaded from GPU and CPU memory if there's no further reference in your code to it. In this example, setting it to null should do it unless there's some others reference to it. You can skip these clear....-methods though. They are just resetting the matrix.
Title: Re: why world.removeObject not destroy object3D?
Post by: Uncle Ray on April 24, 2015, 11:41:25 am
with DDMS,set object3d to null,later memory will be freed.
but world.removeobject(obj),memory never freed.


ok,i think set to null,it was the best method to destroy Object3D.
Title: Re: why world.removeObject not destroy object3D?
Post by: EgonOlsen on April 24, 2015, 12:25:08 pm
but world.removeobject(obj),memory never freed.
No. Why should it? The world is essentially a set of objects. As long as you keep a reference to an instance, nothing will be freed. That's how Java works...