removing all entities from space
removing all entities from space
how to remove all entities from space
Re: removing all entities from space
There's no "remove all entities" method. If you want to completely start from scratch, consider disposing the old space and creating a new one. If you want to re-use the space for other reasons, then removing the entities one-by-one is the current best solution. The Space.Entities property exposes the entities currently in the engine.
Re: removing all entities from space
but disposing does not remove all the entities as i am getting" Cannot add updateable as it already belongs to a space. Ensure that the updateable's space is null before attempting to add it."
after disposing the space
after disposing the space
Re: removing all entities from space
Yep, sorry, forgot to mention- if you dispose, it's assuming you're not re-using anything. If you want to re-use something, then you need to do Space.Removes.
Re: removing all entities from space
like manually removing all the entities?
Re: removing all entities from space
Using Space.Remove, yes.
Re: removing all entities from space
wht if i do space=null;
Space space;
space=new Space();
space.Add(Entity);
space=null
will it clear the whole space?
Space space;
space=new Space();
space.Add(Entity);
space=null
will it clear the whole space?
Re: removing all entities from space
That creates a new space, adds an entity to the space, and then abandons a reference to the space. The space still exists in memory, unchanged. If you hold a reference to the Entity you added to the Space, you are indirectly holding a reference to the Space, and so the Space will never be collected as garbage. If you did not hold a reference to the Entity and nothing else referred to the Space, then the Space and everything in it (that doesn't have an external reference somewhere) would get finalized at some indeterminate point in the future on the whim of the GC, at which point it is also disposed.
For an example where a space and all of its components are completely killed off, look at the BEPUphysicsDemos. Whenever the simulation switches, the Space is disposed, every single reference to the Space and objects in the Space are lost, and the entire simulation gets garbage collected.
For an example where a space and all of its components are completely killed off, look at the BEPUphysicsDemos. Whenever the simulation switches, the Space is disposed, every single reference to the Space and objects in the Space are lost, and the entire simulation gets garbage collected.
Re: removing all entities from space
thnks buddy
changing the simulation worked
cheers
changing the simulation worked
cheers
Re: removing all entities from space
where the samples source (i found the exe only)
Re: removing all entities from space
The main source download contains the BEPUphysicsDemos project: http://bepuphysics.codeplex.com/SourceC ... changesets