コード例 #1
0
    public bool IntersectsOBB(VCollisionBox b)
    {
        base.ConditionalUpdateShape();
        b.ConditionalUpdateShape();
        long num = (long)(this.worldRadius + b.worldRadius);

        if ((this.worldPos - b.worldPos).get_sqrMagnitudeLong() > num * num)
        {
            return(false);
        }
        VInt3 vInt  = new VInt3(IntMath.Divide(VInt3.Dot(ref this.axis[0], ref b.axis[0]), 1000), IntMath.Divide(VInt3.Dot(ref this.axis[0], ref b.axis[1]), 1000), IntMath.Divide(VInt3.Dot(ref this.axis[0], ref b.axis[2]), 1000));
        VInt3 vInt2 = new VInt3(IntMath.Divide(VInt3.Dot(ref this.axis[1], ref b.axis[0]), 1000), IntMath.Divide(VInt3.Dot(ref this.axis[1], ref b.axis[1]), 1000), IntMath.Divide(VInt3.Dot(ref this.axis[1], ref b.axis[2]), 1000));
        VInt3 vInt3 = new VInt3(IntMath.Divide(VInt3.Dot(ref this.axis[2], ref b.axis[0]), 1000), IntMath.Divide(VInt3.Dot(ref this.axis[2], ref b.axis[1]), 1000), IntMath.Divide(VInt3.Dot(ref this.axis[2], ref b.axis[2]), 1000));
        VInt3 abs   = vInt.get_abs();
        VInt3 abs2  = vInt2.get_abs();
        VInt3 abs3  = vInt3.get_abs();
        VInt3 vInt4 = b.worldPos - this.worldPos;

        vInt4 = new VInt3(IntMath.Divide(VInt3.Dot(ref vInt4, ref this.axis[0]), 1000), IntMath.Divide(VInt3.Dot(ref vInt4, ref this.axis[1]), 1000), IntMath.Divide(VInt3.Dot(ref vInt4, ref this.axis[2]), 1000));
        int num2 = this.worldExtends.x * 1000;
        int num3 = VInt3.Dot(ref b.worldExtends, ref abs);

        if (Mathf.Abs(vInt4.x) * 1000 > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.y * 1000;
        num3 = VInt3.Dot(ref b.worldExtends, ref abs2);
        if (Mathf.Abs(vInt4.y) * 1000 > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.z * 1000;
        num3 = VInt3.Dot(ref b.worldExtends, ref abs3);
        if (Mathf.Abs(vInt4.z) * 1000 > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs.x + this.worldExtends.y * abs2.x + this.worldExtends.z * abs3.x;
        num3 = b.worldExtends.x * 1000;
        if (Math.Abs(vInt4.x * vInt.x + vInt4.y * vInt2.x + vInt4.z * vInt3.x) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs.y + this.worldExtends.y * abs2.y + this.worldExtends.z * abs3.y;
        num3 = b.worldExtends.y * 1000;
        if (Math.Abs(vInt4.x * vInt.y + vInt4.y * vInt2.y + vInt4.z * vInt3.y) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs.z + this.worldExtends.y * abs2.z + this.worldExtends.z * abs3.z;
        num3 = b.worldExtends.z * 1000;
        if (Math.Abs(vInt4.x * vInt.z + vInt4.y * vInt2.z + vInt4.z * vInt3.z) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.y * abs3.x + this.worldExtends.z * abs2.x;
        num3 = b.worldExtends.y * abs.z + b.worldExtends.z * abs.y;
        if (Mathf.Abs(vInt4.z * vInt2.x - vInt4.y * vInt3.x) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.y * abs3.y + this.worldExtends.z * abs2.y;
        num3 = b.worldExtends.x * abs.z + b.worldExtends.z * abs.x;
        if (Mathf.Abs(vInt4.z * vInt2.y - vInt4.y * vInt3.y) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.y * abs3.z + this.worldExtends.z * abs2.z;
        num3 = b.worldExtends.x * abs.y + b.worldExtends.y * abs.x;
        if (Mathf.Abs(vInt4.z * vInt2.z - vInt4.y * vInt3.z) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs3.x + this.worldExtends.z * abs.x;
        num3 = b.worldExtends.y * abs2.z + b.worldExtends.z * abs2.y;
        if (Mathf.Abs(vInt4.x * vInt3.x - vInt4.z * vInt.x) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs3.y + this.worldExtends.z * abs.y;
        num3 = b.worldExtends.x * abs2.z + b.worldExtends.z * abs2.x;
        if (Mathf.Abs(vInt4.x * vInt3.y - vInt4.z * vInt.y) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs3.z + this.worldExtends.z * abs.z;
        num3 = b.worldExtends.x * abs2.y + b.worldExtends.y * abs2.x;
        if (Mathf.Abs(vInt4.x * vInt3.z - vInt4.z * vInt.z) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs2.x + this.worldExtends.y * abs.x;
        num3 = b.worldExtends.y * abs3.z + b.worldExtends.z * abs3.y;
        if (Mathf.Abs(vInt4.y * vInt.x - vInt4.x * vInt2.x) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs2.y + this.worldExtends.y * abs.y;
        num3 = b.worldExtends.x * abs3.z + b.worldExtends.z * abs3.x;
        if (Mathf.Abs(vInt4.y * vInt.y - vInt4.x * vInt2.y) > num2 + num3)
        {
            return(false);
        }
        num2 = this.worldExtends.x * abs2.z + this.worldExtends.y * abs.z;
        num3 = b.worldExtends.x * abs3.y + b.worldExtends.y * abs3.x;
        return(Mathf.Abs(vInt4.y * vInt.z - vInt4.x * vInt2.z) <= num2 + num3);
    }