예제 #1
0
        void OnEnable()
        {
            GetInstances().Add(this);

            m_world_data[0].SetDefaultValues();
            m_sph_params[0].SetDefaultValues(m_world_data[0].particle_size);
            m_world_data[0].num_max_particles = m_max_particles;
            m_world_data[0].SetWorldSize(transform.position, transform.localScale,
                                         (uint)m_world_div_x, (uint)m_world_div_y, (uint)m_world_div_z);

            m_particles = new MPGPParticle[m_max_particles];
            for (int i = 0; i < m_particles.Length; ++i)
            {
                m_particles[i].hit_objid = -1;
                m_particles[i].lifetime  = 0.0f;
            }

            int num_cells = m_world_data[0].world_div_x * m_world_data[0].world_div_y * m_world_data[0].world_div_z;

            m_buf_world_data  = new ComputeBuffer(1, MPGPWorldData.size);
            m_buf_world_idata = new ComputeBuffer(1, MPGPWorldIData.size);
            m_buf_world_idata.SetData(m_world_idata);
            m_buf_sph_params   = new ComputeBuffer(1, MPGPSPHParams.size);
            m_buf_cells        = new ComputeBuffer(num_cells, MPGPCell.size);
            m_buf_particles[0] = new ComputeBuffer(m_max_particles, MPGPParticle.size);
            m_buf_particles[1] = new ComputeBuffer(m_max_particles, MPGPParticle.size);
            m_buf_particles[0].SetData(m_particles);
            m_buf_particles_to_add = new ComputeBuffer(m_max_particles, MPGPParticle.size);
            m_buf_imd          = new ComputeBuffer(m_max_particles, MPGPParticleIData.size);
            m_buf_sort_data[0] = new ComputeBuffer(m_max_particles, MPGPSortData.size);
            m_buf_sort_data[1] = new ComputeBuffer(m_max_particles, MPGPSortData.size);

            m_bitonic_sort = new MPGPGPUSort();
            m_bitonic_sort.Initialize(m_cs_sort);

            m_buf_sphere_colliders  = new ComputeBuffer(m_max_sphere_colliders, MPGPSphereColliderData.size);
            m_buf_capsule_colliders = new ComputeBuffer(m_max_capsule_colliders, MPGPCapsuleColliderData.size);
            m_buf_box_colliders     = new ComputeBuffer(m_max_box_colliders, MPGPBoxColliderData.size);
            m_buf_bp_colliders      = new ComputeBuffer(m_max_bp_colliders, MPGPBezierPatchColliderData.size);
            m_buf_forces            = new ComputeBuffer(m_max_forces, CSForce.size);
        }
예제 #2
0
     void OnEnable()
     {
         GetInstances().Add(this);
 
         m_world_data[0].SetDefaultValues();
         m_sph_params[0].SetDefaultValues(m_world_data[0].particle_size);
         m_world_data[0].num_max_particles = m_max_particles;
         m_world_data[0].SetWorldSize(transform.position, transform.localScale,
             (uint)m_world_div_x, (uint)m_world_div_y, (uint)m_world_div_z);
 
         m_particles = new MPGPParticle[m_max_particles];
         for (int i = 0; i < m_particles.Length; ++i)
         {
             m_particles[i].hit_objid = -1;
             m_particles[i].lifetime = 0.0f;
         }
 
         int num_cells = m_world_data[0].world_div_x * m_world_data[0].world_div_y * m_world_data[0].world_div_z;
 
         m_buf_world_data = new ComputeBuffer(1, MPGPWorldData.size);
         m_buf_world_idata = new ComputeBuffer(1, MPGPWorldIData.size);
         m_buf_world_idata.SetData(m_world_idata);
         m_buf_sph_params = new ComputeBuffer(1, MPGPSPHParams.size);
         m_buf_cells = new ComputeBuffer(num_cells, MPGPCell.size);
         m_buf_particles[0] = new ComputeBuffer(m_max_particles, MPGPParticle.size);
         m_buf_particles[1] = new ComputeBuffer(m_max_particles, MPGPParticle.size);
         m_buf_particles[0].SetData(m_particles);
         m_buf_particles_to_add = new ComputeBuffer(m_max_particles, MPGPParticle.size);
         m_buf_imd = new ComputeBuffer(m_max_particles, MPGPParticleIData.size);
         m_buf_sort_data[0] = new ComputeBuffer(m_max_particles, MPGPSortData.size);
         m_buf_sort_data[1] = new ComputeBuffer(m_max_particles, MPGPSortData.size);
 
         m_bitonic_sort = new MPGPGPUSort();
         m_bitonic_sort.Initialize(m_cs_sort);
 
         m_buf_sphere_colliders = new ComputeBuffer(m_max_sphere_colliders, MPGPSphereColliderData.size);
         m_buf_capsule_colliders = new ComputeBuffer(m_max_capsule_colliders, MPGPCapsuleColliderData.size);
         m_buf_box_colliders = new ComputeBuffer(m_max_box_colliders, MPGPBoxColliderData.size);
         m_buf_bp_colliders = new ComputeBuffer(m_max_box_colliders, MPGPBezierPatchColliderData.size);
         m_buf_forces = new ComputeBuffer(m_max_forces, CSForce.size);
     }