GetParticles() private method

private GetParticles ( Particle particles ) : int
particles Particle
return int
Ejemplo n.º 1
0
    void Start()
    {
        particleSystem = gameObject.GetComponent<ParticleSystem>();

        const int maxParticle = 1000;
        particleSystem.maxParticles = maxParticle;
        particles = new ParticleSystem.Particle[maxParticle];
        particleData = new ParticleData[maxParticle];
        particleSystem.Emit(maxParticle);
        particleSystem.GetParticles(particles);

        for (int i = 0; i < maxParticle; i++)
        {
            particles[i].position = Vector3.zero;
            particles[i].velocity = Vector3.zero;
            particles[i].size = 0.1f;

            float rotateX = Random.value * 360;
            float rotateY = Random.value * 180;
            float rotateZ = Random.value * 360;

            Quaternion q = new Quaternion();
            q.eulerAngles = new Vector3(rotateX, rotateY, rotateZ);
            particleData[i].direction = q * Vector3.forward;
            particleData[i].speed = 1;
            particleData[i].cos = i / ((float)maxParticle / 10);
        }

        particleSystem.SetParticles(particles, maxParticle);
    }
	private void AlterParticle( ParticleSystem _ParticleSystem )
	{
		ParticleSystem.Particle [] parray = new ParticleSystem.Particle[ _ParticleSystem.particleCount ] ; 
		int num = _ParticleSystem.GetParticles( parray ) ;
		Debug.Log( "num" + num );
		for( int i = 0 ; i < num ; ++i )
		{
			parray[i].position = Vector3.zero ;
			parray[i].color = Color.red ;
			// Debug.Log( "parray[i].position=" + parray[i].position ) ;
		}
		_ParticleSystem.SetParticles( parray , parray.Length ) ;
	}
 static public int GetParticles(IntPtr l)
 {
     try {
         UnityEngine.ParticleSystem            self = (UnityEngine.ParticleSystem)checkSelf(l);
         UnityEngine.ParticleSystem.Particle[] a1;
         checkType(l, 2, out a1);
         var ret = self.GetParticles(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static int QPYX_GetParticles_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UnityEngine.ParticleSystem            QPYX_obj_YXQP  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.ParticleSystem));
         UnityEngine.ParticleSystem.Particle[] QPYX_arg0_YXQP = ToLua.CheckStructArray <UnityEngine.ParticleSystem.Particle>(L_YXQP, 2);
         int QPYX_o_YXQP = QPYX_obj_YXQP.GetParticles(QPYX_arg0_YXQP);
         LuaDLL.lua_pushinteger(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Ejemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     startTime = Time.time;
     particleSys = GetComponent<ParticleSystem>();
     particleSys.Stop();
     particleSys.Play();
     start = Time.time;
     particles = new ParticleSystem.Particle[particleSys.maxParticles];
     size = particleSys.GetParticles(particles);
     particleVelocity = new Vector3[size];
     for (int i = 0; i < size; i++)
     {
         particleVelocity[i] = particles[i].velocity;
     }
 }
Ejemplo n.º 6
0
    void Start()
    {
        mf = GetComponent<SkinnedMeshRenderer>();
        ps = GetComponent<ParticleSystem> ();
        origVerts = mf.sharedMesh.vertices;

        int i = 0;
        while (i < origVerts.Length) {
            ps.Emit(origVerts[i], Vector3.zero, size, float.PositiveInfinity, Color.white);
            i++;
        }

        particles = new ParticleSystem.Particle[ps.particleCount];
        ps.GetParticles (particles);
    }
Ejemplo n.º 7
0
 static public int GetParticles(IntPtr l)
 {
     try{
         UnityEngine.ParticleSystem            self = (UnityEngine.ParticleSystem)checkSelf(l);
         UnityEngine.ParticleSystem.Particle[] a1;
         checkType(l, 2, out a1);
         System.Int32 ret = self.GetParticles(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 8
0
        public void Update()
        {
            system = GetComponent<ParticleSystem>();
            particles = new ParticleSystem.Particle[system.particleCount];
            system.GetParticles(particles);

            for (int i = 0; i < particles.Length; i++) {
                if (i % 4 == 0) {
                    ((Light)Instantiate(light, particles[i].position, Quaternion.identity))
                        .gameObject.transform.SetParent(root.transform, false);
                }
            }

            system.SetParticles(particles, system.particleCount);
        }
 static public int GetParticles(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 5)
         {
             UnityEngine.ParticleSystem            self = (UnityEngine.ParticleSystem)checkSelf(l);
             UnityEngine.ParticleSystem.Particle[] a1;
             checkArray(l, 3, out a1);
             System.Int32 a2;
             checkType(l, 4, out a2);
             System.Int32 a3;
             checkType(l, 5, out a3);
             var ret = self.GetParticles(a1, a2, a3);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 4)
         {
             UnityEngine.ParticleSystem            self = (UnityEngine.ParticleSystem)checkSelf(l);
             UnityEngine.ParticleSystem.Particle[] a1;
             checkArray(l, 3, out a1);
             System.Int32 a2;
             checkType(l, 4, out a2);
             var ret = self.GetParticles(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 3)
         {
             UnityEngine.ParticleSystem            self = (UnityEngine.ParticleSystem)checkSelf(l);
             UnityEngine.ParticleSystem.Particle[] a1;
             checkArray(l, 3, out a1);
             var ret = self.GetParticles(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 10
0
 static int GetParticles(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
         UnityEngine.ParticleSystem.Particle[] arg0 = ToLua.CheckObjectArray <UnityEngine.ParticleSystem.Particle>(L, 2);
         int o = obj.GetParticles(arg0);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 11
0
 static public int GetParticles__O_Particle__Int32(IntPtr l)
 {
     try {
         UnityEngine.ParticleSystem            self = (UnityEngine.ParticleSystem)checkSelf(l);
         UnityEngine.ParticleSystem.Particle[] a1;
         checkArray(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         var ret = self.GetParticles(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 12
0
    void Start()
    {
        mf = GetComponent<MeshFilter>();
        ps = GetComponent<ParticleSystem> ();
        scale = this.transform.localScale;
        origVerts = mf.sharedMesh.vertices;
        newVerts = new Vector3[origVerts.Length];

        int i = 0;
        while (i < origVerts.Length) {
            ps.Emit(origVerts[i], Vector3.zero, 1f, float.PositiveInfinity, Color.white);
            i++;
        }

        particles = new ParticleSystem.Particle[ps.particleCount];
        ps.GetParticles (particles);
    }
Ejemplo n.º 13
0
	public static void MoveParticles(ParticleSystem ps, Vector3 moveAmount)
	{
		if (ps != null)
		{
			var parr = new ParticleSystem.Particle[ps.maxParticles];
			var totalParticles = ps.GetParticles(parr);

			//Debug.LogFormat("{0}: {1} / {2}", ps.name, totalParticles, parr.Length);
			//Debug.Break();

			for (var i = 0; i < totalParticles; i++)
			{
				parr[i].position += moveAmount;
			}
			ps.SetParticles(parr, parr.Length);
		}
	}
    static int GetParticles(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.ParticleSystem.GetParticles");
#endif
        try
        {
            ToLua.CheckArgsCount(L, 2);
            UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
            UnityEngine.ParticleSystem.Particle[] arg0 = ToLua.CheckStructArray <UnityEngine.ParticleSystem.Particle>(L, 2);
            int o = obj.GetParticles(arg0);
            LuaDLL.lua_pushinteger(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int GetParticles(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = null;
                int o = obj.GetParticles(arg0);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 3)
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = null;
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                int o    = obj.GetParticles(arg0, arg1);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 4)
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = null;
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                int arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
                int o    = obj.GetParticles(arg0, arg1, arg2);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.GetParticles"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 16
0
        static int _m_GetParticles(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.ParticleSystem __cl_gen_to_be_invoked = (UnityEngine.ParticleSystem)translator.FastGetCSObj(L, 1);


            try {
                {
                    UnityEngine.ParticleSystem.Particle[] particles = (UnityEngine.ParticleSystem.Particle[])translator.GetObject(L, 2, typeof(UnityEngine.ParticleSystem.Particle[]));

                    int __cl_gen_ret = __cl_gen_to_be_invoked.GetParticles(particles);
                    LuaAPI.xlua_pushinteger(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Ejemplo n.º 17
0
 private static void RenderCollisionBounds(ParticleSystem system, GizmoType gizmoType)
 {
     if (system.trigger.enabled && s_VisualizeBounds)
     {
         ParticleSystem.Particle[] particles = new ParticleSystem.Particle[system.particleCount];
         int num = system.GetParticles(particles);
         Color color = Gizmos.color;
         Gizmos.color = Color.green;
         Matrix4x4 identity = Matrix4x4.identity;
         if (system.main.simulationSpace == ParticleSystemSimulationSpace.Local)
         {
             identity = system.GetLocalToWorldMatrix();
         }
         Matrix4x4 matrix = Gizmos.matrix;
         Gizmos.matrix = identity;
         for (int i = 0; i < num; i++)
         {
             ParticleSystem.Particle particle = particles[i];
             Vector3 vector = particle.GetCurrentSize3D(system);
             Gizmos.DrawWireSphere(particle.position, (Math.Max(vector.x, Math.Max(vector.y, vector.z)) * 0.5f) * system.trigger.radiusScale);
         }
         Gizmos.color = color;
         Gizmos.matrix = matrix;
     }
 }
 private static void RenderCollisionBounds(ParticleSystem system, GizmoType gizmoType)
 {
   if (CollisionModuleUI.s_LastInteractedEditor == null || !CollisionModuleUI.s_LastInteractedEditor.m_VisualizeBounds || (Object) CollisionModuleUI.s_LastInteractedEditor.m_ParticleSystemUI.m_ParticleSystem != (Object) system)
     return;
   ParticleSystem.Particle[] particles1 = new ParticleSystem.Particle[system.particleCount];
   int particles2 = system.GetParticles(particles1);
   Color color = Gizmos.color;
   Gizmos.color = Color.green;
   Matrix4x4 matrix4x4 = Matrix4x4.identity;
   if (system.simulationSpace == ParticleSystemSimulationSpace.Local)
     matrix4x4 = system.transform.localToWorldMatrix;
   for (int index = 0; index < particles2; ++index)
   {
     ParticleSystem.Particle particle = particles1[index];
     Gizmos.DrawWireSphere(matrix4x4.MultiplyPoint(particle.position), particle.GetCurrentSize(system) * 0.5f * CollisionModuleUI.s_LastInteractedEditor.m_RadiusScale.floatValue);
   }
   Gizmos.color = color;
 }
    static int GetParticles(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <UnityEngine.ParticleSystem.Particle[]>(L, 2))
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = ToLua.ToStructArray <UnityEngine.ParticleSystem.Particle>(L, 2);
                int o = obj.GetParticles(arg0);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> >(L, 2))
            {
                UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> arg0 = StackTraits <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> > .To(L, 2);

                int o = obj.GetParticles(arg0);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.ParticleSystem.Particle[], int>(L, 2))
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = ToLua.ToStructArray <UnityEngine.ParticleSystem.Particle>(L, 2);
                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int o    = obj.GetParticles(arg0, arg1);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle>, int>(L, 2))
            {
                UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> arg0 = StackTraits <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> > .To(L, 2);

                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int o    = obj.GetParticles(arg0, arg1);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <UnityEngine.ParticleSystem.Particle[], int, int>(L, 2))
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = ToLua.ToStructArray <UnityEngine.ParticleSystem.Particle>(L, 2);
                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                int o    = obj.GetParticles(arg0, arg1, arg2);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle>, int, int>(L, 2))
            {
                UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> arg0 = StackTraits <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> > .To(L, 2);

                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                int o    = obj.GetParticles(arg0, arg1, arg2);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.GetParticles"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        private IEnumerator Do_Text_And_Audio( ParticleSystem particle_system, float amount, float text_size, AudioClip audio_clip, float pitch )
        {
            // Wait for the initial particle to be fired off
            while( particle_system.particleCount == 0 )
            {
                yield return null;
            }

            // Track it's position until it detonates
            ParticleSystem.Particle[] particle = new ParticleSystem.Particle[1];

            while( particle_system.particleCount > 0 )
            {
                particle_system.GetParticles( particle );
                yield return null;
            }

            // Create text/audio
            GameObject text_and_audio_gameobject = GameObject.Instantiate( this.amount_text_prefab ) as GameObject;

            // Set up text
            TextMesh text_mesh = text_and_audio_gameobject.GetComponentInChildren<TextMesh>();
            text_mesh.text = this.AmountToText( amount );
            text_mesh.fontSize = Mathf.RoundToInt( text_size );
            text_and_audio_gameobject.transform.position = particle_system.transform.TransformPoint( particle[0].position ) + new Vector3( 0f, 25f, 0f );
            text_and_audio_gameobject.transform.LookAt( this.camera.transform );

            // Set up audio
            AudioSource audio_source = text_and_audio_gameobject.GetComponent<AudioSource>();
            audio_source.clip = audio_clip;
            audio_source.pitch = pitch;
            audio_source.Play();

            // Animate in using scale
            float t = 0f;
            while( t < 1f )
            {
                t += Time.deltaTime;
                text_and_audio_gameobject.transform.localScale = Vector3.one * this.EaseOut( 0f, 1f, t );
                yield return null;
            }

            // Animate out
            Vector3 from_position = text_and_audio_gameobject.transform.position;
            Vector3 to_position = from_position + new Vector3( 0f, 10f, 0f );
            Color from_colour = new Color( 1f, 1f, 1f, 1f );
            Color to_colour = new Color( 1f, 1f, 1f, 0f );
            t = 0f;
            while( t < 1f )
            {
                t += Time.deltaTime / 2f;
                text_and_audio_gameobject.transform.position = Vector3.Lerp( from_position, to_position, t );
                text_and_audio_gameobject.transform.LookAt( this.camera.transform );
                text_mesh.color = Color.Lerp( from_colour, to_colour, t );
                yield return null;
            }

            Object.Destroy( text_and_audio_gameobject );
        }
Ejemplo n.º 21
0
    void Start()
    {
        //get the particle system from the GameObject containing it
        system = systemHolder.GetComponent<ParticleSystem>();

        //create the specified count of particles
        system.Emit(emitCount);

        //create an array to hold the particles
        particleArray = new ParticleSystem.Particle[systemHolder.GetComponent<ParticleSystem>().particleCount];

        //fill particle array with system's particles so they can be manipulated
        system.GetParticles(particleArray);

        //the spacing between particles y value
        float offset = 2.0f / emitCount;

        //how much to increment the phi angle of the particles
        float increment = Mathf.PI * (3.0f - Mathf.Sqrt(5.0f));
        float x, y, z, r;

        //set the initial velocity and position of each of the particles in radial pattern using fibonnacci spiral
        //the fibonnacci spiral method prevents bunching of particles near the poles of the sphere (lat and long method)
        for (float i = 0; i < system.particleCount; i++)
        {
            //get the y value of current particle
            y = ((i * offset) - 1) + (offset / 2.0f);

            //find rotation along spiral based on y value
            r = Mathf.Sqrt(1 - Mathf.Pow(y, 2.0f));

            //calculate an approximation of phi for current particle
            float phi = ((i + 1) % emitCount) * increment;

            //use rotation along spiral r, and phi to calculate x and z coords
            x = Mathf.Cos(phi) * r;
            z = Mathf.Sin(phi) * r;

            //set particle position and velocity
            //initial postion of all particles is set to the center since they are meant to explode outwards
            particleArray[(int)i].position = new Vector3(0, 0, 0);
            //allow initial velocity to be tweaked with the speedFactor
            particleArray[(int)i].velocity = new Vector3(x / speedFactor, y / speedFactor, z / speedFactor);

        }
        //set the position and velocity of the particles in the system based on array
        system.SetParticles(particleArray, system.particleCount);
    }
Ejemplo n.º 22
0
    public void FixedUpdate()
    {
        // Solve collisions only for obbs (not particles)
        collisionSolver.Solve();

        // Update particle system
        particleSystem.Update(Constants.TimeStepSeconds);

        // Solve collisions only for particles
        collisionSolver.Solve(ref particleSystem.Particles);

        // Do simulation
        fluidSim.Calculate(ref particleSystem.Particles, lGravity, Constants.TimeStepSeconds);

        if (fillTypeIndex == 1)
        {
            renderer.GetComponent <MeshRenderer>().enabled = true;
            Mesh mesh = generator.GenerateMesh(fluidSim.m_grid.getFluidMapCount(), Constants.CellSpace / 3);
            filter.mesh = mesh;
        }
        else if (fillTypeIndex == 0)
        {
            renderer.GetComponent <MeshRenderer>().enabled = false;
            // align Unity Particles with simulated Particles ...
            int d = particleSystem.Particles.Count - ps.particleCount;
            if (d > 0)
            {
                ps.Emit(d);
            }

            ps.GetParticles(particles);
            mParticle p;
            for (int i = 0; i < particleSystem.Particles.Count; i++)
            {
                p = particleSystem.Particles[i];
                particles[i].position          = new Vector3(p.Position.x, p.Position.y, 0);
                particles[i].remainingLifetime = 1f;
            }
            ps.SetParticles(particles, particleSystem.MaxParticles);
        }
        else
        {
            //update particle buffer
            smallParticle[] particleArray = new smallParticle[particleSystem.Particles.Count];
            for (int i = 0; i < particleSystem.Particles.Count; i++)
            {
                particleArray[i] = particleSystem.Particles[i].toE();
            }
            particleBuffer.SetData(particleArray);
            // Bind the ComputeBuffer to the shader and the compute shader
            computeShader.SetBuffer(mComputeShaderKernelID, "particleBuffer", particleBuffer);
            computeShader.SetInt("particle_length", particleSystem.Particles.Count);
            int mWarpCount = Mathf.CeilToInt((float)fluidSim.m_grid.GPUVoxel / Constants.WARP_SIZE);
            computeShader.Dispatch(mComputeShaderKernelID, mWarpCount, 1, 1);
            grid[] gridArray = new grid[fluidSim.m_grid.GPUVoxel];
            gridBuffer.GetData(gridArray);
            int[] field = new int[gridArray.GetLength(0)];
            for (int i = 0; i < gridArray.GetLength(0); i++)
            {
                if (gridArray[i].value > 0)
                {
                    field[i] = 1;
                }
            }

            int[,] f = Helper.Make2DArray <int>(field, fluidSim.m_grid.Width * Constants.resolution + 1, fluidSim.m_grid.Height * Constants.resolution + 1);
            renderer.GetComponent <MeshRenderer>().enabled = true;
            Mesh mesh = generator.GenerateMesh(f, Constants.CellSpace / Constants.resolution);
            mesh        = mattatz.MeshSmoothingSystem.MeshSmoothing.LaplacianFilter(mesh);
            filter.mesh = mesh;
        }
    }
	static public int GetParticles(IntPtr l) {
		try {
			#if DEBUG
			var method = System.Reflection.MethodBase.GetCurrentMethod();
			string methodName = GetMethodName(method);
			#if UNITY_5_5_OR_NEWER
			UnityEngine.Profiling.Profiler.BeginSample(methodName);
			#else
			Profiler.BeginSample(methodName);
			#endif
			#endif
			int argc = LuaDLL.lua_gettop(l);
			if(argc==2){
				UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l);
				UnityEngine.ParticleSystem.Particle[] a1;
				checkArray(l,2,out a1);
				var ret=self.GetParticles(a1);
				pushValue(l,true);
				pushValue(l,ret);
				return 2;
			}
			else if(argc==3){
				UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l);
				UnityEngine.ParticleSystem.Particle[] a1;
				checkArray(l,2,out a1);
				System.Int32 a2;
				checkType(l,3,out a2);
				var ret=self.GetParticles(a1,a2);
				pushValue(l,true);
				pushValue(l,ret);
				return 2;
			}
			else if(argc==4){
				UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l);
				UnityEngine.ParticleSystem.Particle[] a1;
				checkArray(l,2,out a1);
				System.Int32 a2;
				checkType(l,3,out a2);
				System.Int32 a3;
				checkType(l,4,out a3);
				var ret=self.GetParticles(a1,a2,a3);
				pushValue(l,true);
				pushValue(l,ret);
				return 2;
			}
			pushValue(l,false);
			LuaDLL.lua_pushstring(l,"No matched override function GetParticles to call");
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
		#if DEBUG
		finally {
			#if UNITY_5_5_OR_NEWER
			UnityEngine.Profiling.Profiler.EndSample();
			#else
			Profiler.EndSample();
			#endif
		}
		#endif
	}