/// <summary> /// Creates a part. /// </summary> /// <param name="primitiveProperties">Properties of the body's shape.</param> /// <param name="massProperties">Properties of the body's mass.</param> /// <param name="withMainController">Adds a main BasicController for this part.</param> public Part(JLG.PrimitiveProperties primitiveProperties, MassProperties massProperties, bool withMainController) : base() { _primitiveProperties = primitiveProperties; _massProperties = massProperties; if (withMainController) { // Create Main Controller _mainController = new BasicController(this); if (PhysicsSystem.CurrentPhysicsSystem != null) { PhysicsSystem.CurrentPhysicsSystem.AddController(_mainController); } } _relatedControllers = new Hashtable(); }
public virtual void Dispose() { _mainController.DisableController(); _mainController = null; IDictionaryEnumerator enumerator = _relatedControllers.GetEnumerator(); Controller controller; while (enumerator.MoveNext()) { controller = (Controller)enumerator.Value; controller.DisableController(); } if (_relatedControllers != null) { _relatedControllers.Clear(); _relatedControllers = null; } }