[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pixel-perfect physics?



Once the PyGame physics module supports other shapes and collision callbacks 
it would be easy to first do the regular AABB test and then do a mask 
collision test. As for the physics, I'm not sure the GSOC project will ever 
include support for adding custom contact points, etc, but it seems like a 
collision joint on the colliding pixels would be in order.

However, all this would be akward and quite cpu expensive since in modern 
games, both in graphics and physics, shapes are in and pixels are out.

/Peter

On 2008-10-26 (Sun) 10:04, Nirav Patel wrote:
> Certainly not an easy problem, especially if the shapes are convex.  A
> sort of hackish way to do this in PyBox2D, if the shapes aren't
> already known polygons, is to use Mask.outline() to get some points on
> the outline of your object and create a Box2D Poly out of a bunch of
> thin connected rects shaped like your object.  This is a really bad
> description, but check out this thread:
> http://www.box2d.org/forum/viewtopic.php?f=8&t=563 .
> 
> Elements, a wrapper for PyBox2D, has functions similar to this written
> that you may also want to look at.  Take a look at complexPoly and
> concavePoly in http://dev.laptop.org/git?p=activities/physics;a=blob;f=elements/add_objects.py;h=3842b750a8dfe46d9400bab1c6ff5d6206dc718f;hb=HEAD
> 
> This still isn't pixel perfect, but accurate physics and pixel perfect
> collision do not go together.
> 
> Nirav
> 
> On Fri, Oct 24, 2008 at 4:50 PM, Michael George <mdgeorge@xxxxxxxxxxxxxx> wrote:
> > Has anyone had experience using pixel-perfect collision detection with a 2d
> > physics engine?  I've looked into pymunk, but that seems to have baked-in
> > collision detection so I don't see how to do it.  ODE has rudimentary python
> > bindings and has separate collision detection, but it's intended for 3d and
> > the 2d support hasn't been added to the python port yet.  There's the GSOC
> > pygame physics project, but I don't see docs for that and can't tell if it
> > would be suitable.
> >
> > Also, as far as doing the collision detection, AFAICT there isn't a way to
> > rotate a mask, or to do collision detection on rotated objects.  Are there
> > plans for something like this, or am I stuck with using an image, rotating
> > it with the transform package and then using Mask.from_surface?
> >
> > Thanks.
> >
> > --Mike
> >
>