1

I'm using SDL (pygame) for a cnc simulator. Initally, screen refreshing is done using the painter's algorithm (just draw everything back-to-front) but it quicly becames slow with big surfaces.

To speed-up redrawing I'm only refreshing the parts of the screen that change at any given moment so if a numeric value changes its value, only its surface and the correspondant sub-surface for every colliding surface gets redrawn.

At the moment, im doing a clipping test over everything on on screen to detect the colliding surfaces, while significantly faster I think there should be a data structure and/or algorithm to avoid testing all the surfaces on screen.

NeonMan
  • 623
  • 10
  • 24

1 Answers1

0

You should consider using a quadtree to store the bounds of each of your surfaces. This will optimize your operation when finding the colliding surfaces.

You might find the question / answer useful.

Community
  • 1
  • 1
emartel
  • 7,712
  • 1
  • 30
  • 58