Esempio n. 1
0
        public static void WhatHappensNext(PhysicsObject physicsObject, GridManager gridManager, EventManager eventManager, double endTime)
        {
            var couldHits = physicsObject.AddToGrid(gridManager);

            var nextStep = Math.Min(endTime, physicsObject.Time + (gridManager.stepSize / physicsObject.Speed));

            foreach (var couldHit in couldHits)
            {
                if (physicsObject != couldHit && physicsObject.TryNextCollision(couldHit, nextStep, out var collision))
                {
                    eventManager.AddEvent(collision);
                }
            }

            // we put in move events even if it is not moving so we update times
            if (physicsObject.Mobile && physicsObject.Time < endTime)
            {
                eventManager.AddMoveEvent(nextStep, physicsObject);
            }
        }
Esempio n. 2
0
 public void AddObject(PhysicsObject physicsObject)
 {
     items.Add(physicsObject);
     physicsObject.AddToGrid(gridManager);
 }