示例#1
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)// && _handle != IntPtr.Zero)
            {
                if (_isDisposed)
                {
                    System.Diagnostics.Debug.WriteLine($"Dispose already disposed: {_handle}");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine($"Disposing: {_handle}");

                    _isDisposed = true;

                    if (Disposing != null)
                    {
                        Disposing(this, new EventArgs());
                    }

                    _world.BodyDisposed(this);      //NOTE: This just gives the .net world object a chance to unhook event listeners
                    Newton.NewtonDestroyBody(_worldHandle, _handle);
                    ObjectStorage.Instance.RemoveBody(_handle);
                    //_handle = IntPtr.Zero;
                }
            }
        }