Ejemplo n.º 1
0
 /// <summary>
 /// Gets a reference to the properties associated with a body's handle.
 /// </summary>
 /// <param name="bodyHandle">Body handle to retrieve the properties for.</param>
 /// <returns>Reference to properties associated with a body handle.</returns>
 public ref T this[BodyHandle bodyHandle]
 {
     [MethodImpl(MethodImplOptions.AggressiveInlining)]
     get
     {
         Debug.Assert(simulation.Bodies.BodyExists(bodyHandle));
         return(ref bodyData[bodyHandle.Value]);
     }
 }
Ejemplo n.º 2
0
 public ref T Allocate(BodyHandle bodyHandle)
 {
     Debug.Assert(simulation.Bodies.BodyExists(bodyHandle), "The body handle should have been allocated in the bodies set before any attempt to create a property for it.");
     if (bodyHandle.Value >= bodyData.Length)
     {
         var targetCount = BufferPool.GetCapacityForCount <T>(simulation.Bodies.HandlePool.HighestPossiblyClaimedId + 1);
         Debug.Assert(targetCount > bodyData.Length, "Given what just happened, we must require a resize.");
         pool.ResizeToAtLeast(ref bodyData, targetCount, Math.Min(simulation.Bodies.HandlePool.HighestPossiblyClaimedId + 1, bodyData.Length));
     }
     return(ref bodyData[bodyHandle.Value]);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructs a new body reference.
 /// </summary>
 /// <param name="handle">Handle of the body to refer to.</param>
 /// <param name="bodies">Collection containing the body.</param>
 public BodyReference(BodyHandle handle, Bodies bodies)
 {
     Handle = handle;
     Bodies = bodies;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Wakes up a body if it is sleeping. All bodies that can be found by traversing the constraint graph from the body will also be awakened.
 /// If the body is already awake, this does nothing.
 /// </summary>
 /// <param name="bodyHandle">Handle of the body to awaken.</param>
 public void AwakenBody(BodyHandle bodyHandle)
 {
     bodies.ValidateExistingHandle(bodyHandle);
     AwakenSet(bodies.HandleToLocation[bodyHandle.Value].SetIndex);
 }
Ejemplo n.º 5
0
 public int GetBodyReference(Bodies bodies, BodyHandle bodyHandle)
 {
     ref var bodyLocation = ref bodies.HandleToLocation[bodyHandle.Value];