[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] line boundingbox




> Does this optimisation actually make a difference?  Has someone
> got a game where in place recting speeds it up substantially (say
> at least 1%)?

Creating new objects is a huge hit.
In the code I just started, adding the code that was just suggested to
create and extend via union the dirty rectangle, causes my game's frame rate
to drop by 12%. As this code is basically deeply nested inside two loops in
the game engine, every bit counts. (I beleive that example creates two
pygame.Rect's and two tuples.) My current inner loop code creates no new
objects. If you already create garbage or needed game objects and don't mind
the hit, you may not notice a few extra.

In addition, in these cases I've had to forego nicities such as "foo.x,
foo.y" which require dict lookup and use " l[0], l[1], l[:] = ...", etc.,
which also can speed things up. (I can't do this everywhere or I wouldn't be
able to read the code, especially w/o the existence of macros. Hopefully a
real py compiler will appear that maps the former to the latter, as should
be the case with most code.)

FWIW,

    HARDWARE | DOUBLEBUF | FULLSCREEN
    no dirty rect mangement
    a full Screen.fill between frames
    flip

turns out to be twice as fast as:

    erase-draw old pos
    track dirty rects
    update(dirty_list).

I'm probably going to count on win32/DirectX for a while for performance.
Is this mode directly supported by any Linux/card combos?
I'm using mostly line draws of many objects, so my case may be different
than heavily blt-based games.

thanks,
mike


----- Original Message -----
From: "Francis Irving" <francis@flourish.org>
To: <pygame-users@seul.org>
Sent: Tuesday, May 29, 2001 4:03 PM
Subject: Re: [pygame] line boundingbox


> On Tue, May 29, 2001 at 01:14:46PM -0700, Pete Shinners wrote:
> > > Also, it would be nice if Rect operations (such as union)
> > > were in-place (destructive) operations rather than creating
> > > new objs -- it's easy enough to copy them, but in this case
> > > (keeping a running Union) it would be more efficient.
>
> > the Rect is a very handy utility class, and i'm not opposed
> > to making it a bit more flexible. i don't think these additional
> > functions would make it too "overwhelming" either?
> > any opinions out there?
>
> Just to chant the usual games programming mantra at this point:
>
> Does this optimisation actually make a difference?  Has someone
> got a game where in place recting speeds it up substantially (say
> at least 1%)?
>
> Perhaps the actual sprite blitting dwarfs creating a new object on an
> efficient heap.
>
> Francis
>
> --
> Home: francis@flourish.org  Web: www.flourish.org
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org