//The Range x and Range y variables control how far away and in which direction this method should look for a particle public static spring GetSpring(int x, int y, int rows, out int connectedParticleIndex, int rangeX, int rangeY, ClothSimulator.SpringVariables vars, SpringType type) { spring Spring = new spring(); Spring.connectionA = y + (x * rows); Spring.connectionB = (y + ((x + rangeX) * rows) + rangeY); Spring.stiffness = vars.stiffness; Spring.damping = vars.damping; Spring.springType = (int)type; Spring.restLength = Vector3.Distance(GetParticlePos((x * rows), y, rows), GetParticlePos((x + rangeX) * rows, y + rangeY, rows)); connectedParticleIndex = (y + ((x + rangeX) * rows) + rangeY); return(Spring); }
public static spring ApplyChanges(spring spring, ClothSimulator.SpringVariables vars) { spring.stiffness = vars.stiffness; spring.damping = vars.damping; return(spring); }