private void SingleSectionSort(ParticleSection particleSection) { particleSection.sendParticles = new List <List <ParticleSection.ReffedParticle> >(); for (int i = 0; i < 6; i++) { particleSection.sendParticles.Add(new List <ParticleSection.ReffedParticle>()); full[i] = false; } var count = particleSection.BulkParticles.Count; var randNumb = random.Next(count); for (int i = randNumb; i < count; i++) { AddToSend0(particleSection.BulkParticles[i], i, particleSection); } for (int i = 0; i < randNumb; i++) { AddToSend0(particleSection.BulkParticles[i], i, particleSection); } }
private void AddToSend5(Particle particle, int i, ParticleSection section) { const int direction = 5; if (full[direction] && !(particle.Position.Z > section.sendParticles[direction][0].particle.Position.Z)) { return; } var j = 1; var zPos = particle.Position.Z; while (j < section.sendParticles[direction].Count && zPos > section.sendParticles[direction][j].particle.Position.Z) { j++; } ParticleSection.ReffedParticle outParticle; AddToRow(particle, i, section, direction, j, out outParticle); //PARTICLE DROPS HERE }
//Returns true if it drops a particle, false otherwise private bool AddToRow(Particle particle, int i, ParticleSection section, int direction, int j, out ParticleSection.ReffedParticle outParticle) { if (!full[direction]) { section.sendParticles[direction].Add(new ParticleSection.ReffedParticle()); for (int k = section.sendParticles[direction].Count - 1; k >= j; k--) { section.sendParticles[direction][k] = section.sendParticles[direction][k - 1]; } section.sendParticles[direction][j - 1] = new ParticleSection.ReffedParticle { particle = particle, reference = i }; outParticle = ParticleSection.ReffedParticle.Null; if (section.sendParticles[direction].Count == section.elementsPerSide[direction]) { full[direction] = true; } return(false); } outParticle = section.sendParticles[direction][0]; for (int k = 0; k < j - 1; k++) { section.sendParticles[direction][k] = section.sendParticles[direction][k + 1]; } section.sendParticles[direction][j - 1] = new ParticleSection.ReffedParticle { particle = particle, reference = i }; return(true); }
private void AddToSend1(Particle particle, int i, ParticleSection section) { var continueToNext = true; const int direction = 1; if (!full[direction] || particle.Position.X > section.sendParticles[direction][0].particle.Position.X) { var j = 1; var xPos = particle.Position.X; while (j < section.sendParticles[direction].Count && xPos > section.sendParticles[direction][j].particle.Position.X) { j++; } ParticleSection.ReffedParticle outParticle; continueToNext = AddToRow(particle, i, section, direction, j, out outParticle); i = outParticle.reference; particle = outParticle.particle; } if (continueToNext) { AddToSend2(particle, i, section); } }