コード例 #1
0
ファイル: World.cs プロジェクト: fxredeemer/jitterphysics
        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);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public void AddEntityToCollisionSystem(ICollidingEntity entity)
 {
     _collisionSystem.AddEntity(ref entity);
 }