Пример #1
0
        public Engine.Effects.Code.Particles.AutonomousParticle[] GetParticles()
        {
            Engine.Effects.Code.Particles.AutonomousParticle[] particles = new Effects.Code.Particles.AutonomousParticle[t_cells.GetLength(0) * t_cells.GetLength(1)];

            Engine.Threading.ParamList paramList = new Threading.ParamList();
            paramList.Add("particles", typeof(int), particles);

            Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop();
            loop.Loop(t_cells.GetLength(0), Threaded_GetParticles, paramList);
            loop.Dispose();

            return(particles);
        }
Пример #2
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);
        }