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);
        }
Exemple #2
0
        public IEnumerator Generate()
        {
            m_Empty = true;

            m_ActiveParticleCount        = 0;
            distanceConstraintsData      = null;
            bendConstraintsData          = null;
            skinConstraintsData          = null;
            tetherConstraintsData        = null;
            bendTwistConstraintsData     = null;
            stretchShearConstraintsData  = null;
            shapeMatchingConstraintsData = null;
            aerodynamicConstraintsData   = null;
            chainConstraintsData         = null;
            volumeConstraintsData        = null;

            points    = null;
            edges     = null;
            triangles = null;

            IEnumerator g = Initialize();

            while (g.MoveNext())
            {
                yield return(g.Current);
            }

            RecalculateBounds();

            m_Empty = false;
            m_InitialActiveParticleCount = m_ActiveParticleCount;

            foreach (IObiConstraints constraints in GetConstraints())
            {
                for (int i = 0; i < constraints.GetBatchCount(); ++i)
                {
                    constraints.GetBatch(i).initialActiveConstraintCount = constraints.GetBatch(i).activeConstraintCount;
                }
            }

#if UNITY_EDITOR
            EditorUtility.SetDirty(this);
#endif

            if (OnBlueprintGenerate != null)
            {
                OnBlueprintGenerate(this);
            }
        }
Exemple #3
0
 public ObiChainConstraintsBatch(ObiChainConstraintsData constraints = null, ObiChainConstraintsBatch source = null) : base(source)
 {
     m_Constraints = constraints;
 }
 public ObiChainConstraintsBatch(ObiChainConstraintsData constraints = null) : base()
 {
 }
 public ObiChainConstraintsData(ObiActor actor = null, ObiChainConstraintsData source = null) : base(actor, source)
 {
 }