コード例 #1
0
 protected SolverUpdateable()
 {
     //Initialize the connection.
     //It will usually be overridden and end up floating on back to the resource pool.
     simulationIslandConnection       = PhysicsResources.GetSimulationIslandConnection();
     simulationIslandConnection.Owner = this;
 }
コード例 #2
0
 /// <summary>
 /// Returns a resource to the pool.
 /// </summary>
 /// <param name="connection">Connection to return.</param>
 public static void GiveBack(SimulationIslandConnection connection)
 {
     if (SimulationIslandConnections == null)
     {
         SimulationIslandConnections = new UnsafeResourcePool <SimulationIslandConnection>();
     }
     connection.CleanUp();
     SimulationIslandConnections.GiveBack(connection);
 }
コード例 #3
0
        void UpdateConnectedMembers()
        {
            //Since we're about to change this updateable's connections, make sure the
            //simulation islands hear about it.  This is NOT thread safe.
            var deactivationManager = simulationIslandConnection.DeactivationManager;

            //Orphan the simulation island connection since it's about to get replaced.
            //There's three possible situations here:
            //1) We belong to the DeactivationManager.
            //2) We don't belong to a DeactivationManager and the connection is slated for removal (we were in the deactivation manager before).
            //   This can happen when a solver updateable associated with a pair gets removed and cleaned up.
            //3) We don't belong to a DeactivationManager and the connection is not slated for removal (we weren't in a deactivation manager before).

            //In Case #1, all we have to do is orphan the connection and remove it from the manager. This performs any splits necessary. The replacement connection will force any necessary merges.
            //In Case #2, we were just removed but the connection is still considered to have an owner.
            //It won't get cleaned up by the removal, and doing it here would be premature: orphan the connection so the next deactivation manager splits flush cleans it up!
            //In Case #3, we have full control over the simulation island connection because there is no interaction with a deactivation manager. We can just get rid of it directly.
            simulationIslandConnection.Owner = null;
            if (deactivationManager != null)
            {
                deactivationManager.Remove(simulationIslandConnection);
            }
            else if (!simulationIslandConnection.SlatedForRemoval)     //If it's already been removed, cleaning it ourselves would prevent proper simulation island splits in the deactivation manager split flush.
            {
                PhysicsResources.GiveBack(simulationIslandConnection); //Well, since we're going to orphan the connection, we'll need to take care of its trash.
            }
            //The SimulationIslandConnection is immutable.
            //So create a new one!
            //Assume we've already dealt with the old connection.
            simulationIslandConnection = PhysicsResources.GetSimulationIslandConnection();
            for (int i = 0; i < involvedEntities.Count; i++)
            {
                simulationIslandConnection.Add(involvedEntities.Elements[i].activityInformation);
            }
            simulationIslandConnection.Owner = this;


            //Add the new reference back.
            if (deactivationManager != null)
            {
                deactivationManager.Add(simulationIslandConnection);
            }
        }
コード例 #4
0
 /// <summary>
 /// Returns a resource to the pool.
 /// </summary>
 /// <param name="connection">Connection to return.</param>
 public static void GiveBack(SimulationIslandConnection connection)
 {
     connection.CleanUp();
     SimulationIslandConnections.GiveBack(connection);
 }