private int Threaded_Loop_Cell_Part_2(int start, int end, Threading.ParamList paramList) { AutonomousParticle p = (AutonomousParticle)paramList.Get("particle").Value; Engine.Color.Cell[] cells = (Engine.Color.Cell[])paramList.Get("cells").Value; int counter = (int)paramList.Get("counter").Value; int offset = 0; if (!t_glassBlock) { offset = Engine.Surface.Ops.GetGridOffset(0, start, t_cellSize, t_cellSize); } for (int y = start; y < end; y++) { for (int x = 0; x < t_cellSize; x++) { cells[offset] = Engine.Calc.Color.FastAlphaBlend(cells[offset], t_imageProcessed.GetPixel((int)(p.Position.X - (t_cellSize / 2) + x), (int)(p.Position.Y - (t_cellSize / 2) + y), Surface.PixelRetrievalOptions.ReturnNeutralGray)); t_imageProcessed.SetPixel(cells[offset], (int)(p.Position.X - (t_cellSize / 2) + x), (int)(p.Position.Y - (t_cellSize / 2) + y), Surface.PixelSetOptions.Ignore); offset++; } } return(0); }
private int Threaded_Loop(int start, int end, Threading.ParamList paramList) { int counter = (int)paramList.Get("counter").Value; Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); for (int ii = start; ii < end; ii++) { // collect pixels in each grid cell Engine.Color.Cell[] cells = new Engine.Color.Cell[t_cellSize * t_cellSize]; AutonomousParticle p = t_particles[ii]; Engine.Threading.ParamList paramList2 = new Threading.ParamList(); paramList2.Add("particle", typeof(AutonomousParticle), p); paramList2.Add("cells", typeof(Engine.Color.Cell[]), cells); paramList2.Add("counter", typeof(int), counter); loop.Loop(t_cellSize, Threaded_Loop_Cell_Part_1, paramList2); p.Move(); loop.Loop(t_cellSize, Threaded_Loop_Cell_Part_2, paramList2); } loop.Dispose(); return(0); }
private int Threaded_GetParticles(int start, int end, Threading.ParamList paramlist) { Engine.Effects.Code.Particles.AutonomousParticle[] particles = (Engine.Effects.Code.Particles.AutonomousParticle[])paramlist.Get("particles").Value; for (int x = start; x < end; x++) { for (int y = 0; y < t_cells.GetLength(1); y++) { int offset = Engine.Surface.Ops.GetGridOffset(x, y, t_cells.GetLength(0), t_cells.GetLength(1)); particles[offset] = new Effects.Code.Particles.AutonomousParticle(new Engine.Calc.Vector((x * t_gridCellWidth) + (t_gridCellWidth / 2), (y * t_gridCellHeight) + (t_gridCellHeight / 2))); Engine.Calc.Vector vel = t_cells[x, y].Pressure; vel.Normalize(); vel.SetMagnitude(2); particles[offset].Velocity = vel; //t_cells[x, y].CalculateAveragePressure(t_flowField, x * t_gridCellWidth, y * t_gridCellHeight); } } return(0); }