Saturday, January 19, 2008

Rigid Body Physics #2

hi
i fixed some bugs in the physics engine related to inertia tensor calculations and collisions.
i also add it to my fixed time step scheme, so it will be more smooth.
while checking performance i found a bug in my particle system related to profiler sections, it seems that profiler section started but wasn't ended so it damaged the profiler (this isn't related to rigid body physics but because of this i added nice feature to the profiler so it will show me if sections are not closed properly).
anyway, i founded that my collision system needs optimizations (because of the mesh vs mesh collision), so i searched the net to find some info about generic convex mesh collision and i found something called: GJK algorithm.
i also so that its good to build AABB/OBB trees for the meshes for fast culling.
i already implement AABB tree in my engine for some collision testing at the beginning, now i found some useful area to use it.
as for GJK, i need to read more about it and see how it goes.
in my last update i uploaded screenshots, and its time to add some nice movie to show my physics in action:

Saturday, January 12, 2008

Rigid Body Physics

hi, i decided to add some rigid body physics.
there is a lot of physics engines out there that i could integrate into my engine, so i have checked few engines such as Agiea PhysX, newton dynamics and ode.
Agiea PhysX seems to be very fast and stable, and it comes with great sdk with tons of examples, so i decided to give it a try.
while trying t integrate i have founded that its not so great for me, because i already have very good and fast collision system that i'm using in my AI, projectiles,camera collision and more, so to make use of external lib i must change all the places that use my system to use theirs.
this wasn't an option because i need to check that everything that was working is still works after the change.
i could use their engine with my own systems but it required to duplicate the data, the scene for example must be known by both systems so they and mine could do collisions.
also, i just want simple physics and i wont even use all the features that Agiea PhysX support so i decided to write my own physics engine so the integration will be smooth and clean, this will take some time to do but i think its worth the a effort, i also will learn from the process :)
my physics system is impulsed based, that means that in order to move an object an impulse to act on the object on a certain point.
i choose to use impulsed base physics engine so i wont need to solve big linear equations system every frame, also i could give x ms for the physics engine and things that didn't solved correctly in current frame will get a chance next frame.
also in impulsed base, constraints system isn't stiff, that means the constraints is trying to be preserved by applying forces every frame/iteration, this is different from linear systems (implicit method) because if the system can't be solved (for example: one of the constraint needs very big forces to be preserved) the system will explode.
after reading some materials and got refreshed in my calculus, i'v started to wrote the engine.
i have finished the integration, also add simple shapes: sphere, box, cylinder
the collision system is also finished and support rigid body vs scene and rigid body vs rigid body collision.
for now each rigid body is a mesh, so the collision basically does mesh vs mesh collision, this simplify the things a lot because i don't need to a lot of collision functions based on rigid bodies type.
i also started working on few joint constraints: ball & socket, hinge and universal, next time i hope i will finish it and put some screenshots :)
here is few screenshots of the rigid bodies in action (wireframe mode).

box stacks
one of the stacks lost balance and fall