Exemplo n.º 1
0
        /**
         * Tears a cloth distance constraint, affecting both the physical representation of the cloth and its mesh.
         */
        public bool Tear(StructuralConstraint edge)
        {
            // don't allow splitting if there are no free particles left in the pool.
            if (activeParticleCount >= m_TearableClothBlueprint.particleCount)
            {
                return(false);
            }

            // get particle indices at both ends of the constraint:
            ParticlePair indices = edge.batchIndex.GetParticleIndices(edge.constraintIndex);

            // Try to perform a split operation on the topology. If we cannot perform it, bail out.
            Vector3                  point, normal;
            HashSet <int>            updatedHalfEdges = new HashSet <int>();
            List <HalfEdgeMesh.Face> updatedFaces     = new List <HalfEdgeMesh.Face>();

            if (!TopologySplitAttempt(ref indices.first, ref indices.second, out point, out normal, updatedFaces, updatedHalfEdges))
            {
                return(false);
            }

            int splitActorIndex = solver.particleToActor[indices.first].indexInActor;

            // Weaken edges around the cut:
            WeakenCutPoint(splitActorIndex, point, normal);

            // split the particle in two, adding a new active particle:
            SplitParticle(splitActorIndex);

            // update constraints:
            UpdateTornDistanceConstraints(updatedHalfEdges);
            UpdateTornBendConstraints(indices.first);

            if (OnConstraintTorn != null)
            {
                OnConstraintTorn(this, new ObiConstraintTornEventArgs(edge, splitActorIndex, updatedFaces));
            }

            return(true);
        }
Exemplo n.º 2
0
 public ObiClothTornEventArgs(StructuralConstraint edge, int particle, List <HalfEdgeMesh.Face> updatedFaces)
 {
     this.edge          = edge;
     this.particleIndex = particle;
     this.updatedFaces  = updatedFaces;
 }