public void Clone(CollisionIsland ci) { bodies.Clear(); for (index = 0, length = ci.bodies.Count; index < length; index++) { bodies.Add(ci.bodies[index]); } arbiters.Clear(); for (index = 0, length = ci.arbiter.Count; index < length; index++) { ArbiterClone arbiterClone = WorldClone.poolArbiterClone.GetNew(); arbiterClone.Clone(ci.arbiter[index]); arbiters.Add(arbiterClone); } constraints.Clear(); for (index = 0, length = ci.constraints.Count; index < length; index++) { constraints.Add(ci.constraints[index]); } }
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; }