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

Re: [pygame] Physics, collision detection etc?



Hi again Nirav!

Yes, but the number of pixels involved makes it too time consuming.
Also, I'll be using OpenGL to render the polygons which means I have to copy 
the pixels to RAM or use occlusion tests, neither of which are optimal.

/Peter

On 2008-10-07 (Tue) 15:03, Nirav Patel wrote:
> Peter,
> 
> If the polygons are Surfaces or can be turned into Surfaces, they can
> be turned into Masks to do pixel collision.  Though, I may be
> misunderstanding what you are trying to do.
> 
> Nirav
> 
> On Tue, Oct 7, 2008 at 11:21 AM, Peter Gebauer
> <peter.gebauer@xxxxxxxxxxxxxxxxxxxxx> wrote:
> > Hey Nirav!
> >
> > Yep, but as I said, I need to find colliding polygons, not pixels.
> >
> > /Peter
> >
> > On 2008-10-06 (Mon) 12:05, Nirav Patel wrote:
> >> Peter,
> >>
> >> There are some new functions in SVN in the mask module.  New ones
> >> since 1.8.1 that could be useful for collision are:
> >>
> >> Mask.overlap_mask - Returns a mask of the overlapping pixels
> >> Mask.draw - Draws a mask onto another
> >> Mask.erase - Erases a mask from another
> >> Mask.count - Returns the number of set pixels
> >> Mask.centroid - Returns the centroid of the pixels in a Mask
> >> Mask.angle - Returns the orientation of the pixels
> >> Mask.connected_component - Returns a mask of a connected region of pixels.
> >>
> >> The mask module does pixel collisions pretty quickly.  I think on
> >> modern systems it shouldn't be a significant difference (compared to
> >> say, blitting) between using pixel perfect detection and something
> >> like the seperating axis theorem.
> >>
> >> Nirav
> >>
> >> On Mon, Oct 6, 2008 at 11:27 AM, Peter Gebauer
> >> <peter.gebauer@xxxxxxxxxxxxxxxxxxxxx> wrote:
> >> > Hey guys!
> >> >
> >> > I've been looking around for various libraries that handle
> >> > intersection/colliding polygons/line segments, I'm just wondering if/when
> >> > there will be polygon shapes and additional collision testing functions
> >> > that can be used seemlessly with the old rect and mask libraries that
> >> > already exist in PyGame?
> >> >
> >> > /Peter
> >> >
> >>
> >
>