public BroadPhaseTest() { BroadPhase.IsValidate = true; //srand(888); AABB worldAABB = new AABB(); worldAABB.LowerBound.Set(-5.0f * k_extent, -5.0f * k_extent); worldAABB.UpperBound.Set(5.0f * k_extent, 5.0f * k_extent); _overlapCount = 0; _overlapCountExact = 0; _callback._test = this; _broadPhase = new BroadPhase(worldAABB, _callback); for (int i = 0; i < k_actorCount; i++) { _overlaps[i] = new bool[k_actorCount]; } for (int i = 0; i < k_actorCount; i++) { for (int j = 0; j < k_actorCount; j++) { _overlaps[i][j] = false; } } for (int i = 0; i < k_actorCount; i++) { _actors[i] = new Actor(); } for (int i = 0; i < k_actorCount; ++i) { bool s = false; if (i == 91) { s = true; } Actor actor = _actors[i]; GetRandomAABB(ref actor.aabb); //actor->aabb.minVertex.Set(0.0f, 0.0f); //actor->aabb.maxVertex.Set(k_width, k_width); actor.proxyId = _broadPhase.CreateProxy(actor.aabb, actor); actor.overlapCount = 0; _broadPhase.Validate(); } _automated = true; _stepCount = 0; }
// These support body activation/deactivation. public void CreateProxies(BroadPhase broadPhase, Transform xf) { Debug.Assert(ProxyCount == 0); // Create proxies in the broad-phase. ProxyCount = Shape.ChildCount; for (int i = 0; i < ProxyCount; ++i) { FixtureProxy proxy = Proxies[i]; Shape.ComputeAABB(proxy.AABB, xf, i); proxy.ProxyId = broadPhase.CreateProxy(proxy.AABB, proxy); proxy.Fixture = this; proxy.ChildIndex = i; } }
private void CreateProxy() { Random rnd = new Random(888); for (int i = 0; i < k_actorCount; ++i) { int j = (rnd.Next() % k_actorCount); Actor actor = _actors[j]; if (actor.proxyId == PairManager.NullProxy) { actor.overlapCount = 0; GetRandomAABB(ref actor.aabb); actor.proxyId = _broadPhase.CreateProxy(actor.aabb, actor); return; } } }
internal void RefilterProxy(BroadPhase broadPhase, XForm transform) { if (_proxyId == PairManager.NullProxy) { return; } broadPhase.DestroyProxy(_proxyId); AABB aabb; _shape.ComputeAABB(out aabb, transform); bool inRange = broadPhase.InRange(aabb); _proxyId = inRange ? broadPhase.CreateProxy(aabb, this) : PairManager.NullProxy; }
// These support body activation/deactivation. internal void CreateProxies(BroadPhase broadPhase, ref Transform xf) { Debug.Assert(ProxyCount == 0); // Create proxies in the broad-phase. ProxyCount = Shape.ChildCount; for (int i = 0; i < ProxyCount; ++i) { FixtureProxy proxy = Proxies[i]; Shape.ComputeAABB(out proxy.AABB, ref xf, i); proxy.Fixture = this; proxy.ChildIndex = i; proxy.ProxyId = broadPhase.CreateProxy(ref proxy.AABB, ref proxy); Proxies[i] = proxy; } }
// We need separation create/destroy functions from the constructor/destructor because // the destructor cannot access the allocator or broad-phase (no destructor arguments allowed by C++). public void Create(BroadPhase broadPhase, Body body, Transform xf, FixtureDef def) { UserData = def.UserData; Friction = def.Friction; Restitution = def.Restitution; Body = body; _next = null; Filter = def.Filter; IsSensor = def.IsSensor; Shape = def.Shape.Clone(); Shape.ComputeMass(out _massData, def.Density); // Create proxy in the broad-phase. Shape.ComputeAABB(out Aabb, ref xf); ProxyId = broadPhase.CreateProxy(Aabb, this); }
internal void RefilterProxy(BroadPhase broadPhase, Transform Transform) { if (_proxyId == PairManager.NullProxy) { return; } broadPhase.DestroyProxy(_proxyId); AABB aabb; _shape.ComputeAABB(out aabb, Transform); bool inRange = broadPhase.InRange(aabb); if (inRange) { _proxyId = broadPhase.CreateProxy(aabb, this); } else { _proxyId = PairManager.NullProxy; } }
/// <summary> /// Refilters the proxy using the specified broad phase /// </summary> /// <param name="broadPhase">The broad phase</param> /// <param name="transform">The transform</param> internal void RefilterProxy(BroadPhase broadPhase, XForm transform) { if (ProxyId == PairManager.NullProxy) { return; } broadPhase.DestroyProxy(ProxyId); Aabb aabb; Shape.ComputeAabb(out aabb, transform); bool inRange = broadPhase.InRange(aabb); if (inRange) { ProxyId = broadPhase.CreateProxy(aabb, this); } else { ProxyId = PairManager.NullProxy; } }
public void Create(BroadPhase broadPhase, Body body, Transform xf, FixtureDef def) { UserData = def.UserData; Friction = def.Friction; Restitution = def.Restitution; Density = def.Density; _body = body; _next = null; Filter = def.Filter; _isSensor = def.IsSensor; _type = def.Type; // Allocate and initialize the child shape. switch (_type) { case ShapeType.CircleShape: { CircleShape circle = new CircleShape(); CircleDef circleDef = (CircleDef)def; circle._position = circleDef.LocalPosition; circle._radius = circleDef.Radius; _shape = circle; } break; case ShapeType.PolygonShape: { PolygonShape polygon = new PolygonShape(); PolygonDef polygonDef = (PolygonDef)def; polygon.Set(polygonDef.Vertices, polygonDef.VertexCount); _shape = polygon; } break; case ShapeType.EdgeShape: { EdgeShape edge = new EdgeShape(); EdgeDef edgeDef = (EdgeDef)def; edge.Set(edgeDef.Vertex1, edgeDef.Vertex2); _shape = edge; } break; default: Box2DNetDebug.Assert(false); break; } // Create proxy in the broad-phase. AABB aabb; _shape.ComputeAABB(out aabb, xf); bool inRange = broadPhase.InRange(aabb); // You are creating a shape outside the world box. Box2DNetDebug.Assert(inRange); if (inRange) { _proxyId = broadPhase.CreateProxy(aabb, this); } else { _proxyId = PairManager.NullProxy; } }
// We need separation create/destroy functions from the ructor/destructor because // the destructor cannot access the allocator or broad-phase (no destructor arguments allowed by C++). internal void Create(BroadPhase broadPhase, Body body, ref XForm xf, FixtureDef def) { _userData = def.userData; _friction = def.friction; _restitution = def.restitution; _density = def.density; _body = body; _next = null; _filter = def.filter; _isSensor = def.isSensor; _shape = def.shape.Clone(); // Create proxy in the broad-phase. AABB aabb; _shape.ComputeAABB(out aabb, ref xf); _proxyId = broadPhase.CreateProxy(ref aabb, this); }
// These support body activation/deactivation. internal void CreateProxies(BroadPhase broadPhase, ref Transform xf) { Debug.Assert(ProxyCount == 0); // Create proxies in the broad-phase. ProxyCount = Shape.ChildCount; for (int i = 0; i < ProxyCount; ++i) { FixtureProxy proxy = Proxies[i]; Shape.ComputeAABB(out proxy.AABB, ref xf, i); proxy.Fixture = this; proxy.ChildIndex = i; proxy.ProxyId = broadPhase.CreateProxy(ref proxy.AABB, ref proxy); Proxies[i] = proxy; } }
// These support body activation/deactivation. internal void CreateProxies(BroadPhase broadPhase, ref Transform xf) { Debug.Assert(_proxyCount == 0); // Create proxies in the broad-phase. _proxyCount = _shape.GetChildCount(); for (int i = 0; i < _proxyCount; ++i) { FixtureProxy proxy = _proxies[i]; _shape.ComputeAABB(out proxy.aabb, ref xf, i); proxy.fixture = this; proxy.childIndex = i; proxy.proxyId = broadPhase.CreateProxy(ref proxy.aabb, proxy); _proxies[i] = proxy; } }
// These support body activation/deactivation. internal void CreateProxies(BroadPhase broadPhase, Transform xf){ //broadPhase was pointer Utilities.Assert(m_proxies.Count() == 0); // Create proxies in the broad-phase. int m_proxyCount = m_shape.GetChildCount(); for (int i = 0; i < m_proxyCount; ++i) { FixtureProxy proxy = new FixtureProxy(); m_shape.ComputeAABB(out proxy.aabb, xf, i); proxy.proxyId = broadPhase.CreateProxy(proxy.aabb, proxy); proxy.fixture = this; proxy.childIndex = i; m_proxies.Add(proxy); } }
// These support body activation/deactivation. internal void CreateProxy(BroadPhase broadPhase, ref Transform xf) { Debug.Assert(_proxyId == BroadPhase.NullProxy); // Create proxy in the broad-phase. _shape.ComputeAABB(out _aabb, ref xf); _proxyId = broadPhase.CreateProxy(ref _aabb, this); }