示例#1
0
        /// <summary>
        /// Returns side of the plane that the given box lies on.
        /// The box is defined as bounds.
        /// </summary>
        /// <param name="bounds">The given bounds.</param>
        /// <returns>The resulting side.</returns>
        public Side GetSide(ref Bounds bounds)
        {
            Vector3 boundsCenter;

            bounds.GetCenter(out boundsCenter);

            //Vec3d boundsHalfSize = boundsCenter - bounds.Minimum;
            Vector3 boundsHalfSize;

            Vector3.Subtract(ref boundsCenter, ref bounds.Minimum, out boundsHalfSize);

            return(GetSide(ref boundsCenter, ref boundsHalfSize));
        }
示例#2
0
            bool BoundsPlanesIntersects(Bounds bounds, Plane[] planes)
            {
                var boundsCenter   = bounds.GetCenter();
                var boundsHalfSize = bounds.Maximum - boundsCenter;

                foreach (var plane in planes)
                {
                    if (plane.GetSide(boundsCenter, boundsHalfSize) == Plane.Side.Positive)
                    {
                        return(false);
                    }
                }
                return(true);
            }
示例#3
0
        public PhysicsConvexSweepTestItem(Matrix4 from, Matrix4 to, int collisionFilterGroup, int collisionFilterMask, ModeEnum mode, Bounds bounds)
        {
            this.originalFrom         = from;
            this.originalTo           = to;
            this.CollisionFilterGroup = collisionFilterGroup;
            this.CollisionFilterMask  = collisionFilterMask;
            this.Mode = mode;

            transformedFrom = originalFrom;
            transformedTo   = originalTo;

            Vector3 offset = bounds.GetCenter();

            if (!offset.Equals(Vector3.Zero, MathEx.Epsilon))
            {
                transformedFrom.SetTranslation(transformedFrom.GetTranslation() + offset);
                transformedTo.SetTranslation(transformedTo.GetTranslation() + offset);
            }

            var halfSize = bounds.GetSize() / 2;

            Shape            = new BulletSharp.BoxShape(BulletPhysicsUtility.Convert(halfSize));
            ShapeAutoDispose = true;
        }
示例#4
0
        public PhysicsContactTestItem(int collisionFilterGroup, int collisionFilterMask, ModeEnum mode, Bounds bounds)
        {
            var geometry = bounds;

            geometry.Expand(0.001);

            var collisionObject = new CollisionObject();

            collisionObject.CollisionShape = new BulletSharp.BoxShape(BulletPhysicsUtility.Convert(bounds.GetSize() * 0.5));
            collisionObject.WorldTransform = BulletPhysicsUtility.Convert(Matrix4.FromTranslate(bounds.GetCenter()));
            Construct(collisionFilterGroup, collisionFilterMask, mode, collisionObject, true, point => geometry.Contains(point));
        }