I modified the serialize interface. now it take an array of bodies, that way the client application can serialize selection rather that complete worlds,
the interface is like this now
- Code: Select all
void NewtonSerializeBodyArray (const NewtonWorld* const newtonWorld, NewtonBody** const bodyArray, int bodyCount, NewtonOnBodySerializationCallback serializeBody, NewtonSerializeCallback serializeFunction, void* const serializeHandle);
void NewtonDeserializeBodyArray (const NewtonWorld* const newtonWorld, NewtonOnBodyDeserializationCallback deserializeBody, NewtonDeserializeCallback serializeFunction, void* const serializeHandle);
I also added the Scene collision, for what you described you have a world with lot of static objects, at mix of terrain polygonal meshes, and rigid solid.
the scene collision is a static compound collision, so it can take convex, and poligonal mesh.
for world with my static terrain paches with terrain LOD, polygonal meshes, and solid convexes (collsion scene does not allow to take other collision scene as child shape) .
This offer a big level performance optimization and memory saving.
say for example you have a work with 1000 static mesh, and 100 dynamiocs bodies.
if each piece is added to the broad phase as a body.
the broad phase time complexity is k * n log2(n) whil is k * 1100 * log2 (1100)
this is because the does not know that a static body does no move, and even if it did to add that information to a single brad phase,
you end of with a series of states represent by dirty flags in the broad phase and each body.
The reason for this is that the only way to extract that information is by haven a full graph, and the broad phase if a top down tree. therefore graph connectivity has to be added with dirty flags.
this was the approach used in core 100 and 200
for core 300, and by the end of core 200 I realize that the person who knows better how to optimize the collision is the client application.
The client will know when a body is static, if it has more statics than dynamics, or vise verse.
this can be accomplished by assign some sort of grouping to the collision system. But the engine had that already, it was the compound collision.
So I realize that with little modification to the compound collision, basically adding the ability to add, and remove children and modifier the transform matrix of a child shape. this is what the collision engine needed.
so I did that and now scene collision is a powerful system that let the end application to add unlimited number of static shape at chapel cost. Say for example you want to add a tree forest.
normally people do that by making a series for trees, and placing instances of the at random.
with the new collision system the cost of adding a new copy is simple a new node in the collision scene.
while the all system add a complete body.
let us now calculate the time complexity for the above example.
we know that 1000 entities are static, but they do not collide with each other.
the worse time complexity for this object is if every other object is in intersecting its AABB.
the time complexity of colliding one object with the scene collision is log (n)
so when all bodies intersect the aadd of the collision scene we have 100 * log (1000)
all the dynamics bodies can collide with each other so they time complexity is 100 * log (100)
so the total time complexity is now
k * 100 * (log2 (1000) + log2 (100))
if we neglect the log2(100) over
you can see how the performance a least 10 time that of the general tree. In general is much better.
what this mean is that a client application can literally add 10's of thousand of object to a world in cost effect way.
Meaning objects will only be consider for calculation when a dynamic object is nearby and not other time.
Scene collision is the Newton solution for Next generation games like you see in crisis, and battle field 4.
while still being general phys engine.
those technologies are so tight that they cannot afford to use a their part engine, they actually have to write custom solutions.
While those game are very impressive graphically, when you analyze the closely the physics is of very poor quality. Bad collision, bad physics resolution.