private void AddPendingProxies() { for (int index = 0; index < pendingProxies.Count; ++index) { BodyProxy proxy = pendingProxies[index]; Body.CreateProxy(proxy.Body1, proxy.Body2, proxy.transformation); } pendingProxies.Clear(); }
private static void AddProxySingle(Body body1, Body body2, Matrix2x2 transformation) { BodyProxy proxy1 = new BodyProxy(body2, body1, transformation.Inverted); BodyProxy proxy2 = new BodyProxy(body1, body2, transformation); proxy1.invertedTwin = proxy2; proxy2.invertedTwin = proxy1; body1.proxies.AddLast(proxy2.node); body2.proxies.AddLast(proxy1.node); }
private static void AddProxyList(Body body1, Body body2, Matrix2x2 transformation) { for (LinkedListNode <BodyProxy> node = body2.proxies.First; node != null; node = node.Next) { BodyProxy proxyT = node.Value; AddProxySingle(body1, proxyT.Body2, transformation * proxyT.transformation); } }
/// <summary> /// This will remove this body from any proxy list it is a part of. /// </summary> private void RemoveFromProxy() { if (proxies.Count == 0) { return; } for (LinkedListNode <BodyProxy> node = proxies.First; node != null; node = node.Next) { BodyProxy proxy = node.Value.invertedTwin; proxy.node.List.Remove(proxy.node); } proxies.Clear(); }
/// <summary> /// This applys the proxy. /// This will cause all other bodies in the proxy list to have their velocity set /// to this body’s. /// With the appropriate transformations applied. /// </summary> public void ApplyProxy() { if (proxies.Count == 0) { return; } for (LinkedListNode <BodyProxy> node = proxies.First; node != null; node = node.Next) { BodyProxy proxy = node.Value; PhysicsState state = proxy.Body2.state; state.Velocity.Angular = this.state.Velocity.Angular; Vector2D.Transform( ref proxy.transformation, ref this.state.Velocity.Linear, out state.Velocity.Linear); } }