// BUGGO: Yikes this suddenly broke dramatically when I re-ordered the // constructor arguments for BBox's. I thought I fixed all the instances // where that mattered though! public override Intersection IntersectBBox(BBox other) { var intersectionBBox = bbox.Intersection(other); if (intersectionBBox == null) { return(null); } var contact = intersectionBBox.Center(); // XXX: rather kludgy and approximate; should take into account starting velocity, etc. var dx0 = contact.X - other.Left; var dx1 = other.Right - contact.X; var dx = Math.Min(dx0, dx1); var xside = dx0 < dx1 ? -Vector2d.UnitX : Vector2d.UnitX; var dy0 = contact.Y - other.Bottom; var dy1 = other.Top - contact.Y; var dy = Math.Min(dy0, dy1); var yside = dy0 < dy1 ? Vector2d.UnitY : -Vector2d.UnitY; var ds = Math.Min(dx, dy); var sideNormal = dx < dy ? xside : yside; var flat = dx < dy ? intersectionBBox.Dy : intersectionBBox.Dx; return(new Intersection(contact, sideNormal, 0.5 * ds, -0.5 * ds, flat, -flat)); }