cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

Intersection detection for Physics

Open smallmain opened this issue 1 month ago • 0 comments

Use Case

Intersection2D geometry.intersect

只有与形状进行相交检测的函数,缺少与 Collider 之间进行相交检测的函数。

一些理由:

  • 建立一条射线之后,我想要只测试是否击中了某个 Collider,使用 raycast 之类的函数感觉可能性能太低。
  • 当然,自己可以封装函数,但我觉得这个功能算是比较常用,也属于基础设施,应该内置于引擎。
  • 由于需要通过判断 Collider 是哪种形状的碰撞器来实现这个功能,用户封装的代码会在引擎增加新的碰撞器、删除旧的碰撞器时过时。

API 设计:

  • 可能是放在 PhysicsSystem 里与当前 intersect 类中所有方法相等的一系列方法。
  • 或者是在 Collider 增加一个 geometry 属性,或者一个 toGeometry(collider) 工具方法。

Problem Description

.

Proposed Solution

No response

How it works

No response

Alternatives Considered

.

Additional Information

No response

smallmain avatar Jun 05 '24 01:06 smallmain