public Spring2D(MassPoint2D a, MassPoint2D b, float width, float softness = 0.5f) { _a = a; _b = b; _width = width; _sqrWidth = width * width; _softness = softness; }
// public void Add(Rigidbody2D a, Rigidbody2D b, float width, float softness = 0.5f) // { // if(_massPointList.Any(x => x.body == a) == false) // { // _massPointList.Add(new MassPoint2D(a)); // } // if(_massPointList.Any(x => x.body == b) == false) // { // _massPointList.Add(new MassPoint2D(b)); // } // var aa = _massPointList.FirstOrDefault(x => x.body == a); // var bb = _massPointList.FirstOrDefault(x => x.body == b); // _springList.Add(new Spring2D(aa, bb, width, softness)); // } public void Add(MassPoint2D a, MassPoint2D b, float width, float softness = 0.5f) { if (_massPointList.Any(x => x == a) == false) { _massPointList.Add(a); } if (_massPointList.Any(x => x == b) == false) { _massPointList.Add(b); } _springList.Add(new Spring2D(a, b, width, softness)); }