/// <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)); }
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); }
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; }
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)); }