首页 > 解决方案 > 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().

标签: chipmunkpymunk

解决方案


调试绘制方法主要用于调试和快速原型制作,因此剔除等更高级的功能不在其实现范围内。

如果您觉得自己受到调试绘图的限制,那么可能是时候转换到您自己的绘图代码了,您可以在其中完全控制。自己模拟调试绘图应该很容易,一些示例代码进行自定义绘图。


推荐阅读