public void AddBody(SoftBody body) { if (body == null) { throw new ArgumentNullException(nameof(body), "body can't be null."); } if (softbodies.Contains(body)) { throw new ArgumentException("The body was already added to the world.", nameof(body)); } softbodies.Add(body); CollisionSystem.AddEntity(body); Events.RaiseAddedSoftBody(body); foreach (Constraint constraint in body.EdgeSprings) { AddConstraint(constraint); } foreach (var massPoint in body.VertexBodies) { Events.RaiseAddedRigidBody(massPoint); rigidBodies.Add(massPoint); } }
public bool CheckCollision(IBroadphaseEntity rigidBody1, IBroadphaseEntity rigidBody2) { collisionDetected = false; collisionSystem.AddEntity(rigidBody1); collisionSystem.AddEntity(rigidBody2); collisionSystem.CollisionDetected += CollisionSystem_CollisionDetected; collisionSystem.Detect(true); collisionSystem.CollisionDetected -= CollisionSystem_CollisionDetected; collisionSystem.RemoveEntity(rigidBody1); collisionSystem.RemoveEntity(rigidBody2); return(collisionDetected); }
public void AddBody(RigidBody body) { if (body == null) throw new ArgumentNullException("body", "body can't be null."); if (rigidBodies.Contains(body)) throw new ArgumentException("The body was already added to the world.", "body"); events.RaiseAddedRigidBody(body); CollisionSystem.AddEntity(body); rigidBodies.Add(body); }
public void AddEntityToCollisionSystem(ICollidingEntity entity) { _collisionSystem.AddEntity(ref entity); }