/// <summary> /// Create a new instance of the <see cref="World"/> class. /// </summary> /// <param name="collision">The collisionSystem which is used to detect /// collisions. See for example: <see cref="CollisionSystemSAP"/> /// or <see cref="CollisionSystemBrute"/>. /// </param> public World(CollisionSystem collision) { if (collision == null) { throw new ArgumentNullException("The CollisionSystem can't be null.", "collision"); } arbiterCallback = new Action <object>(ArbiterCallback); integrateCallback = new Action <object>(IntegrateCallback); // Create the readonly wrappers this.RigidBodies = new ReadOnlyHashset <RigidBody>(rigidBodies); this.Constraints = new ReadOnlyHashset <Constraint>(constraints); this.SoftBodies = new ReadOnlyHashset <SoftBody>(softbodies); this.CollisionSystem = collision; collisionDetectionHandler = new CollisionDetectedHandler(CollisionDetected); this.CollisionSystem.CollisionDetected += collisionDetectionHandler; this.arbiterMap = new ArbiterMap(); AllowDeactivation = true; }
public World(CollisionSystem collision) { CollisionSystem = collision ?? throw new ArgumentNullException("The CollisionSystem can't be null.", nameof(collision)); arbiterCallback = new Action <object>(ArbiterCallback); integrateCallback = new Action <object>(IntegrateCallback); RigidBodies = new ReadOnlyHashset <RigidBody>(rigidBodies); Constraints = new ReadOnlyHashset <Constraint>(constraints); SoftBodies = new ReadOnlyHashset <SoftBody>(softbodies); collisionDetectionHandler = new CollisionDetectedHandler(CollisionDetected); CollisionSystem.CollisionDetected += collisionDetectionHandler; ArbiterMap = new ArbiterMap(); AllowDeactivation = true; }
public World(CollisionSystem collision) { if (collision == null) throw new ArgumentNullException("collision", "The CollisionSystem can't be null."); arbiterCallback = ArbiterCallback; integrateCallback = IntegrateCallback; RigidBodies = new ReadOnlyHashset<RigidBody>(rigidBodies); Constraints = new ReadOnlyHashset<Constraint>(constraints); SoftBodies = new ReadOnlyHashset<SoftBody>(softbodies); CollisionSystem = collision; collisionDetectionHandler = CollisionDetected; CollisionSystem.CollisionDetected += collisionDetectionHandler; arbiterMap = new ArbiterMap(); AllowDeactivation = true; }
/// <summary> /// Create a new instance of the <see cref="World"/> class. /// </summary> /// <param name="collision">The collisionSystem which is used to detect /// collisions. See for example: <see cref="CollisionSystemSAP"/> /// or <see cref="CollisionSystemBrute"/>. /// </param> public World(CollisionSystem system) { Debug.Assert(system != null, "Collision system can't be null."); Arbiter.World = this; arbiterCallback = ArbiterCallback; integrateCallback = IntegrateCallback; // Create the readonly wrappers this.RigidBodies = new ReadOnlyHashset <RigidBody>(rigidBodies); this.Constraints = new ReadOnlyHashset <Constraint>(constraints); this.SoftBodies = new ReadOnlyHashset <SoftBody>(softbodies); this.CollisionSystem = system; collisionDetectionHandler = new CollisionDetectedHandler(CollisionDetected); this.CollisionSystem.CollisionDetected += collisionDetectionHandler; this.arbiterMap = new ArbiterMap(); AllowDeactivation = true; }
public void Clear() { foreach (var body in rigidBodies) { CollisionSystem.RemoveEntity(body); if (body.island != null) { body.island.ClearLists(); body.island = null; } body.connections.Clear(); body.arbiters.Clear(); body.constraints.Clear(); Events.RaiseRemovedRigidBody(body); } foreach (var body in softbodies) { CollisionSystem.RemoveEntity(body); } rigidBodies.Clear(); foreach (var constraint in constraints) { Events.RaiseRemovedConstraint(constraint); } constraints.Clear(); softbodies.Clear(); islands.RemoveAll(); ArbiterMap.Clear(); ResetResourcePools(); }
/// <summary> /// Create a new instance of the <see cref="World"/> class. /// </summary> /// <param name="collision">The collisionSystem which is used to detect /// collisions. See for example: <see cref="CollisionSystemSAP"/> /// or <see cref="CollisionSystemBrute"/>. /// </param> public World(CollisionSystem collision) { if (collision == null) throw new ArgumentNullException("The CollisionSystem can't be null.", "collision"); arbiterCallback = new Action<object>(ArbiterCallback); integrateCallback = new Action<object>(IntegrateCallback); // Create the readonly wrappers this.RigidBodies = new ReadOnlyHashset<RigidBody>(rigidBodies); this.Constraints = new ReadOnlyHashset<Constraint>(constraints); this.SoftBodies = new ReadOnlyHashset<SoftBody>(softbodies); this.CollisionSystem = collision; collisionDetectionHandler = new CollisionDetectedHandler(CollisionDetected); this.CollisionSystem.CollisionDetected += collisionDetectionHandler; this.arbiterMap = new ArbiterMap(); AllowDeactivation = true; }