Ejemplo n.º 1
0
        public int Compare(object x, object y)
        {
            ConstraintData a = (ConstraintData)x;
            ConstraintData b = (ConstraintData)y;

            ParticleData pa1 = m_particles[a.ParticleAIndex];
            ParticleData pa2 = m_particles[a.ParticleBIndex];

            ParticleData pb1 = m_particles[b.ParticleAIndex];
            ParticleData pb2 = m_particles[b.ParticleBIndex];

            if (pa1.IsKinematic || pa2.IsKinematic)
            {
                return(-1);
            }
            if (pb1.IsKinematic || pb2.IsKinematic)
            {
                return(1);
            }

            if (Math.Min(pa1.Mass, pa2.Mass) < Math.Min(pb1.Mass, pb2.Mass))
            {
                return(-1);
            }
            return(1);
        }
Ejemplo n.º 2
0
        public ClothParticleSystem(ParticleClothSettings settings)
        {
            m_numParticles = settings.Particles.Length;

            m_x = new float[m_numParticles];
            m_y = new float[m_numParticles];
            m_z = new float[m_numParticles];

            m_px = new float[m_numParticles];
            m_py = new float[m_numParticles];
            m_pz = new float[m_numParticles];

            m_fx = new float[m_numParticles];
            m_fy = new float[m_numParticles];
            m_fz = new float[m_numParticles];

            m_mass      = new float[m_numParticles];
            m_invmass   = new float[m_numParticles];
            m_kinematic = new bool[m_numParticles];

            settings.GetGravity(out m_gx, out m_gy, out m_gz);

            m_constraints = settings.Constraints;

            for (int i = 0; i < m_numParticles; ++i)
            {
                ParticleData p = settings.Particles[i];

                m_x[i]         = m_px[i] = p.x;
                m_y[i]         = m_py[i] = p.y;
                m_z[i]         = m_pz[i] = p.z;
                m_mass[i]      = p.Mass;
                m_invmass[i]   = 1f / p.Mass;
                m_kinematic[i] = p.IsKinematic;
            }

            m_collisions = settings.CollisionObjects;

            for (int i = 0; i < m_collisions.Length; ++i)
            {
                m_collisions[i].Init(this);
            }
        }