コード例 #1
0
        public bool isCollision(FixedOBB2D obb)
        {
            Vector2d centerdis = m_Center - obb.m_Center;

            //4条检测轴
            Vector2d[] axes =
            {
                m_AxisX,
                m_AxisY,
                obb.m_AxisX,
                obb.m_AxisY,
            };
            long r1, r2, r3;

            for (int i = 0; i < axes.Length; ++i)
            {
                r1 = this.getProjectionRadius(axes[i]);
                r2 = obb.getProjectionRadius(axes[i]);
                r3 = Math.Abs(centerdis.Dot(axes[i]));
                if (r1 + r2 <= r3)
                {
                    //Debug.LogFormat("R1_{0:F}, R2_{1:F}, R:{2:F}, R:{3:F}", r1.ToFloat(), r2.ToFloat(), (r1 + r2).ToFloat(), r3.ToFloat());
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
 public void getOBB2D(ref FixedOBB2D obb)
 {
     obb.update(center.x, center.z, size.x / 2, size.z / 2);
     obb.setRotation(Mathf.Deg2Rad * degreeY);
 }