1

I found culling only under spatial hashing for collisions. I'm referring to the kind of backface culling performed by 3D graphics libraries, where anything that need not be visible isn't rendered.

Does Chipmunk2D/Pymunk have any provision for not drawing objects that are not within screen bounds or does that user have to implement it themselves?
For example:
enter image description here

The red rectangle is the screen boundary. All blue objects should get drawn because they are within the screen. Green objects shouldn't be drawn.

I was hoping debug_draw() would have a culling functionality.

ps: btw, if I don't use debug_draw() for drawing, what is the other way of drawing? I don't see a draw() or release_draw() function. So would the user have to write code to individually iterate all objects and draw them? I guess that'd work fine because then the user can do a rectangle intersection test and decide which objects to cull. Perhaps debug_draw could be renamed to drawAll().

Nav
  • 19,885
  • 27
  • 92
  • 135

1 Answers1

1

The debug draw method is mainly meant for debugging and quick prototyping, so more advanced features such as culling is out of scope for its implementation.

If you feel yourself limited by debug draw it might be time to transition to your own drawing code, where you have full control. It should be quite easy to emulate what debug draw is doing yourself, some of the example code do custom drawing.

viblo
  • 4,159
  • 4
  • 20
  • 28
  • Ok thats's sad. I had seen methods of doing custom drawing and had posted an example in a prior answer (which I had edited into your answer) but didn't know how I would go about doing a custom drawing of the constraints, which is why I stuck with `debug_draw`. More examples of such functionality would be a great help. – Nav Apr 02 '19 at 01:27
  • Pygame does its own culling before it blits outside the screen, so you wont take the full performance hit: https://stackoverflow.com/questions/39185187/will-pygame-blit-sprites-with-a-rect-outside-the-display – viblo Apr 02 '19 at 18:23