Solaestas / Everglow

GNU General Public License v3.0
29 stars 4 forks source link

Common/collision source #253

Closed shb201902040125 closed 5 months ago

shb201902040125 commented 6 months ago

基于SAT/GJK的碰撞以及凸形三角剖分 用于较高精度检测实体碰撞(未添加物块判定支持) 性能也许可以优化,但我不建议使用此代码库进行多实体碰撞判定(低精度需求时性价比不如Rectangle的AABB) 具有对于XNA的Rectangle到Shape的Rectangle的显式转换 支持圆形,三角形,矩形,任意点集到常规凸形的转换 支持线与线的碰撞判定 少边图形应优先选择SAT,多边图形在选择GJK 可以通过EPA获取多边形的重合区

shb201902040125 commented 6 months ago

基于SAT/GJK的碰撞以及凸形三角剖分 用于较高精度检测实体碰撞(未添加物块判定支持) 性能也许可以优化,但我不建议使用此代码库进行多实体碰撞判定(低精度需求时性价比不如Rectangle的AABB) 具有对于XNA的Rectangle到Shape的Rectangle的显式转换 支持圆形,三角形,矩形,任意点集到常规凸形的转换 支持线与线的碰撞判定 少边图形应优先选择SAT,多边图形在选择GJK 可以通过EPA获取多边形的重合区

For Set6: Collision Detection and Convex Triangulation Based on SAT/GJK

This code is designed for high-precision collision detection of entities (without support for Tile block detection). While performance can potentially be optimized, I do not recommend using this code library for multi-entity collision detection (for low-precision requirements, AABBs with rectangles are more cost-effective).

Features:

Explicit conversion from XNA’s Rectangle to a custom Shape rectangle. Supports conversion from circles, triangles, rectangles, and arbitrary point sets to regular convex shapes. Provides collision detection between lines. For shapes with fewer edges, prefer SAT (Separating Axis Theorem); for more complex polygons, consider GJK (Gilbert–Johnson–Keerthi algorithm). The EPA (Expanding Polytope Algorithm) can be used to obtain the overlapping region of polygons.

Setnour6 commented 5 months ago

Is there an example you can provide on what it looks like in the game? I only see the implementation of what it is in the code but not how exactly it's used, other than the explanation of it.