Gianluca wrote:My first idea was to set a Null Collision to bodies and to set a Null all callbacks regarding the bodies.
In that way, I suppose that the NewtonUpdate should simply skip the bodies and do nothing.
I tested the execution time of an empty NewtonWorld, of a NewtonWorld with 100 bodies active, and of a NewtonWorld with 100 bodies disabled as above.
There is no time difference between the last two conditions. Why ?? If there is no collision on bodies, and if there is no callbacks to call... why NewtonUpdate takes exactly the same time as if the bodies has collision and callbacks set ???
that was true of sdk 1.xx, in 1.xx inactive bodies where keetd in a separate list, and each body had a pointer to the list node.
Sicne the list where of the same kind, it was constanat time to move a body from one list to the next.
that made newton take almost zero time in a update popultated with bodies with NULL collision or sleeping bodies.
Newton 1.xx did not have a Force And TorqueCallback loop, activation and diactivation were handled by moving bodies from one list to the next.
with Newton 2.00 one for the main issue is mutithreading, so the above scheme made activation and dactivation happen in a critical section
and what became the become the biggest performnace bottlenect on the engine.
Newton 2.00 uses a much simpler approach, the body has a flag that indicate if it is sleepping or not.
then there is a loop that go over the list calling force and torque callback (even if the body is sleeping) and take care of the sleepping state of the body.
The loop is runned uncoditianlly on each call to newton update. and it is uses as the hartbeat of the simulation.
As it is now there is not way the newton 2.00 can ignore bodies.
what we can do is add the funtionality to remove a body from the simulation,
something like:
NewronRemoveBody(world, body)
NetwonInsertBody(world, body)
this can maybe be used to move bodies from one work to anotherr which is a funtionality Newton never had.
and it will handle NULL bodies, because make a body with Null collision deos no mean it sodu no get force and torque callback.
does that sound like a solution to you?