Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        protected virtual IEnumerator CreateBendTwistConstraints()
        {
            bendTwistConstraintsData = new ObiBendTwistConstraintsData();

            // Add two batches:
            bendTwistConstraintsData.AddBatch(new ObiBendTwistConstraintsBatch());
            bendTwistConstraintsData.AddBatch(new ObiBendTwistConstraintsBatch());

            // the last bend constraint couples the last segment and a phantom segment past the last particle.
            for (int i = 0; i < totalParticles - 1; i++)
            {
                var batch = bendTwistConstraintsData.batches[i % 2] as ObiBendTwistConstraintsBatch;

                Vector2Int indices = new Vector2Int(i, i + 1);

                Quaternion darboux = keepInitialShape ? ObiUtils.RestDarboux(orientations[indices.x], orientations[indices.y]) : Quaternion.identity;
                batch.AddConstraint(indices, darboux);
                batch.activeConstraintCount++;

                if (i % 500 == 0)
                {
                    yield return(new CoroutineJob.ProgressInfo("ObiRod: generating structural constraints...", i / (float)(totalParticles - 1)));
                }
            }

            // if the path is closed, add the last, loop closing constraints to a new batch to avoid sharing particles.
            if (path.Closed)
            {
                var loopClosingBatch = new ObiBendTwistConstraintsBatch();
                bendTwistConstraintsData.AddBatch(loopClosingBatch);

                Vector2Int indices = new Vector2Int(m_ActiveParticleCount - 1, 0);
                Quaternion darboux = keepInitialShape ? ObiUtils.RestDarboux(orientations[indices.x], orientations[indices.y]) : Quaternion.identity;
                loopClosingBatch.AddConstraint(indices, darboux);
                loopClosingBatch.activeConstraintCount++;
            }
        }
Ejemplo n.º 3
0
 public ObiBendTwistConstraintsData(ObiActor actor = null, ObiBendTwistConstraintsData source = null) : base(actor, source)
 {
 }
Ejemplo n.º 4
0
 public ObiBendTwistConstraintsBatch(ObiBendTwistConstraintsData constraints = null) : base()
 {
 }
Ejemplo n.º 5
0
 public ObiBendTwistConstraintsBatch(ObiBendTwistConstraintsData constraints = null, ObiBendTwistConstraintsBatch source = null) : base(source)
 {
     m_Constraints = constraints;
 }