/// @see Shape::ComputeAABB public override void ComputeAABB(out AABB aabb, Transform xf, int childIndex) { Vec2 v1 = Utilities.Mul(xf, m_vertex1); Vec2 v2 = Utilities.Mul(xf, m_vertex2); Vec2 lower = Utilities.Min(v1, v2); Vec2 upper = Utilities.Max(v1, v2); Vec2 r = new Vec2(m_radius, m_radius); aabb.lowerBound = lower - r; aabb.upperBound = upper + r; }
/// @see Shape::ComputeAABB public override void ComputeAABB(out AABB aabb, Transform xf, int childIndex) { Vec2 lower = Utilities.Mul(xf, m_vertices[0]); Vec2 upper = lower; for (int i = 1; i < m_count; ++i) { Vec2 v = Utilities.Mul(xf, m_vertices[i]); lower = Utilities.Min(lower, v); upper = Utilities.Max(upper, v); } Vec2 r = new Vec2(m_radius, m_radius); aabb.lowerBound = lower - r; aabb.upperBound = upper + r; }
private void MoveAABB(AABB aabb) { Vec2 d; d.X = RandomFloat(-0.5f, 0.5f); d.Y = RandomFloat(-0.5f, 0.5f); //d.X = 2.0f; //d.Y = 0.0f; aabb.lowerBound += d; aabb.upperBound += d; Vec2 c0 = 0.5f * (aabb.lowerBound + aabb.upperBound); Vec2 min = new Vec2(); min.Set(-m_worldExtent, 0.0f); Vec2 max = new Vec2(); max.Set(m_worldExtent, 2.0f * m_worldExtent); Vec2 c = Utilities.Clamp(c0, min, max); aabb.lowerBound += c - c0; aabb.upperBound += c - c0; }
/// @see Shape::ComputeAABB public override void ComputeAABB(out AABB aabb, Transform transform, int childIndex) { throw new NotImplementedException(); //Utilities.Assert(childIndex < m_count); //int i1 = childIndex; //int i2 = childIndex + 1; //if (i2 == m_count) //{ // i2 = 0; //} //Vec2 v1 = Utilities.Mul(xf, m_vertices[i1]); //Vec2 v2 = Utilities.Mul(xf, m_vertices[i2]); //aabb.lowerBound = Math.Min(v1, v2); //aabb.upperBound = Math.Max(v1, v2); }
/// Given a transform, compute the associated axis aligned bounding box for a child shape. /// @param aabb returns the axis aligned box. /// @param xf the world transform of the shape. /// @param childIndex the child shape public abstract void ComputeAABB(out AABB aabb, Transform xf, int childIndex);
private void GetRandomAABB(AABB aabb) { Vec2 w = new Vec2(); w.Set(2.0f * m_proxyExtent, 2.0f * m_proxyExtent); //aabb.lowerBound.X = -m_proxyExtent; //aabb.lowerBound.Y = -m_proxyExtent + m_worldExtent; aabb.lowerBound.X = RandomFloat(-m_worldExtent, m_worldExtent); aabb.lowerBound.Y = RandomFloat(0.0f, 2.0f * m_worldExtent); aabb.upperBound = aabb.lowerBound + w; }
/// Combine two AABBs into this one. public void Combine(AABB aabb1, AABB aab) { lowerBound = Utilities.Min(aabb1.lowerBound, aab.lowerBound); upperBound = Utilities.Max(aabb1.upperBound, aab.upperBound); }
/// Does this aabb contain the provided AABB. public bool Contains(AABB aabb) { bool 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; }
public static bool TestOverlap(AABB a, AABB b) { Vec2 d1, d2; d1 = b.lowerBound - a.upperBound; d2 = a.lowerBound - b.upperBound; if (d1.X > 0.0f || d1.Y > 0.0f) return false; if (d2.X > 0.0f || d2.Y > 0.0f) return false; return true; }
/// Combine an AABB into this one. public void Combine(AABB aabb) { throw new NotImplementedException(); //lowerBound = Math.Min(lowerBound, aabb.lowerBound); //upperBound = Math.Max(upperBound, aabb.upperBound); }
/// @see Shape::ComputeAABB public override void ComputeAABB(out AABB aabb, Transform transform, int childIndex) { aabb = new AABB(); Vec2 p = transform.p + Utilities.Mul(transform.q, m_p); aabb.lowerBound.Set(p.X - m_radius, p.Y - m_radius); aabb.upperBound.Set(p.X + m_radius, p.Y + m_radius); }
/// Query the world for all fixtures that potentially overlap the /// provided AABB. /// @param callback a user implemented callback class. /// @param aabb the query box. public void QueryAABB(QueryCallback callback, AABB aabb){ throw new NotImplementedException(); //WorldQueryWrapper wrapper; //wrapper.broadPhase = &m_contactManager.m_broadPhase; //wrapper.callback = callback; //m_contactManager.m_broadPhase.Query(&wrapper, aabb); }
/// Query an AABB for overlapping proxies. The callback class /// is called for each proxy that overlaps the supplied AABB. public void Query(Func <int, bool> callback, AABB aabb) { m_tree.Query(callback, aabb); }
internal void DrawAABB(AABB AABB, Color c) { this.DrawPolygon(new Vec2[] { AABB.lowerBound, new Vec2(AABB.lowerBound.X, AABB.upperBound.Y), AABB.upperBound, new Vec2(AABB.upperBound.X, AABB.lowerBound.Y)}, 4, c); }
/// Get the fixture's AABB. This AABB may be enlarge and/or stale. /// If you need a more accurate AABB, compute it using the Shape and /// the body transform. public void GetAABB(out AABB aabb, int childIndex) { //Debug.Assert(0 <= childIndex && childIndex < _proxyCount); aabb = _proxies[childIndex].aabb; }