Beispiel #1
0
 public LinearDisplacement(IPhysicControl physicControl, float deltaTime)
 {
     Velocity         = physicControl.Velocity;
     StartingPosition = physicControl.CenterPosition;
     DeltaTime        = deltaTime;
     PhysicObject     = physicControl;
 }
Beispiel #2
0
 public AcceleratedDisplacement(IPhysicControl physicControl, float deltaTime)
 {
     Acceleration     = physicControl.Acceleration;
     StartingPosition = physicControl.CenterPosition;
     DeltaTime        = deltaTime;
     PhysicControl    = physicControl;
 }
Beispiel #3
0
        public FastestCollision DoTheFastestCollision(List <GameObject> MovingGameObjects)
        {
            // Precalculate intersecting areas
            var PossibleCollisionGroups = Booster.CheckAll(MovingGameObjects);

            // 2. For each intersecting area calculate precise collision details, if any

            FastestCollision  fastestCollision = null;
            CollisionResponse collisionResponse;

            foreach (var TestingGroup in PossibleCollisionGroups)
            {
                foreach (var testing in TestingGroup.GetPossibleCollidingObjects())
                {
                    IPhysicControl SecondCrossTest        = testing.GetSecondary();
                    var            PrimaryDisplacements   = testing.GetPrimary().GetDisplacements();
                    var            SecondaryDisplacements = SecondCrossTest.GetDisplacements();

                    CollisionSimplifiedScenario Scenario;

                    Scenario = DisplacementSimplifier.Simplify
                                   (PrimaryDisplacements, SecondaryDisplacements);

                    if (Scenario == null)
                    {
                        continue;
                    }

                    collisionResponse = CollisionStrategy.Test(Scenario);

                    if (collisionResponse != null)
                    {
                        if (fastestCollision == null || fastestCollision.CollisionDeltaTime > collisionResponse.CollisionDeltaTime)
                        {
                            fastestCollision = new FastestCollision(
                                collisionResponse, SecondCrossTest.GameObject
                                );
                        }
                    }
                }
            }


            if (fastestCollision != null)
            {
                fastestCollision.GameObject.Hit(fastestCollision.CollisionResponse);
            }

            return(fastestCollision);
        }
Beispiel #4
0
 public CollidingObjects(IPhysicControl primaryObject, IPhysicControl secondaryObject)
 {
     PrimaryObject   = primaryObject;
     SecondaryObject = secondaryObject;
 }
Beispiel #5
0
 public GameObject(IPhysicControl PhysicRidgidBody) : this()
 {
     kinematicBody = PhysicRidgidBody;
     OnKinematicChange();
 }