示例#1
0
        public override void OnEnable()
        {
            m_world         = GetComponent <MPWorld>();
            m_max_instances = m_world.m_max_particle_num;

            base.OnEnable();
            ResetGPUResoures();
        }
示例#2
0
        public override void OnEnable()
        {
            m_world = GetComponent<MPWorld>();
            m_max_instances = m_world.m_max_particle_num;

            base.OnEnable();
            ResetGPUResoures();
        }
示例#3
0
        public unsafe void PropagateHit(ref MPParticle particle)
        {
            Vector3 f = MPAPI.mpGetIntermediateData(MPWorld.GetCurrentContext())->accel *MPWorld.GetCurrent().m_particle_mass;

            if (m_rigid3d != null)
            {
                m_rigid3d.AddForceAtPosition(f, particle.position);
            }
            if (m_rigid2d != null)
            {
                m_rigid2d.AddForceAtPosition(f, particle.position);
            }
        }
        public override void OnEnable()
        {
            m_world         = GetComponent <MPWorld>();
            m_max_instances = m_world.m_max_particle_num;
            m_cameras       = m_camera == null ? Camera.allCameras : new Camera[] { m_camera };

            if (m_cameras.Length > 0)
            {
                m_hdr = m_cameras[0].allowHDR;
            }

            base.OnEnable();
            ResetGPUResoures();
        }
示例#5
0
        public void PropagateForce(ref MPParticleForce force)
        {
            Vector3 pos = force.position_average;
            Vector3 f   = force.force * MPWorld.GetCurrent().m_particle_mass;

            if (m_rigid3d != null)
            {
                m_rigid3d.AddForceAtPosition(f, pos);
            }
            if (m_rigid2d != null)
            {
                m_rigid2d.AddForceAtPosition(f, pos);
            }
        }
示例#6
0
 static void ImmediateUpdate()
 {
     foreach (MPWorld w in s_instances)
     {
         w.UpdateKernelParams();
     }
     UpdateMPObjects();
     foreach (MPWorld w in s_instances)
     {
         MPAPI.mpUpdate(w.GetContext(), Time.deltaTime);
         s_current = w;
         MPAPI.mpCallHandlers(w.GetContext());
         MPAPI.mpClearCollidersAndForces(w.GetContext());
         w.CallUpdateRoutines();
         s_current = null;
     }
 }
示例#7
0
        public static void AddRadialSphereForce(MPWorld world, Vector3 pos, float radius, float strength)
        {
            Matrix4x4         mat = Matrix4x4.TRS(pos, Quaternion.identity, Vector3.one * radius);
            MPForceProperties p   = new MPForceProperties();

            p.shape_type      = MPForceShape.Sphere;
            p.dir_type        = MPForceDirection.Radial;
            p.center          = pos;
            p.strength_near   = strength;
            p.strength_far    = 0.0f;
            p.attenuation_exp = 0.5f;
            p.range_inner     = 0.0f;
            p.range_outer     = radius;
            world.AddOneTimeAction(() =>
            {
                MPAPI.mpAddForce(world.GetContext(), ref p, ref mat);
            });
        }
示例#8
0
文件: MP.cs 项目: davidlawson/ggj2016
 public static void AddRadialSphereForce(MPWorld world, Vector3 pos, float radius, float strength)
 {
     Matrix4x4 mat = Matrix4x4.TRS(pos, Quaternion.identity, Vector3.one * radius);
     MPForceProperties p = new MPForceProperties();
     p.shape_type = MPForceShape.Sphere;
     p.dir_type = MPForceDirection.Radial;
     p.center = pos;
     p.strength_near = strength;
     p.strength_far = 0.0f;
     p.attenuation_exp = 0.5f;
     p.range_inner = 0.0f;
     p.range_outer = radius;
     world.AddOneTimeAction(() =>
     {
         MPAPI.mpAddForce(world.GetContext(), ref p, ref mat);
     });
 }
示例#9
0
        public override void OnEnable()
        {
            m_world = GetComponent<MPWorld>();
            m_max_instances = m_world.m_max_particle_num;
            m_cameras = m_camera == null ? Camera.allCameras : new Camera[] { m_camera };

            if (m_cameras.Length > 0)
            {
                m_hdr = m_cameras[0].hdr;
            }

            base.OnEnable();
            ResetGPUResoures();
        }
示例#10
0
 static void DeferredUpdate()
 {
     foreach (MPWorld w in s_instances)
     {
         MPAPI.mpEndUpdate(w.GetContext());
     }
     foreach (MPWorld w in s_instances)
     {
         s_current = w;
         MPAPI.mpCallHandlers(w.GetContext());
         MPAPI.mpClearCollidersAndForces(w.GetContext());
         w.CallUpdateRoutines();
         w.UpdateKernelParams();
         s_current = null;
     }
     UpdateMPObjects();
     foreach (MPWorld w in s_instances)
     {
         MPAPI.mpBeginUpdate(w.GetContext(), Time.deltaTime);
     }
 }