chipmunk - 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:
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()
.
解决方案
调试绘制方法主要用于调试和快速原型制作,因此剔除等更高级的功能不在其实现范围内。
如果您觉得自己受到调试绘图的限制,那么可能是时候转换到您自己的绘图代码了,您可以在其中完全控制。自己模拟调试绘图应该很容易,一些示例代码进行自定义绘图。
推荐阅读
- javascript - 如何将时间数组转换为 24 小时格式
- javascript - Express.js 显示未定义的 req.body,其中路由从其他文件重新组合
- java - 如何从给定范围加载日期数组?
- java - java.lang.ClassNotFoundException:用于 Spark 3.0.0 的 org.apache.spark.sql.sources.v2.DataSourceV2
- regex - 使用正则表达式进行 DART 条件查找和替换
- java-8 - 在 Netbeans 中运行项目时如何抑制错误的“Java 版本已过期消息”
- python - 如何在python中将base64字节转换为图像
- javascript - 如何让 async/await 真正等待
- r - 如果另一个变量的下一行满足条件,则定义新变量取 1
- python - Python 类如何在没有在类定义中声明的情况下拥有一个新属性?