Esempio n. 1
0
        protected virtual IEnumerator CreateChainConstraints()
        {
            chainConstraintsData = new ObiChainConstraintsData();

            // Add a single batch:
            var batch = new ObiChainConstraintsBatch();

            chainConstraintsData.AddBatch(batch);

            int[] indices = new int[m_ActiveParticleCount + (path.Closed ? 1 : 0)];

            for (int i = 0; i < m_ActiveParticleCount; ++i)
            {
                indices[i] = i;
            }

            // Add the first particle as the last index of the chain, if closed.
            if (path.Closed)
            {
                indices[m_ActiveParticleCount] = 0;
            }

            // TODO: variable distance between particles:
            batch.AddConstraint(indices, m_InterParticleDistance, 1, 1);
            batch.activeConstraintCount++;

            yield return(0);
        }
        public override IObiConstraintsBatch Clone()
        {
            var clone = new ObiChainConstraintsBatch(this);

            clone.particleIndices.ResizeUninitialized(particleIndices.count);
            clone.firstParticle.ResizeUninitialized(firstParticle.count);
            clone.numParticles.ResizeUninitialized(numParticles.count);
            clone.lengths.ResizeUninitialized(lengths.count);

            clone.particleIndices.CopyFrom(particleIndices);
            clone.firstParticle.CopyFrom(firstParticle);
            clone.numParticles.CopyFrom(numParticles);
            clone.lengths.CopyFrom(lengths);

            return(clone);
        }
 public ObiChainConstraintsBatch(ObiChainConstraintsBatch source = null) : base(source)
 {
 }
Esempio n. 4
0
 public ObiChainConstraintsBatch(ObiChainConstraintsData constraints = null, ObiChainConstraintsBatch source = null) : base(source)
 {
     m_Constraints = constraints;
 }