物理引擎中基于AABB碰撞盒的SAP碰撞检测
作者:互联网
一、碰撞检测中的broad phase中的常见算法
该算在 这篇文章 中有比较简单而准确的描述,由于这里描述的思路并不复杂,但是是所有物理引擎中碰撞检测的入门级功课,所以这里写代码加深下对于该简单算法的理解。同样为了避免链接失效,这个地方拷贝下关键内容:
Let's see what this means using the simplest "flavor" of the SAP algorithms, non-persistent single axis SAP:
- Fill a list called "axisList" with all objects in the world. Sort this list on one axis (here the x-axis) by the begin of the bounding box (Sort by Object.BoundingBox.Min.X, With "Min" and "Max" the vectors defining the bounding box). So you know that the most left point of object5 is more left then the most left point on object6 when you look directly at the X-Axis.
- Create a new temporary list called "activeList". You begin on the left of your axisList, adding the first item to the activeList. Now you have a look at the next item in the axisList and compare it with all items currently in the activeList (at the moment just one): If the new item's left is greater then the current activeList-item right, then remove the activeList-item from the activeList – otherwise report a possible collision between the new axisList-item and the current activeList-item. Add the new item itself to the activeList and continue with the next item in the axisList.
标签:box,item,activeList,AABB,iter,碰撞检测,int,SAP,miMin 来源: https://www.cnblogs.com/tsecer/p/10488022.html