Ejemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            if (ConnectedToXpa)
            {
                ///////////// FROM SOLID

                bool update = false;

                if (parent != null)
                {
                    throw new Exception("ConnectedToXpa und Parent geht nicht zusammen");
                }

                if (!physicsObject.Orientation.Equals(xpaRotationBackup))
                {
                    Quaternion xpaRotation = Quaternion.Normalize(Quaternion.Inverse(physicsObject.Orientation));
                    xpaRotationBackup = physicsObject.Orientation;

                    if (!nextRotationChanged)
                    {
                        Debug.Assert(!float.IsNaN(xpaRotation.X));
                        localRotation = xpaRotation;
                    }
                    localRotationAsMatrix = Matrix.CreateFromQuaternion(localRotation);

                    update = true;
                }

                if (!physicsObject.Position.Equals(xpaPositionBackup))
                {
                    Vector3 xpaPosition = physicsObject.Position;
                    xpaPositionBackup = xpaPosition;

                    if (!nextPositionChanged)
                    {
                        Debug.Assert(!float.IsNaN(xpaPosition.X));
                        localPosition = xpaPosition;
                    }
                    localPositionAsMatrix = Matrix.CreateTranslation(localPosition);

                    update = true;
                }

                if (update)
                {
                    RecalculateLocalValues();
                }


                ///////////// TO SOLID

                if (nextPositionChanged)
                {
                    nextPositionChanged    = false;
                    physicsObject.Position = localPosition;
                    Debug.Assert(!float.IsNaN(physicsObject.Position.X));
                }

                if (nextRotationChanged)
                {
                    nextRotationChanged       = false;
                    physicsObject.Orientation = Quaternion.Inverse(localRotation);
                    Debug.Assert(!float.IsNaN(physicsObject.Orientation.X));
                }


                ////// COLLISION EVENTS

                //string mname = "Transformable at " + globalPosition + ": " + collisionEvents.Count + " Collision Events";
                //Helper.Helper.BeginTimeMeasurementDebugOutput(mname);
                while (collisionEvents.Count > 0)
                {
                    QueueableCollisionEvent d = collisionEvents.Dequeue();
                    d.Invoke();
                }
                //Helper.Helper.EndTimeMeasurementDebugOutput(mname);
            }
        }
Ejemplo n.º 2
0
 public void DispatchCollisionEvent(QueueableCollisionEvent d)
 {
     d.Actor.OnCollision(d.Event);
 }
Ejemplo n.º 3
0
 public void AddCollisionEvent(QueueableCollisionEvent e)
 {
     collisionEvents.Enqueue(e);
 }