///<summary> /// Notifies the position updater that an updateable has changed state. ///</summary> ///<param name="updateable">Updateable with changed state.</param> ///<param name="previousMode">Previous state the updateable was in.</param> public void UpdateableModeChanged(ICCDPositionUpdateable updateable, PositionUpdateMode previousMode) { switch (previousMode) { case PositionUpdateMode.Discrete: discreteUpdateables.Remove(updateable); break; case PositionUpdateMode.Passive: passiveUpdateables.Remove(updateable); break; case PositionUpdateMode.Continuous: continuousUpdateables.Remove(updateable); break; } switch (updateable.PositionUpdateMode) { case PositionUpdateMode.Discrete: discreteUpdateables.Add(updateable); break; case PositionUpdateMode.Passive: passiveUpdateables.Add(updateable); break; case PositionUpdateMode.Continuous: continuousUpdateables.Add(updateable); break; } }
///<summary> /// Removes a force updateable from the force updater. ///</summary> ///<param name="forceUpdateable">Item to remove.</param> ///<exception cref="Exception">Thrown when the item does not belong to this force updater or its state is corrupted.</exception> public void Remove(IForceUpdateable forceUpdateable) { if (forceUpdateable.ForceUpdater == this) { if (forceUpdateable.IsDynamic && !dynamicObjects.Remove(forceUpdateable)) { throw new InvalidOperationException("Dynamic object not present in dynamic objects list; ensure that the IForceUpdateable was never removed from the list improperly by using ForceUpdateableBecomingKinematic."); } forceUpdateable.ForceUpdater = null; } else { throw new ArgumentException("Cannot remove updateable; it does not belong to this manager."); } }
public override void Remove(BroadPhaseEntry entry) { base.Remove(entry); entriesX.Remove(entry); entriesY.Remove(entry); entriesZ.Remove(entry); }
/// <summary> /// Removes the member from this island. /// </summary> /// <param name="simulationIslandMember">Removes the member from the manager.</param> public void Remove(SimulationIslandMember simulationIslandMember) { if (simulationIslandMember.DeactivationManager == this) { if (simulationIslandMember.IsDynamic) { simulationIslandMember.Activate(); } else { //If the object was NOT dynamic, then simply calling activate will be insufficient //because it does not share any simulation island with connected objects. //We need to notify its connections directly. foreach (var connection in simulationIslandMember.connections) { foreach (var entry in connection.entries) { if (entry.Member != simulationIslandMember) { entry.Member.Activate(); } } } } simulationIslandMember.DeactivationManager = null; simulationIslandMembers.Remove(simulationIslandMember); RemoveSimulationIslandFromMember(simulationIslandMember); } else { throw new Exception("Cannot remove that member from this DeactivationManager; it belongs to a different or no manager."); } }
[Test] public void Basics() { RawList <int> intList = new RawList <int>(); intList.Add(10); intList.AddRange(new int[] { 17, 42, 94 }); Assert.AreEqual(4, intList.Count); Assert.IsTrue(intList.Contains(42)); Assert.AreEqual(2, intList.IndexOf(42)); CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList.Data.Take(4)); intList.ShrinkToFit(); Assert.AreEqual(intList.Count, intList.Capacity); intList.Remove(42); Assert.AreEqual(3, intList.Count); Assert.IsTrue(!intList.Contains(42)); Assert.AreEqual(-1, intList.IndexOf(42)); CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList.Data.Take(3)); intList.Insert(1, 100); CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList.Data.Take(4)); intList.InsertRange(2, new int[] { 150, 200, 250, 300 }); CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList.Data.Take(8)); intList.Clear(); Assert.AreEqual(0, intList.Count); Assert.IsTrue(!intList.Contains(94)); }
[Test] public void Basics() { RawList<int> intList = new RawList<int>(); intList.Add(10); intList.AddRange(new int[] { 17, 42, 94 }); Assert.AreEqual(4, intList.Count); Assert.IsTrue(intList.Contains(42)); Assert.AreEqual(2, intList.IndexOf(42)); CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList.Data.Take(4)); intList.ShrinkToFit(); Assert.AreEqual(intList.Count, intList.Capacity); intList.Remove(42); Assert.AreEqual(3, intList.Count); Assert.IsTrue(!intList.Contains(42)); Assert.AreEqual(-1, intList.IndexOf(42)); CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList.Data.Take(3)); intList.Insert(1, 100); CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList.Data.Take(4)); intList.InsertRange(2, new int[] { 150, 200, 250, 300 }); CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList.Data.Take(8)); intList.Clear(); Assert.AreEqual(0, intList.Count); Assert.IsTrue(!intList.Contains(94)); }
internal void Destroy(Contact contact, int index) { Fixture fixtureA = contact.FixtureA; Fixture fixtureB = contact.FixtureB; Body bodyA = fixtureA.Body; Body bodyB = fixtureB.Body; if (EndContact != null && contact.IsTouching()) { EndContact(contact); } // Remove from the world. if (index == -1) { ContactList.Remove(contact); } else { ContactList.RemoveAt(index); } // Remove from body 1 if (contact.NodeA.Prev != null) { contact.NodeA.Prev.Next = contact.NodeA.Next; } if (contact.NodeA.Next != null) { contact.NodeA.Next.Prev = contact.NodeA.Prev; } if (contact.NodeA == bodyA.ContactList) { bodyA.ContactList = contact.NodeA.Next; } // Remove from body 2 if (contact.NodeB.Prev != null) { contact.NodeB.Prev.Next = contact.NodeB.Next; } if (contact.NodeB.Next != null) { contact.NodeB.Next.Prev = contact.NodeB.Prev; } if (contact.NodeB == bodyB.ContactList) { bodyB.ContactList = contact.NodeB.Next; } contact.Destroy(); }
/// <summary> /// Removes the member from this island. /// </summary> /// <param name="simulationIslandMember">Removes the member from the manager.</param> public void Remove(SimulationIslandMember simulationIslandMember) { if (simulationIslandMember.DeactivationManager == this) { simulationIslandMember.DeactivationManager = null; simulationIslandMembers.Remove(simulationIslandMember); RemoveSimulationIslandFromMember(simulationIslandMember); } else { throw new ArgumentException("Cannot remove that member from this DeactivationManager; it belongs to a different or no manager."); } }
/// <summary> /// Removes a solver updateable from the group. /// </summary> /// <param name="solverUpdateable">Solver updateable to remove.</param> /// <exception cref="InvalidOperationException">Thrown when the SolverUpdateable to remove from the SolverGroup doesn't actually belong to this SolverGroup.</exception> protected void Remove(EntitySolverUpdateable solverUpdateable) { if (solverUpdateable.SolverGroup == this) { solverUpdateables.Remove(solverUpdateable); solverUpdateable.SolverGroup = null; solverUpdateable.Solver = null; OnInvolvedEntitiesChanged(); } else { throw new InvalidOperationException("Cannot remove SolverUpdateable from SolverGroup; it doesn't belong to this SolverGroup."); } }
[Test] public void RemoveResetsReferenceTypesToDefault() { RawList <string> list = new RawList <string>( Enumerable.Range(0, 10) .Select(i => i.ToString()) .ToArray()); // Is the internal array empty if not assigned otherwise? if (list.Capacity > list.Count) { Assert.AreSame(null, list.Data[list.Count]); } // Adjusting the count shouldn't affect the internal array, just as documented list.Count = 0; for (int i = 0; i < 10; i++) { Assert.AreNotSame(null, list.Data[i]); } list.Count = 10; // Check various types of removal and make sure the internal array is reset properly { // Remove an element list.Remove("1"); Assert.AreSame(null, list.Data[list.Count]); list.RemoveAt(5); Assert.AreSame(null, list.Data[list.Count]); // Remove the last element specifically to tap into a different code path list.RemoveAt(list.Count - 1); Assert.AreSame(null, list.Data[list.Count]); // Remove a range list.RemoveRange(0, 5); for (int i = list.Count; i < list.Data.Length; i++) { Assert.AreSame(null, list.Data[i]); } // Clear the list list.Clear(); for (int i = list.Count; i < list.Data.Length; i++) { Assert.AreSame(null, list.Data[i]); } } }
///<summary> /// Removes an entry from the updater. ///</summary> ///<param name="entry">Entry to remove.</param> public void Remove(MobileCollidable entry) { entries.Remove(entry); }
internal void Remove(Grid2DEntry entry) { entries.Remove(entry); }
/// <summary> /// Removes an entry from the broad phase. /// </summary> /// <param name="entry">Entry to remove.</param> public override void Remove(BroadPhaseEntry entry) { entries.Remove(entry); }
[Test] public void RemoveResetsReferenceTypesToDefault() { RawList<string> list = new RawList<string>(Enumerable.Range(0, 10).Select(i => i.ToString())); // Is the internal array empty if not assigned otherwise? if (list.Capacity > list.Count) Assert.AreSame(null, list.Data[list.Count]); // Adjusting the count shouldn't affect the internal array, just as documented list.Count = 0; for (int i = 0; i < 10; i++) { Assert.AreNotSame(null, list.Data[i]); } list.Count = 10; // Check various types of removal and make sure the internal array is reset properly { // Remove an element list.Remove("1"); Assert.AreSame(null, list.Data[list.Count]); list.RemoveAt(5); Assert.AreSame(null, list.Data[list.Count]); // Remove a range list.RemoveRange(0, 5); for (int i = list.Count; i < list.Data.Length; i++) { Assert.AreSame(null, list.Data[i]); } // Clear the list list.Clear(); for (int i = list.Count; i < list.Data.Length; i++) { Assert.AreSame(null, list.Data[i]); } } }
///<summary> /// Strips a member of its simulation island. ///</summary> ///<param name="member">Member to be stripped.</param> public void RemoveSimulationIslandFromMember(SimulationIslandMember member) { //Becoming kinematic eliminates the member as a possible path. //Splits must be attempted between its connected members. //Don't need to split same-connection members. Splitting one non-null entry against a non null entry in each of the other connections will do the trick. if (member.simulationIsland != null) { //Note that this is using the most immediate simulation island. This is because the immediate simulation island //is the one who 'owns' the member; not the root parent. The root parent will own the member in the next frame //after the deactivation candidacy loop runs. SimulationIsland island = member.simulationIsland; island.Remove(member); if (island.memberCount == 0) { simulationIslands.Remove(island); GiveBackIsland(island); //Even though we appear to have connections, the island was only me! //We can stop now. //Note that we do NOT remove the island from the simulation islands list here. //That would take an O(n) search. Instead, orphan it and let the TryToDeactivate loop find it. return; } } if (member.connections.Count > 0) { for (int i = 0; i < member.connections.Count; i++) { //Find a member with a non-null island to represent connection i. SimulationIslandMember representativeA = null; for (int j = 0; j < member.connections.Elements[i].entries.Count; j++) { if (member.connections.Elements[i].entries.Elements[j].Member.SimulationIsland != null) { representativeA = member; break; } } if (representativeA == null) { //There was no representative! That means it was a connection in which //no member had a simulation island. Consider removing a dynamic box from the space //while it sits on a kinematic box. Neither object has a simulation island. //In this case, simply try the next connection. continue; } //Split the representative against representatives from other connections. for (int j = i + 1; j < member.connections.Count; j++) { //Find a representative for another connection. SimulationIslandMember representativeB = null; for (int k = 0; k < member.connections.Elements[j].entries.Count; k++) { if (member.connections.Elements[j].entries.Elements[k].Member.SimulationIsland != null) { representativeB = member; break; } } if (representativeB == null) { //There was no representative! Same idea as above. //Try the next connection. continue; } //Try to split the representatives. //Don't bother doing any deferring; this is a rare activity //and it's best just to do it up front. TryToSplit(representativeA, representativeB); } } } }
private void UnbufferMove(Element <FixtureProxy> proxy) { _moveBuffer.Remove(proxy); }