Beispiel #1
0
        public void Clone(IWorld iWorld, bool doChecksum)
        {
            Physics2D.World world = (Physics2D.World)iWorld;

            Reset();

            if (doChecksum)
            {
                checksum = ChecksumExtractor.GetEncodedChecksum();
            }

            clonedPhysics.Clear();
            for (index = 0, length = world.BodyList.Count; index < length; index++)
            {
                Physics2D.Body b = world.BodyList[index];

                BodyClone2D cloneB = poolRigidBodyClone.GetNew();
                cloneB.Clone(b);

                clonedPhysics.Add(b.BodyId, cloneB);
            }

            contactsClone.Clear();

            for (index = 0, length = world.ContactList.Count; index < length; index++)
            {
                Physics2D.Contact c = world.ContactList[index];

                ContactClone2D cClone = poolContactClone.GetNew();
                cClone.Clone(c);

                contactsClone.Add(cClone);
            }

            islandClone.Clone(world.Island);
            toiClone.Clone(world._input);
            dynamicTreeClone.Clone((Physics2D.DynamicTreeBroadPhase)world.ContactManager.BroadPhase);

            this._worldHasNewFixture = world._worldHasNewFixture;

            bodyCounter    = Physics2D.Body._bodyIdCounter;
            fixtureCounter = Physics2D.Fixture._fixtureIdCounter;
        }
Beispiel #2
0
        public void Clone(IWorld iWorld, bool doChecksum)
        {
            World world = (World)iWorld;

            Reset();

            if (doChecksum)
            {
                checksum = ChecksumExtractor.GetEncodedChecksum();
            }

            clonedPhysics.Clear();

            foreach (RigidBody rb in world.RigidBodies)
            {
                RigidBodyClone rigidBodyClone = poolRigidBodyClone.GetNew();
                rigidBodyClone.Clone(rb);

                clonedPhysics.Add(rb.GetInstance(), rigidBodyClone);
            }

            clonedArbiters.Clear();
            foreach (Arbiter arb in world.ArbiterMap.Arbiters)
            {
                ArbiterClone arbiterClone = poolArbiterClone.GetNew();
                arbiterClone.Clone(arb);

                clonedArbiters.Add(arbiterClone);
            }

            clonedArbitersTrigger.Clear();
            foreach (Arbiter arb in world.ArbiterTriggerMap.Arbiters)
            {
                ArbiterClone arbiterClone = poolArbiterClone.GetNew();
                arbiterClone.Clone(arb);

                clonedArbitersTrigger.Add(arbiterClone);
            }

            collisionIslands.Clear();

            for (index = 0, length = world.islands.Count; index < length; index++)
            {
                CollisionIsland ci = world.islands[index];

                CollisionIslandClone collisionIslandClone = poolCollisionIslandClone.GetNew();
                collisionIslandClone.Clone(ci);

                collisionIslands.Add(collisionIslandClone);
            }

            cloneCollision.Clone((CollisionSystemPersistentSAP)world.CollisionSystem);

            clonedInitialCollisions.Clear();
            clonedInitialCollisions.AddRange(world.initialCollisions);

            clonedInitialTriggers.Clear();
            clonedInitialTriggers.AddRange(world.initialTriggers);

            rigidBodyInstanceCount  = RigidBody.instanceCount;
            constraintInstanceCount = Constraint.instanceCount;
        }