Exemple #1
0
 void GhostSimulateBody(GhostLSBody ghost)
 {
     //Only simulate stuff that doesn't affect lockstep simulation
     ghost._SimVelocity();
     ghost.BuildChangedValues();
     ghost._SimVisualsCounter();
 }
 public void Initialize(Vector3d StartPosition, Vector2d StartRotation, bool isDynamic = true)
 {
     if (_internalBody.IsNull())
     {
         _internalBody = new GhostLSBody();
     }
     InternalBody.InitializeGhost(StartPosition, StartRotation, isDynamic);
 }
 void Reset()
 {
     if (InternalBody.IsNull())
     {
         _internalBody = new GhostLSBody();
     }
     InternalBody.transform = this.transform;
     InternalBody.Reset();
 }
Exemple #4
0
        void ProcessPair(GhostLSBody ghost, int ID2)
        {
            var pair = GetCollisionPair(ghost, ID2);

            if (pair == null)
            {
                return;
            }
            //CollisionPair.OnlyAffectBody1 should solve simulation-polluting
            pair.CheckAndDistributeCollision();
            pair.NotifyBody1();
        }
Exemple #5
0
        private static CollisionPair GetCollisionPair(GhostLSBody ghost, int ID2)
        {
            LSBody body2;

            if ((body2 = PhysicsManager.SimObjects[ID2]).IsNotNull())
            {
                CollisionPair pair;
                if (!ghost.CollisionPairs.TryGetValue(body2.ID, out pair))
                {
                    pair = new CollisionPair();
                    ghost.CollisionPairs.Add(body2.ID, pair);
                    pair.Initialize(ghost, body2);
                    //Don't modify simulation object
                    //body2.CollisionPairHolders.Add(body1.ID);
                }
                return(pair);
            }
            return(null);
        }
Exemple #6
0
        void CheckCollisions(GhostLSBody ghost)
        {
            bufferPartitionNodes.FastClear();
            Partition.GetTouchingPartitions(ghost, bufferPartitionNodes);

            //temporarily make collisions only affect body1 (the ghost)
            CollisionPair.OnlyAffectBody1 = true;
            for (int n = 0; n < bufferPartitionNodes.Count; n++)
            {
                var node = bufferPartitionNodes [n];
                for (int i = 0; i < node.ContainedImmovableObjects.Count; i++)
                {
                    var id = node.ContainedImmovableObjects [i];
                    ProcessPair(ghost, id);
                }
                for (int k = 0; k < node.ContainedImmovableObjects.Count; k++)
                {
                    var id = node.ContainedImmovableObjects [k];
                    ProcessPair(ghost, id);
                }
            }
            CollisionPair.OnlyAffectBody1 = false;
        }
Exemple #7
0
 public void Assimilate(GhostLSBody ghostBody)
 {
     GhostBodies.Add(ghostBody);
 }