An axis-aligned bounding box.
Beispiel #1
0
 /// <summary>
 /// Query the world for all fixtures that potentially overlap the provided AABB.
 /// </summary>
 /// <param name="callback">a user implemented callback class.</param>
 /// <param name="aabb">the query box.</param>
 public virtual void queryAABB(QueryCallback callback, AABB aabb)
 {
     wqwrapper.broadPhase = m_contactManager.m_broadPhase;
     wqwrapper.callback = callback;
     m_contactManager.m_broadPhase.query(wqwrapper, aabb);
 }
Beispiel #2
0
 /// <summary>
 /// Copies from the given object
 /// </summary>
 /// <param name="copy">the object to copy from</param>
 public AABB(AABB copy)
     : this(copy.lowerBound, copy.upperBound)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Query the world for all fixtures that potentially overlap the provided AABB.
 /// </summary>
 /// <param name="callback">a user implemented callback class.</param>
 /// <param name="aabb">the query box.</param>
 public void QueryAABB(IQueryCallback callback, AABB aabb)
 {
     wqwrapper.BroadPhase = ContactManager.BroadPhase;
     wqwrapper.Callback = callback;
     ContactManager.BroadPhase.Query(wqwrapper, aabb);
 }
Beispiel #4
0
 /// <summary>
 /// Does this aabb contain the provided AABB.
 /// </summary>
 /// <returns></returns>
 public bool contains(AABB aabb)
 {
     /*
     * boolean result = true; result = result && lowerBound.x <= aabb.lowerBound.x; result = result
     * && lowerBound.y <= aabb.lowerBound.y; result = result && aabb.upperBound.x <= upperBound.x;
     * result = result && aabb.upperBound.y <= upperBound.y; return result;
     */
     // djm: faster putting all of them together, as if one is false we leave the logic
     // early
     return lowerBound.x > aabb.lowerBound.x && lowerBound.y > aabb.lowerBound.y && aabb.upperBound.x > upperBound.x && aabb.upperBound.y > upperBound.y;
 }
Beispiel #5
0
 /// <summary>
 /// Sets this object from the given object
 /// </summary>
 /// <param name="aabb">the object to copy from</param>
 public void set_Renamed(AABB aabb)
 {
     Vec2 v = aabb.lowerBound;
     lowerBound.x = v.x;
     lowerBound.y = v.y;
     Vec2 v1 = aabb.upperBound;
     upperBound.x = v1.x;
     upperBound.y = v1.y;
 }
Beispiel #6
0
 /// <summary>
 /// Combine two AABBs into this one.
 /// </summary>
 /// <param name="aabb1"></param>
 /// <param name="aab"></param>
 public void combine(AABB aabb1, AABB aab)
 {
     lowerBound.x = aabb1.lowerBound.x < aab.lowerBound.x ? aabb1.lowerBound.x : aab.lowerBound.x;
     lowerBound.y = aabb1.lowerBound.y < aab.lowerBound.y ? aabb1.lowerBound.y : aab.lowerBound.y;
     upperBound.x = aabb1.upperBound.x > aab.upperBound.x ? aabb1.upperBound.x : aab.upperBound.x;
     upperBound.y = aabb1.upperBound.y > aab.upperBound.y ? aabb1.upperBound.y : aab.upperBound.y;
 }
Beispiel #7
0
 /// <summary>
 /// Combines another aabb with this one
 /// </summary>
 /// <param name="aabb"></param>
 public void combine(AABB aabb)
 {
     lowerBound.x = lowerBound.x < aabb.lowerBound.x ? lowerBound.x : aabb.lowerBound.x;
     lowerBound.y = lowerBound.y < aabb.lowerBound.y ? lowerBound.y : aabb.lowerBound.y;
     upperBound.x = upperBound.x > aabb.upperBound.x ? upperBound.x : aabb.upperBound.x;
     upperBound.y = upperBound.y > aabb.upperBound.y ? upperBound.y : aabb.upperBound.y;
 }
Beispiel #8
0
 /// <summary>
 /// Copies from the given object
 /// </summary>
 /// <param name="copy">the object to copy from</param>
 public AABB(AABB copy)
     : this(copy.LowerBound, copy.UpperBound)
 {
 }
Beispiel #9
0
        public static bool testOverlap(AABB a, AABB b)
        {
            if (b.lowerBound.x - a.upperBound.x > 0.0f || b.lowerBound.y - a.upperBound.y > 0.0f)
            {
                return false;
            }

            if (a.lowerBound.x - b.upperBound.x > 0.0f || a.lowerBound.y - b.upperBound.y > 0.0f)
            {
                return false;
            }

            return true;
        }
Beispiel #10
0
 /// <summary>
 /// Sets this object from the given object
 /// </summary>
 /// <param name="aabb">the object to copy from</param>
 public void Set(AABB aabb)
 {
     Vec2 v = aabb.LowerBound;
     LowerBound.X = v.X;
     LowerBound.Y = v.Y;
     Vec2 v1 = aabb.UpperBound;
     UpperBound.X = v1.X;
     UpperBound.Y = v1.Y;
 }
Beispiel #11
0
 /// <summary>
 /// Does this aabb contain the provided AABB.
 /// </summary>
 /// <returns></returns>
 public bool Contains(AABB aabb)
 {
     /*
     * boolean result = true; result = result && lowerBound.x <= aabb.lowerBound.x; result = result
     * && lowerBound.y <= aabb.lowerBound.y; result = result && aabb.upperBound.x <= upperBound.x;
     * result = result && aabb.upperBound.y <= upperBound.y; return result;
     */
     // djm: faster putting all of them together, as if one is false we leave the logic
     // early
     return LowerBound.X > aabb.LowerBound.X && LowerBound.Y > aabb.LowerBound.Y && aabb.UpperBound.X > UpperBound.X && aabb.UpperBound.Y > UpperBound.Y;
 }
Beispiel #12
0
 /// <summary>
 /// Combines another aabb with this one
 /// </summary>
 /// <param name="aabb"></param>
 public void Combine(AABB aabb)
 {
     LowerBound.X = LowerBound.X < aabb.LowerBound.X ? LowerBound.X : aabb.LowerBound.X;
     LowerBound.Y = LowerBound.Y < aabb.LowerBound.Y ? LowerBound.Y : aabb.LowerBound.Y;
     UpperBound.X = UpperBound.X > aabb.UpperBound.X ? UpperBound.X : aabb.UpperBound.X;
     UpperBound.Y = UpperBound.Y > aabb.UpperBound.Y ? UpperBound.Y : aabb.UpperBound.Y;
 }
Beispiel #13
0
 /// <summary>
 /// Combine two AABBs into this one.
 /// </summary>
 /// <param name="aabb1"></param>
 /// <param name="aab"></param>
 public void Combine(AABB aabb1, AABB aab)
 {
     LowerBound.X = aabb1.LowerBound.X < aab.LowerBound.X ? aabb1.LowerBound.X : aab.LowerBound.X;
     LowerBound.Y = aabb1.LowerBound.Y < aab.LowerBound.Y ? aabb1.LowerBound.Y : aab.LowerBound.Y;
     UpperBound.X = aabb1.UpperBound.X > aab.UpperBound.X ? aabb1.UpperBound.X : aab.UpperBound.X;
     UpperBound.Y = aabb1.UpperBound.Y > aab.UpperBound.Y ? aabb1.UpperBound.Y : aab.UpperBound.Y;
 }
Beispiel #14
0
        public static bool TestOverlap(AABB a, AABB b)
        {
            if (b.LowerBound.X - a.UpperBound.X > 0.0f || b.LowerBound.Y - a.UpperBound.Y > 0.0f)
            {
                return false;
            }

            if (a.LowerBound.X - b.UpperBound.X > 0.0f || a.LowerBound.Y - b.UpperBound.Y > 0.0f)
            {
                return false;
            }

            return true;
        }