Page 1 of 1
Disable/remove body
Posted: Mon Nov 07, 2011 1:56 pm
by saturn1
Hello, for my game i use one quadtree and each time there is new body or removed body i do :
-World.Remove(this.Body);
-World.Add(this.Body);
But i wonder if it's a heavy operation, and maybe there is a function like disableBody which is more expensive??
Thank you.
Re: Disable/remove body
Posted: Mon Nov 07, 2011 7:54 pm
by Norbo
Adding objects to a space is pretty quick. Removing objects is still quick, but generally removals should be slower than adds. I couldn't say whether or not it is
too expensive for your purposes; you'll have to measure and find out.
maybe there is a function like disableBody which is [less] expensive??
Dynamic objects that have been sitting still for a while will go to sleep. In a sleeping state, only the broad phase touches the entity. The other update processes early-out, making a bunch of sleeping objects quite cheap. Sleeping is handled automatically. You can check to see if an object is asleep using its entity.ActivityInformation.IsActive property.
Re: Disable/remove body
Posted: Tue Nov 08, 2011 1:12 pm
by saturn1
Thank you.