public void QueryCircle( Vector2 point, float radius, VoltBuffer<VoltBody> outBuffer) { outBuffer.Add(this.bodies, this.count); }
public VoltWorld( int historyLength = 0, float damping = VoltConfig.DEFAULT_DAMPING) { this.HistoryLength = historyLength; this.Damping = damping; this.IterationCount = VoltConfig.DEFAULT_ITERATION_COUNT; this.DeltaTime = VoltConfig.DEFAULT_DELTA_TIME; this.bodies = new CheapList<VoltBody>(); this.manifolds = new List<Manifold>(); this.dynamicBroadphase = new NaiveBroadphase(); this.staticBroadphase = new TreeBroadphase(); this.reusableBuffer = new VoltBuffer<VoltBody>(); this.reusableOutput = new VoltBuffer<VoltBody>(); this.bodyPool = new VoltPool<VoltBody>(); this.circlePool = new VoltPool<VoltShape, VoltCircle>(); this.polygonPool = new VoltPool<VoltShape, VoltPolygon>(); this.contactPool = new VoltPool<Contact>(); this.manifoldPool = new VoltPool<Manifold>(); this.historyPool = new VoltPool<HistoryBuffer>(); }
public void CircleCast( ref VoltRayCast ray, float radius, VoltBuffer<VoltBody> outBuffer) { outBuffer.Add(this.bodies, this.count); }
public void RayCast( ref VoltRayCast ray, VoltBuffer<VoltBody> outBuffer) { outBuffer.Add(this.bodies, this.count); }
public void QueryPoint( Vector2 point, VoltBuffer<VoltBody> outBuffer) { outBuffer.Add(this.bodies, this.count); }
public void QueryOverlap( VoltAABB aabb, VoltBuffer<VoltBody> outBuffer) { outBuffer.Add(this.bodies, this.count); }
private void StartQuery(VoltBuffer<VoltBody> outBuffer) { this.queryStack.Clear(); this.ExpandChild(this.rootId, outBuffer); }
/// <summary> /// Finds all dynamic bodies that overlap with the explosion AABB /// and pass the target filter test. Does not test actual shapes. /// </summary> private void PopulateFiltered( Vector2 origin, float radius, VoltBodyFilter targetFilter, int ticksBehind, ref VoltBuffer<VoltBody> filterBuffer) { if (filterBuffer == null) filterBuffer = new VoltBuffer<VoltBody>(); filterBuffer.Clear(); this.reusableBuffer.Clear(); this.staticBroadphase.QueryCircle(origin, radius, this.reusableBuffer); this.dynamicBroadphase.QueryCircle(origin, radius, this.reusableBuffer); VoltAABB aabb = new VoltAABB(origin, radius); for (int i = 0; i < this.reusableBuffer.Count; i++) { VoltBody body = this.reusableBuffer[i]; if ((targetFilter == null) || targetFilter.Invoke(body)) if (body.QueryAABBOnly(aabb, ticksBehind)) filterBuffer.Add(body); } }
/// <summary> /// If the node is a leaf, we do not test the actual proxy bounding box. /// This is redundant since we will be testing the body's bounding box in /// the first step of the narrowphase, and the two are almost equivalent. /// </summary> private void ExpandChild(int query, VoltBuffer<VoltBody> outBuffer) { if (query != TreeBroadphase.NULL_NODE) { Node node = this.nodes[query]; if (node.IsLeaf) outBuffer.Add(node.body); else this.queryStack.Push(query); } }
private void ExpandNode(Node node, VoltBuffer<VoltBody> outBuffer) { VoltDebug.Assert(node.IsLeaf == false); this.ExpandChild(node.left, outBuffer); this.ExpandChild(node.right, outBuffer); }
public void RayCast( ref VoltRayCast ray, VoltBuffer<VoltBody> outBuffer) { this.StartQuery(outBuffer); while (this.queryStack.Count > 0) { Node node = this.GetNextNode(); if (node.aabb.RayCast(ref ray)) this.ExpandNode(node, outBuffer); } }
public void QueryPoint( Vector2 point, VoltBuffer<VoltBody> outBuffer) { this.StartQuery(outBuffer); while (this.queryStack.Count > 0) { Node node = this.GetNextNode(); if (node.aabb.QueryPoint(point)) this.ExpandNode(node, outBuffer); } }
public void QueryOverlap( VoltAABB aabb, VoltBuffer<VoltBody> outBuffer) { this.StartQuery(outBuffer); while (this.queryStack.Count > 0) { Node node = this.GetNextNode(); if (node.aabb.Intersect(aabb)) this.ExpandNode(node, outBuffer); } }
public void QueryCircle( Vector2 point, float radius, VoltBuffer<VoltBody> outBuffer) { this.StartQuery(outBuffer); while (this.queryStack.Count > 0) { Node node = this.GetNextNode(); if (node.aabb.QueryCircleApprox(point, radius)) this.ExpandNode(node, outBuffer); } }
public void CircleCast( ref VoltRayCast ray, float radius, VoltBuffer<VoltBody> outBuffer) { this.StartQuery(outBuffer); while (this.queryStack.Count > 0) { Node node = this.GetNextNode(); if (node.aabb.CircleCastApprox(ref ray, radius)) this.ExpandNode(node, outBuffer); } }