chipmunkpymunk

Does Chipmunk/Pymumk have culling of objects that are outside screen boundary?


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().


Solution

  • 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.