Tokamak Open Source

Post Reply
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Tokamak Open Source

Post by Dirk Gregorius »

From what I saw in comarissons this was actually one of the fastest engines. So quite cool that it is open source now.

http://sourceforge.net/projects/tokamakp/
wyd124
Posts: 9
Joined: Sat Jan 06, 2007 9:34 am

Post by wyd124 »

Is this the result of competition?
raigan2
Posts: 197
Joined: Sat Aug 19, 2006 11:52 pm

Post by raigan2 »

If only the source was at least somewhat commented!
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine
Contact:

Post by Erin Catto »

Do you know what algorithms it uses?
David Lam
Posts: 3
Joined: Wed Jan 02, 2008 6:10 am

Re: Tokamak Open Source

Post by David Lam »

Hello All!

During this holiday I decided to revisit the world of physics programming and come across many different new physics engine and physics research. And hence I come to find this website about physics discussion. Doing a search for "Tokamak" come up with a few mentions. I admit I have neglect Tokamak for awhile. In case you are interested, When I released Tokamak back in 2003, I didn't have the skill and connection to take it commercial. I tried a few leads (that's another story), but I quickly returned to the world of game development doing mostly graphics stuffs. What I can say is that it is not easy to maintain a hobby project when you have a full time job and a family (and other hobbies)!

The dynamic solver hasn't change since back in 2003. It is what you can call sequential impulse. But the naive implementation of this doesn't work very well. Simply calculating impulse for zero-relative velocity alone will allow the joints position to drift. So there is an extra term in the impulse calculation for drift correction. The correction impulse should be such that it produce a relative velocity that reduce the displacement "in a frame step time". All the impulses for one body are accumulated before applying.

There is a hack for reducing the number of iteration require for maintaining stable stacking. Tokamak builds a directed graph of contacts pointing away from the gravity vector. And contact constraints are solve in that order.

The other things that was important was putting bodies to sleep. That's mostly done by considering the history of the body's state. I don't remember the exact procedure but I am happy to take a look at it again if anyone is interested.

For collision detection, everything is pretty standard except for narrow-phase convex meshes. I used the algorithm describe in this paper http://www.cs.hku.hk/research/techreps/ ... 005-01.pdf (Collision Detection of Convex Polyhedra Based on Duality Transformation). The algorithm seems sound, but for some reason I found very few people know or discuss about it. I think there's some numerical issue with my implementation so sometime it can fail.

That's off the top of my head. I am happy to talk about anything which I haven't cover. My view on physics engine is pretty much represented what Tokamak does: the important of speed, memory and stability far outweigh any accuracy concerns. I do intend on going back to work on Tokamak, for my own personal use if not for anything else.

Cheers,
David
billyzelsnack
Posts: 2
Joined: Wed Aug 03, 2005 7:29 pm
Contact:

Re: Tokamak Open Source

Post by billyzelsnack »

Welcome back to the physics world David. I think many people here were inspired by Tokamak when it first came out. I know I was.
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine
Contact:

Re: Tokamak Open Source

Post by Erin Catto »

Hi David,

I'm sure many people here would be curious to know about the inner workings of Tokamak.
I used the algorithm describe in this paper http://www.cs.hku.hk/research/techreps/ ... 005-01.pdf (Collision Detection of Convex Polyhedra Based on Duality Transformation). The algorithm seems sound, but for some reason I found very few people know or discuss about it..
I actually did implement this algorithm a while back using a quad-edge data structure. However this method doesn't give an accurate distance or penetration depth. How did you manage to use it to create contact points?

Cheers,
Erin
David Lam
Posts: 3
Joined: Wed Jan 02, 2008 6:10 am

Re: Tokamak Open Source

Post by David Lam »

Erin Catto wrote:Hi David,

I'm sure many people here would be curious to know about the inner workings of Tokamak.
I used the algorithm describe in this paper http://www.cs.hku.hk/research/techreps/ ... 005-01.pdf (Collision Detection of Convex Polyhedra Based on Duality Transformation). The algorithm seems sound, but for some reason I found very few people know or discuss about it..
I actually did implement this algorithm a while back using a quad-edge data structure. However this method doesn't give an accurate distance or penetration depth. How did you manage to use it to create contact points?

Cheers,
Erin
Hi Erin,

This could well be the case. In my test, arbitrary convex mesh colliding with ground box mesh (not as a primitive) seem fine but convex mesh colliding with each other do sometime penetrate. I checked the algorithm, and I can understand it and everything seems good on paper. It would be easy to write a test program and set up the fail case and follow the code to see why it fails, when I find the time :).

David
Post Reply