Beispiel #1
0
 /// <summary>
 /// Add a constraint to the physics world. A constraint may affect one or two bodies.
 /// </summary>
 /// <param name="constraint">The constraint to add.</param>
 public void Add(Constraint constraint)
 {
     if (constraint.Manager != null)
         throw new ArgumentException("Constraint is already managed by a physics implementation.");
     if (constraint.BodyA != null) constraint.BodyA.Constraints.Add(constraint);
     if (constraint.BodyB != null) constraint.BodyB.Constraints.Add(constraint);
     constraint.Manager = this;
 }
Beispiel #2
0
 /// <summary>
 /// Removes a constraint from the physics world.
 /// </summary>
 /// <param name="constraint">The constraint to remove.</param>
 /// <returns>Returns a value indicating whether the constraint was successfully removed.</returns>
 public bool Remove(Constraint constraint)
 {
     bool removed = false;
     if (constraint.BodyA != null) removed |= constraint.BodyA.Constraints.Remove(constraint);
     if (constraint.BodyB != null) removed |= constraint.BodyB.Constraints.Remove(constraint);
     constraint.Manager = null;
     return removed;
 }
 public void Add(Constraint constraint)
 {
     physics.Add(constraint);
 }