Exemplo n.º 1
0
        public static bool Check_Sphere_Capsule(Sphere a, Capsule b)
        {
            float dis2 = BVMath.Square_Distance_Line_Point(b.Line, a.center);
            float r    = a.r + b.r;

            return(dis2 <= r * r);
        }
Exemplo n.º 2
0
        public static bool Check_Sphere_OBB(Sphere sphere, OBB obb, out Vector3 closestPoint)
        {
            closestPoint = BVMath.ClosetPt_OBB_Point(obb, sphere.center);

            Vector3 v = closestPoint - sphere.center;

            return(Vector3.Dot(v, v) <= sphere.r * sphere.r);
        }
Exemplo n.º 3
0
        public static bool Check_Capsule_Capsule(Capsule a, Capsule b)
        {
            Vector3 p1 = Vector3.zero, p2 = Vector3.zero;
            float   dis2 = BVMath.MinPoints_Line_line(
                new Line(a.a, a.b),
                new Line(b.a, b.b), out p1, out p2);
            float r = a.r + b.r;

            return(dis2 <= r * r);
        }
Exemplo n.º 4
0
        //获取最近的面
        public Plane GetClosestPlane(Vector3 point)
        {
            List <Plane> planes = getPlanes();
            Plane        res    = planes[0];
            float        minDis = Math.Abs(BVMath.Distance_Plane_Point(planes[0], point));

            for (int i = 1; i < 6; ++i)
            {
                float Dis = Math.Abs(BVMath.Distance_Plane_Point(planes[i], point));
                if (minDis > Dis)
                {
                    res    = planes[i];
                    minDis = Dis;
                }
            }
            return(res);
        }