mosra / magnum-integration

Integration libraries for the Magnum C++11 graphics engine
https://magnum.graphics/
Other
98 stars 44 forks source link

2D Physics Engine #18

Open ghost opened 8 years ago

ghost commented 8 years ago

I noticed Bullet doesn't have a 2D version for its objects. Feasibly, this could be fixed in two ways:

  1. Create a 2D version of the Bullet objects, which would assumedly convert between the 2D magnum API's and a 2D version of Bullet shapes (similar to the current way 3D Bullet integration works, but with the Z axis disabled or some such)
  2. Keep the API similar, but use a Box2D backend, giving similar integration but a different and more suitable backend.

I've got experience with Box2D, if that seems more applicable to what we want in a 2D physics engine, and it's widely used and widely regarded.

mosra commented 8 years ago

Box2D would be awesome :) I also don't see Bullet matching to 2D very well.

The use case is probably a bit different, so I don't mind having a completely different API from what's done for Bullet. Makes more room for experiments.

Squareys commented 8 years ago

Bullet does allow for 2D physics (see their example here), you basically register some 2D collision algorithms to the collision dispatcher, but still have to use 3D vectors it seems.

Box2D would indeed be awesome, though :D

ghost commented 8 years ago

@mosra @Squareys Looks like the proper way forward would be to embed Box2D then; it doesn't look any harder than Bullet, and it is probably more optimized towards 2D physics.

roig commented 7 years ago

Have you checked http://chipmunk-physics.net/ ? I think it's more flexible than Box2D.

mosra commented 6 years ago

Just for the record, a very simple Box2D example is now in the examples repository. This was done directly, without creating any integration library. Potential integration lib could be based on what the example does (conversion of math types first, for example).

Squareys commented 6 years ago

Btw, for reference: I remember the way to do 2D in bullet is to add a bunch of contstraints to the Z axis of all the rigid bodies.