コード例 #1
0
   public void QueryCircle(
 Vector2 point,
 float radius,
 VoltBuffer<VoltBody> outBuffer)
   {
       outBuffer.Add(this.bodies, this.count);
   }
コード例 #2
0
ファイル: VoltWorld.cs プロジェクト: slawo/VolatilePhysics
        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>();
        }
コード例 #3
0
   public void CircleCast(
 ref VoltRayCast ray,
 float radius,
 VoltBuffer<VoltBody> outBuffer)
   {
       outBuffer.Add(this.bodies, this.count);
   }
コード例 #4
0
   public void RayCast(
 ref VoltRayCast ray,
 VoltBuffer<VoltBody> outBuffer)
   {
       outBuffer.Add(this.bodies, this.count);
   }
コード例 #5
0
   public void QueryPoint(
 Vector2 point,
 VoltBuffer<VoltBody> outBuffer)
   {
       outBuffer.Add(this.bodies, this.count);
   }
コード例 #6
0
   public void QueryOverlap(
 VoltAABB aabb,
 VoltBuffer<VoltBody> outBuffer)
   {
       outBuffer.Add(this.bodies, this.count);
   }
コード例 #7
0
 private void StartQuery(VoltBuffer<VoltBody> outBuffer)
 {
     this.queryStack.Clear();
       this.ExpandChild(this.rootId, outBuffer);
 }
コード例 #8
0
        /// <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);
              }
        }
コード例 #9
0
 /// <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);
       }
 }
コード例 #10
0
 private void ExpandNode(Node node, VoltBuffer<VoltBody> outBuffer)
 {
     VoltDebug.Assert(node.IsLeaf == false);
       this.ExpandChild(node.left, outBuffer);
       this.ExpandChild(node.right, outBuffer);
 }
コード例 #11
0
   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);
         }
   }
コード例 #12
0
   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);
         }
   }
コード例 #13
0
   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);
         }
   }
コード例 #14
0
   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);
         }
   }
コード例 #15
0
   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);
         }
   }