/// <summary> /// Присоединит переданный объект, используя переданный Location. /// </summary> public void Attach(IPhysical body, Frame3D realLocation, bool joinWithFriction = true) { var bb = (BepuBody)body; var rb = bb.RealBody; BepuConverter.PutInFrame(rb, realLocation, bb.InitialOrientation); //bb.RealBody.Position = new Vector3(-bb.RealBody.Position.X, bb.RealBody.Position.Y, bb.RealBody.Position.Z); rb.Position += RealBody.Position; rb.Orientation *= RealBody.Orientation; SolverGroup wj = BepuWorld.MakeWeldJoint(RealBody, rb); Connection c; try //есть connection { c = _connections.First(x => x.OtherBody == rb); c.Add(wj); } catch (Exception) //нет connection { c = new Connection(rb); c.Add(wj); _connections.Add(c); //connection добавляем для обоих тел! М.К. bb._connections.Add(c); } }
public void Disconnect() { foreach (var j in _joints) { BepuWorld.RemoveJoint(j); } }