Пример #1
0
        public override IObiConstraintsBatch Clone(IObiConstraints constraints)
        {
            var clone = new ObiBendTwistConstraintsBatch(constraints as ObiBendTwistConstraintsData, this);

            clone.particleIndices.ResizeUninitialized(particleIndices.count);
            clone.restDarbouxVectors.ResizeUninitialized(restDarbouxVectors.count);
            clone.stiffnesses.ResizeUninitialized(stiffnesses.count);

            clone.particleIndices.CopyFrom(particleIndices);
            clone.restDarbouxVectors.CopyFrom(restDarbouxVectors);
            clone.stiffnesses.CopyFrom(stiffnesses);

            return(clone);
        }
Пример #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++;
            }
        }
Пример #3
0
 public ObiBendTwistConstraintsBatch(ObiBendTwistConstraintsData constraints = null, ObiBendTwistConstraintsBatch source = null) : base(source)
 {
     m_Constraints = constraints;
 }
 public ObiBendTwistConstraintsBatch(ObiBendTwistConstraintsBatch source = null) : base(source)
 {
 }