Exemplo n.º 1
0
 public SubmoduleEntry(string name, string path, URIish url, UpdateMethod update)
 {
     Name = name;
     Path = path;
     Url = url;
     Update = update;
 }
		public FileTreeItem(FileInfo fileInfo, UpdateMethod method, FileVerificationLevel level, string relativePath, string flag)
		{
			FileInfo = fileInfo;
			RelativePath = relativePath;
			_updateMethod = method;
			_verificationLevel = level;
			_flag = flag;
		}
Exemplo n.º 3
0
 /// <summary>
 /// 发送一个重要的异步Event,这个Event必定在下一帧发给Listener
 /// TODO 之后还会写一个 SendMinorAsync 用来发送不重要的Event
 /// </summary>
 public void SendMajorAsync(int eventId
                            , IUserData userData
                            , UpdateMethod updateMethod)
 {
     lock (m_MajorEventCache)
     {
         m_MajorEventCache
         .Enqueue(m_EventItemPool.Alloc().SetData(eventId, userData, updateMethod));
     }
 }
Exemplo n.º 4
0
 internal Particle2 UNPOOL(Vector2 pos, Vector2 vel, UpdateMethod mymeth, Color c, int s)
 {
     position = pos;
     velocity = vel;
     myUpdate = mymeth;
     time     = 0;
     this.c   = c;
     size     = s;
     isActive = true;
     return(this);
 }
Exemplo n.º 5
0
 public void Init(WorldSpace ws)
 {
     fuel               = 1f;
     investigation      = 0f;
     m_WorldSpace       = ws;
     m_HomePlanet       = ws.homePlanet;
     m_HomePlanetCoords = m_HomePlanet.trf.position;
     closestPlanet      = ScanClosestPlanet(1)[0];
     m_Trf              = transform;
     m_UpdateMethod     = _IdleUpdate;
 }
Exemplo n.º 6
0
            public string GetUpdate(ArchAngel.Interfaces.Scripting.DatabaseChanges.IChangedTable table)
            {
                object[] parms = new object[] { table };
                string   body  = (string)UpdateMethod.Invoke(null, parms);

                if (body.StartsWith("          "))
                {
                    body = body.Substring(10);
                }

                return(body);
            }
Exemplo n.º 7
0
        /// <summary>
        /// 更新数据至源
        /// </summary>
        /// <returns></returns>
        public override UpdateInformation UpdateToSource(UpdateMethod updateMethod)
        {
            if (updateMethod == UpdateMethod.Delete)
            {
                foreach (Container container in FetchContainers((c) => true))
                {
                    container.UpdateToSource(UpdateMethod.Delete);
                }
            }
            UpdateInformation updateInformation = base.UpdateToSource(updateMethod);

            return(updateInformation);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Event handler for an assert.
        /// </summary>
        /// <param name="sender">Because Debug is a static class, this is always NULL.</param>
        /// <param name="args">Info about the assert.</param>
        private void HandleAssert(object sender, DebugEventArgs args)
        {
            updateMethod = Update_Assert;
            drawMethod   = Draw_Assert;

            // This method is running on the thread that asserted, so start a new thread for the
            // handler so it can kill off all the worker threads without killing itself.
            //handleAssertThread = new Thread(new ParameterizedThreadStart(HandleAssertThread));
            //handleAssertThread.Name = "HandleAssert";
            //handleAssertThread.IsBackground = true;
            //handleAssertThread.Start(args);
            HandleAssertThread(args);
        }
        public Result <Method> UpdateMethod(UpdateMethod updateMethod)
        {
            Method methodToUpdate = methodsMemoryDatabase.Find(e => e.Id == updateMethod.Id);

            if (methodToUpdate == null)
            {
                return(Result.Fail <Method>("The method you're trying to update does not exist"));
            }

            methodToUpdate.Creator = updateMethod.Creator;
            methodToUpdate.Name    = updateMethod.Name;

            return(Result.Ok <Method>(methodToUpdate));
        }
Exemplo n.º 10
0
    public void FlyToPlanet(Planet p)
    {
        m_JumpTime     = 0f;
        m_TargetPlanet = p.planet;

        if (m_TargetPlanet != null)
        {
            closestPlanet = m_TargetPlanet.GetComponent <Planet>();
        }

        m_JumpTarget   = closestPlanet.trf.position;
        m_UpdateMethod = _FlyToUpdate;
        m_CanInteract  = false;
    }
Exemplo n.º 11
0
        /// <summary>
        ///     Initialize a new coroutine with specified name, update multiplier and optional callback on its execution done.
        /// </summary>
        /// <param name="routine">The coroutine to start.</param>
        /// <param name="name">Name of the coroutine, commonly used for debug log.</param>
        /// <param name="updateMethod">Determines from where the coroutine is automantically updated.</param>
        /// <param name="updateMultiplier">Determines how many times the coroutine is executed per frame.</param>
        /// <param name="done">Callback executes when the coroutine is done.</param>
        public Coroutine(IEnumerator routine, string name,
                         UpdateMethod updateMethod, int updateMultiplier = 1, Action done = null)
        {
            Routine = routine ?? throw new ArgumentNullException(nameof(routine));

            this.name = name;

            UpdateMethod     = updateMethod;
            UpdateMultiplier = updateMultiplier;

            if (done != null)
            {
                Done += done;
            }
        }
Exemplo n.º 12
0
    private void _FlyToUpdate(float dt)
    {
        m_JumpTime += dt;
        float progress = m_JumpTime / HD_JUMP_TIME;

        m_Trf.position = Vector3.Slerp(m_Trf.position, m_JumpTarget, progress);
        m_Trf.LookAt(m_JumpTarget);

        float dist = Vector3.Distance(closestPlanet.trf.position, m_Trf.position);

        if (dist < MAX_DIST_INTERACT_PLANET)
        {
            m_UpdateMethod = _InteractUpdate;
        }
    }
        public IActionResult UpdateMethod(long id, [FromBody] MethodDTO methodDTO)
        {
            long loggedInUserId = GetLoggedInUserIdMockUp();

            if (loggedInUserId == -1)
            {
                return(Unauthorized());
            }

            UpdateMethod updateMethod =
                new UpdateMethod(id, methodDTO.Creator, methodDTO.Name, methodDTO.ApplicationRate, loggedInUserId);

            _kafkaProducer.Produce(updateMethod, METHODS_TOPIC);

            return(Ok("Currently processing your request..."));
        }
Exemplo n.º 14
0
        /// <summary>
        ///     Initialize a new coroutine and start it.
        /// </summary>
        /// <param name="routine">The coroutine to start.</param>
        /// <param name="name">Name of the coroutine, commonly used for debug log.</param>
        /// <param name="updateMethod">Determines from where the coroutine is automantically updated.</param>
        /// <param name="done">Callback that executes when the coroutine stops.</param>
        /// <returns></returns>
        public static Coroutine Start(IEnumerator routine, string name, UpdateMethod updateMethod, Action done = null)
        {
            if (routine == null)
            {
                throw new ArgumentNullException(nameof(routine));
            }

            if (startedInstances.TryGetValue(routine, out var coroutine))
            {
                return(coroutine);
            }

            coroutine = new Coroutine(routine, name, updateMethod, 1, done);
            coroutine.StartImpl();
            return(coroutine);
        }
Exemplo n.º 15
0
    public void Init()
    {
        elapsedTime = 0;

        SpriteRenderer sr = GetComponent <SpriteRenderer>();

        if (sr != null && sr.sprite != null)
        {
            marginH = sr.sprite.rect.height;
            marginW = sr.sprite.rect.width;
        }

        OnFixedUpdate = FixedUpdateNormal;
        if (duration > 0)
        {
            OnFixedUpdate = FixedUpdateDuration;
        }
    }
Exemplo n.º 16
0
        protected void RunMethod(UpdateMethod method)
        {
            var args = new MethodArgs
            {
                Method          = method,
                MaxRowsToUpdate = Convert.ToInt64(txtMaxRowsToUpdate.Value),
                PrepareCommand  = chkbPrepareCommand.Checked
            };

            ///////////////////////////////////////////////////////////////////////////////

            var progressForm = new FormGenericProgress(method.ToString(), PerformOperation, args, true);

            progressForm.ShowDialog();

            ///////////////////////////////////////////////////////////////////////////////

            ShowResults(args);
        }
Exemplo n.º 17
0
        public void AddAndRefreshIconStatus(UpdateMethod updateMethods, string newValue = "")
        {
            switch (updateMethods)
            {
            case UpdateMethod.LeftClick:
                HandleLeftClick();
                break;

            case UpdateMethod.RightClick:
                HandleRightClick();
                break;

            case UpdateMethod.NewValue:
                HandleNewValue(newValue);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(updateMethods), updateMethods, null);
            }
        }
Exemplo n.º 18
0
        public VolumetricRendererGame()
        {
            Debug.OnAssert += new EventHandler <DebugEventArgs>(HandleAssert);
            //Debug.BlockAfterAssert = true;

            // Set up and run initial threads.
            //mainThread = Thread.CurrentThread;
            //mainThread.Name = "Main";

            //updateLock = new object();
            //updateThread = new Thread(new ThreadStart(UpdateThread));
            //updateThread.Name = "Update";
            //updateThread.IsBackground = true;
            //updateThread.Start();

            //drawLock = new object();
            //drawThread = new Thread(new ThreadStart(DrawThread));
            //drawThread.Name = "Draw";
            //drawThread.IsBackground = true;
            //drawThread.Start();

            // Set up the game.
            updateMethod  = Update_Normal;
            drawMethod    = Draw_Normal;
            assertHandled = false;

            Content.RootDirectory = "Content";

            graphicsDM = new GraphicsDeviceManager(this);
            graphicsDM.PreferredBackBufferWidth       = 1280;
            graphicsDM.PreferredBackBufferHeight      = 960;
            graphicsDM.PreferMultiSampling            = false;
            graphicsDM.SynchronizeWithVerticalRetrace = false;
            graphicsDM.IsFullScreen = false;

            input         = new InputState();
            screenManager = new ScreenManager(this, input);
            Components.Add(screenManager);

            IsMouseVisible = true;
        }
Exemplo n.º 19
0
        public static OnUpdateCallback Add(UpdateMethod callback, float fps)
        {
            if (callback == null)
            {
                return(null);
            }

            OnUpdateCallback newElement = new OnUpdateCallback(callback, fps);

            if (FirstElement == null)
            {
                FirstElement = LastElement = newElement;
            }
            else
            {
                newElement.Previous = LastElement;
                LastElement         = LastElement.Next = newElement;
            }

            return(newElement);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 更新数据至源
        /// </summary>
        /// <returns></returns>
        public override UpdateInformation UpdateToSource(UpdateMethod updateMethod)
        {
            if (updateMethod == UpdateMethod.Delete)
            {
                foreach (Pair pair in FetchPairs((p) => true))
                {
                    pair.UpdateToSource(UpdateMethod.Delete);
                }
                if (File.Exists($@"{DataAvatarsFolderName}\{Avatar}"))
                {
                    File.Delete($@"{DataAvatarsFolderName}\{Avatar}");
                }
            }
            else if (updateMethod == UpdateMethod.Update)
            {
                foreach (Pair pair in _workPairs)
                {
                    pair.UpdateToSource();
                }
            }
            UpdateInformation ui = base.UpdateToSource(updateMethod);

            return(ui);
        }
Exemplo n.º 21
0
        private async void UpdateSummonerSpellImage(Obj_AI_Hero hero, Size size, SpriteHelper.SpriteInfo sprite, SpellSlot slot, UpdateMethod method)
        {
            Task<SpriteHelper.SpriteInfo> taskInfo = null;
            switch (slot)
            {
                case SpellSlot.Summoner1:
                    taskInfo = SpriteHelper.LoadTextureAsync(hero.Spellbook.GetSpell(SpellSlot.Summoner1).Name, sprite, SpriteHelper.DownloadType.Summoner);
                    break;

                case SpellSlot.Summoner2:
                    taskInfo = SpriteHelper.LoadTextureAsync(hero.Spellbook.GetSpell(SpellSlot.Summoner2).Name, sprite, SpriteHelper.DownloadType.Summoner);
                    break;
            }
            if (taskInfo == null)
                return;
            sprite = await taskInfo;
            if (sprite.LoadingFinished)
            {
                Utility.DelayAction.Add(5000, () => UpdateSummonerSpellImage(hero, size, sprite, slot, method));
            }
            else
            {
                float percentScale =
                    (float)UiTracker.GetMenuItem("SAssembliesUITrackerScale").GetValue<Slider>().Value / 100;
                sprite.Sprite.PositionUpdate = delegate
                {
                    return new Vector2(size.Width, size.Height);
                };
                sprite.Sprite.VisibleCondition = sender =>
                {
                    return IsActive() && GetMode(hero.IsEnemy).SelectedIndex != 1;
                };
                sprite.Sprite.Add();
            }
        }
Exemplo n.º 22
0
 public TimedUpdate(int msCount, UpdateMethod up)
 {
     m_Rate = msCount;
     m_Update = up;
     Start();
 }
		void ChangeState(UpdateMethod method, FileVerificationLevel level)
		{
			var proj = UpdatePackageBuilder.Instance.AuProject;
			if (proj == null)
				return;

			if (method == UpdateMethod.AsProject)
			{
				//跟随项目,则删除
				var pi = proj.FindProjectItem(RelativePath);
				if (pi != null)
					proj.Files.Remove(pi);
			}
			else
			{
				var pi = proj.FindProjectItem(RelativePath);
				if (pi == null)
				{
					pi = new ProjectItem()
					{
						Path = RelativePath
					};
					proj.Files.Add(pi);
				}

				pi.FileVerificationLevel = level;
				pi.UpdateMethod = method;
			}
		}
Exemplo n.º 24
0
		/// <summary>
		/// 测试是否具有指定的更新方式
		/// </summary>
		/// <param name="method"></param>
		/// <param name="targetMethod"></param>
		/// <returns></returns>
		public static bool HasMethod(UpdateMethod method, UpdateMethod targetMethod)
		{
			return (method & targetMethod) > 0;
		}
Exemplo n.º 25
0
		/// <summary>
		/// 清除指定的标记位
		/// </summary>
		/// <param name="method"></param>
		/// <param name="flag"></param>
		/// <returns></returns>
		public static UpdateMethod SetUpdateMethodFlag(UpdateMethod method, UpdateMethod flag)
		{
			method |= flag;
			return method;
		}
Exemplo n.º 26
0
 public void UpdateHealth(UpdateMethod updateMethod, int value)
 {
     _health = (updateMethod == UpdateMethod.SET) ? value : _health + value;
 }
Exemplo n.º 27
0
 public OnUpdateCallback(UpdateMethod method)
 {
     Method = method;
 }
		void SetSelectedItemUpdateMethod(UpdateMethod method)
		{
			var items = SelectedItems.Cast<ListViewItem>().Where(s => GetFileUpdateMethod(((KeyValuePair<string, FileInfo>)s.Tag).Key) != method).ToArray();
			if (items.Length == 0) return;

			var group = Groups[(int)method];
			var project = UpdatePackageBuilder.Instance.AuProject;

			var verifyLevel = FileVerificationLevel.Hash | FileVerificationLevel.Size | FileVerificationLevel.Version;
			if (method == UpdateMethod.VersionCompare)
			{
				var dlg = new Dialogs.SelectVerificationLevel() { FileVerificationLevel = verifyLevel };
				if (dlg.ShowDialog() != DialogResult.OK) return;

				verifyLevel = dlg.FileVerificationLevel;
				if ((verifyLevel & FileVerificationLevel.Version) != FileVerificationLevel.None
					&&
					items.Any(s => _versions[((KeyValuePair<string, FileInfo>)s.Tag).Key].IsIllegal())
					&&
					MessageBox.Show("您已经选择版本比较选项,但当前选择的文件中有一个或多个无法识别出有效的版本(主版本号为0),是否确认继续?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes
				)
				{
					return;
				}
			}

			foreach (var item in items)
			{
				var tag = (KeyValuePair<string, FileInfo>)item.Tag;
				var path = tag.Key;

				if (GetFileUpdateMethod(path) == method) continue;

				item.Group = group;

				//处理更新方式
				if (method != UpdateMethod.VersionCompare && _verifyLevels.ContainsKey(path))
				{
					_verifyLevels.Remove(path);
				}
				if (method == UpdateMethod.Always)
				{
					if (_updateMethods.ContainsKey(path)) _updateMethods.Remove(path);
				}
				else
				{
					if (_updateMethods.ContainsKey(path)) _updateMethods[path] = method;
					else _updateMethods.Add(path, method);
				}

				if (method == UpdateMethod.VersionCompare)
				{
					if (_verifyLevels.ContainsKey(path)) _verifyLevels[path] = verifyLevel;
					else _verifyLevels.Add(path, verifyLevel);
				}

				UpdateVerificationLevelDesc(item);

				//处理包项目
				var pi = project.Files.FirstOrDefault(s => string.Compare(s.Path, path, true) == 0);
				if (pi == null)
				{
					pi = new ProjectItem();
					pi.Path = path;
					project.Files.Add(pi);
				}
				pi.UpdateMethod = method;
				pi.FileVerificationLevel = verifyLevel;
			}

			AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
		}
Exemplo n.º 29
0
 public TimedUpdate(int msCount, UpdateMethod up)
 {
     m_Rate = msCount;
     m_Update = up;
     m_CameraTick = new System.Threading.Timer(TickCB, this as object, m_Rate, System.Threading.Timeout.Infinite);
 }
Exemplo n.º 30
0
	public void SetUpdateType( UpdateMethod updateMethod )
	{
		this.updateMethod = updateMethod;
	}
Exemplo n.º 31
0
 public TimedUpdate(int msCount, UpdateMethod up)
 {
     m_Rate   = msCount;
     m_Update = up;
     Start();
 }
Exemplo n.º 32
0
 public void Update()
 {
     UpdateMethod?.Invoke();
 }
Exemplo n.º 33
0
 public SubmoduleEntry(string name, string path, string url, UpdateMethod update)
 {
     Name = name;
     Path = path;
     try { Url = new URIish(url); }
     catch { }
     RawUrl = url;
     Update = update;
 }
Exemplo n.º 34
0
 public SubmoduleEntry(string name, string path, URIish url, UpdateMethod update)
 {
     Name = name;
     Path = path;
     Url = url;
     RawUrl = url != null ? url.ToPrivateString() : null;
     Update = update;
 }
Exemplo n.º 35
0
 public TimedUpdate(int msCount, UpdateMethod up)
 {
     m_Rate       = msCount;
     m_Update     = up;
     m_CameraTick = new System.Threading.Timer(TickCB, this as object, m_Rate, System.Threading.Timeout.Infinite);
 }
Exemplo n.º 36
0
        public VolumetricRendererGame()
        {
            Debug.OnAssert += new EventHandler<DebugEventArgs>(HandleAssert);
            //Debug.BlockAfterAssert = true;

            // Set up and run initial threads.
            //mainThread = Thread.CurrentThread;
            //mainThread.Name = "Main";

            //updateLock = new object();
            //updateThread = new Thread(new ThreadStart(UpdateThread));
            //updateThread.Name = "Update";
            //updateThread.IsBackground = true;
            //updateThread.Start();

            //drawLock = new object();
            //drawThread = new Thread(new ThreadStart(DrawThread));
            //drawThread.Name = "Draw";
            //drawThread.IsBackground = true;
            //drawThread.Start();

            // Set up the game.
            updateMethod = Update_Normal;
            drawMethod = Draw_Normal;
            assertHandled = false;

            Content.RootDirectory = "Content";

            graphicsDM = new GraphicsDeviceManager(this);
            graphicsDM.PreferredBackBufferWidth = 1280;
            graphicsDM.PreferredBackBufferHeight = 960;
            graphicsDM.PreferMultiSampling = false;
            graphicsDM.SynchronizeWithVerticalRetrace = false;
            graphicsDM.IsFullScreen = false;

            input = new InputState();
            screenManager = new ScreenManager(this, input);
            Components.Add(screenManager);

            IsMouseVisible = true;
        }
Exemplo n.º 37
0
 public OnUpdateCallback(UpdateMethod method, float fps)
 {
     Method = method;
     SetRate(fps);
 }
Exemplo n.º 38
0
        /// <summary>
        /// Event handler for an assert.
        /// </summary>
        /// <param name="sender">Because Debug is a static class, this is always NULL.</param>
        /// <param name="args">Info about the assert.</param>
        private void HandleAssert(object sender, DebugEventArgs args)
        {
            updateMethod = Update_Assert;
            drawMethod = Draw_Assert;

            // This method is running on the thread that asserted, so start a new thread for the
            // handler so it can kill off all the worker threads without killing itself.
            //handleAssertThread = new Thread(new ParameterizedThreadStart(HandleAssertThread));
            //handleAssertThread.Name = "HandleAssert";
            //handleAssertThread.IsBackground = true;
            //handleAssertThread.Start(args);
            HandleAssertThread(args);
        }
Exemplo n.º 39
0
        public void Update(Object[] args)
        {
            if (StartMethod != null)
            {
                foreach (var instance in StartList)
                {
                    var node = instance.Node;

                    if (node != null && node.IsEnabled())
                    {
                        if (node.Scene != null)
                        {
                            StartMethod.Invoke(instance, null);
                        }
                    }
                }

                // TODO: need to handle delayed starts when node isn't enabled
                StartList.Clear();
            }

            if (UpdateMethod != null)
            {
                foreach (var instance in Instances)
                {
                    bool remove = false;

                    var node = instance.Node;

                    // TODO: Ideally we want to remove disabled instances,
                    // and re-add them when re-enabled
                    if (node != null /*&& node.IsEnabled()*/)
                    {
                        if (node.Scene != null)
                        {
                            if (node.IsEnabled())
                            {
                                UpdateMethod.Invoke(instance, args);
                            }
                        }
                        else
                        {
                            remove = true;
                        }
                    }
                    else
                    {
                        remove = true;
                    }

                    if (remove)
                    {
                        RemoveList.Add(instance);
                    }
                }
            }

            foreach (var instance in RemoveList)
            {
                Instances.Remove(instance);
            }

            RemoveList.Clear();
        }
Exemplo n.º 40
0
 /// <summary>
 /// 测试是否具有指定的更新方式
 /// </summary>
 /// <param name="method"></param>
 /// <param name="targetMethod"></param>
 /// <returns></returns>
 public static bool HasMethod(UpdateMethod method, UpdateMethod targetMethod)
 {
     return((method & targetMethod) > 0);
 }
Exemplo n.º 41
0
		/// <summary>
		/// 清除指定的标记位
		/// </summary>
		/// <param name="method"></param>
		/// <param name="flag"></param>
		/// <returns></returns>
		public static UpdateMethod ClearUpdateMethodFlag(UpdateMethod method, UpdateMethod flag)
		{
			method &= (~flag);
			return method;
		}
Exemplo n.º 42
0
 /// <summary>
 /// 清除指定的标记位
 /// </summary>
 /// <param name="method"></param>
 /// <param name="flag"></param>
 /// <returns></returns>
 public static UpdateMethod ClearUpdateMethodFlag(UpdateMethod method, UpdateMethod flag)
 {
     method &= (~flag);
     return(method);
 }
Exemplo n.º 43
0
		public static UpdateMethod SetOrClearUpdateMethodFlag(UpdateMethod method, UpdateMethod flag, bool add)
		{
			if (add)
				return SetUpdateMethodFlag(method, flag);
			return ClearUpdateMethodFlag(method, flag);
		}
Exemplo n.º 44
0
 /// <summary>
 /// 清除指定的标记位
 /// </summary>
 /// <param name="method"></param>
 /// <param name="flag"></param>
 /// <returns></returns>
 public static UpdateMethod SetUpdateMethodFlag(UpdateMethod method, UpdateMethod flag)
 {
     method |= flag;
     return(method);
 }
Exemplo n.º 45
0
        public HashTrie <V> AddOrUpdate(int hash, V value, UpdateMethod <V> updateValue = null)
        {
            var index      = hash & LEVEL_MASK; // index from 0 to 31
            var restOfHash = hash >> LEVEL_BITS;

            if (_indexBitmap == 0)
            {
                return(new HashTrie <V>(1u << index, restOfHash == 0 ? (object)value : Empty.AddOrUpdate(restOfHash, value)));
            }

            var nodeCount = _nodes.Length;

            var pastIndexBitmap = _indexBitmap >> index;

            if ((pastIndexBitmap & 1) == 0) // no nodes at the index, could be inserted.
            {
                var subnode = restOfHash == 0 ? (object)value : Empty.AddOrUpdate(restOfHash, value);

                var pastIndexCount = pastIndexBitmap == 0 ? 0 : GetSetBitsCount(pastIndexBitmap);
                var insertIndex    = nodeCount - pastIndexCount;

                var nodesToInsert = new object[nodeCount + 1];
                if (insertIndex != 0)
                {
                    Array.Copy(_nodes, 0, nodesToInsert, 0, insertIndex);
                }
                nodesToInsert[insertIndex] = subnode;
                if (pastIndexCount != 0)
                {
                    Array.Copy(_nodes, insertIndex, nodesToInsert, insertIndex + 1, pastIndexCount);
                }

                return(new HashTrie <V>(_indexBitmap | (1u << index), nodesToInsert));
            }

            var updateIndex = nodeCount == 1 ? 0
                : nodeCount - (pastIndexBitmap == 1 ? 1 : GetSetBitsCount(pastIndexBitmap));

            var updatedNode = _nodes[updateIndex];

            if (updatedNode is HashTrie <V> )
            {
                updatedNode = ((HashTrie <V>)updatedNode).AddOrUpdate(restOfHash, value, updateValue);
            }
            else if (restOfHash != 0) // if we need to update value with node we will move value down to new node sub-nodes at index 0.
            {
                updatedNode = new HashTrie <V>(1u, updatedNode).AddOrUpdate(restOfHash, value, updateValue);
            }
            else // here the actual update should go, cause old and new nodes contain values.
            {
                updatedNode = updateValue == null ? value : updateValue((V)updatedNode, value);
            }

            var nodesToUpdate = new object[nodeCount];

            if (nodesToUpdate.Length > 1)
            {
                Array.Copy(_nodes, 0, nodesToUpdate, 0, nodesToUpdate.Length);
            }
            nodesToUpdate[updateIndex] = updatedNode;

            return(new HashTrie <V>(_indexBitmap, nodesToUpdate));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Tango3DReconstruction"/> class.
        /// </summary>
        /// <param name="resolution">Size in meters of each grid cell.</param>
        /// <param name="generateColor">If true the reconstruction will contain color information.</param>
        /// <param name="spaceClearing">If true the reconstruction will clear empty space it detects.</param> 
        /// <param name="minNumVertices">
        /// If non-zero, any submesh with less than this number of vertices will get removed, assumed to be noise.
        /// </param>
        /// <param name="updateMethod">Method used to update voxels.</param>
        internal Tango3DReconstruction(float resolution, bool generateColor, bool spaceClearing, int minNumVertices,
                                       UpdateMethod updateMethod)
        {
            IntPtr config = API.Tango3DR_Config_create((int)APIConfigType.Context);
            API.Tango3DR_Config_setDouble(config, "resolution", resolution);
            API.Tango3DR_Config_setBool(config, "generate_color", generateColor);
            API.Tango3DR_Config_setBool(config, "use_space_clearing", spaceClearing);
            API.Tango3DR_Config_setInt32(config, "min_num_vertices", minNumVertices);
            API.Tango3DR_Config_setInt32(config, "update_method", (int)updateMethod);

            // The 3D Reconstruction library can not handle a left handed transformation during update.  Instead,
            // transform into the Unity world space via the external_T_tango config.
            APIMatrix3x3 unityWorld_T_startService = new APIMatrix3x3();
            unityWorld_T_startService.SetRow(0, new Vector3(1, 0, 0));
            unityWorld_T_startService.SetRow(1, new Vector3(0, 0, 1));
            unityWorld_T_startService.SetRow(2, new Vector3(0, 1, 0));
            API.Tango3DR_Config_setMatrix3x3(config, "external_T_tango", ref unityWorld_T_startService);
            API.Tango3DR_Config_setBool(config, "use_clockwise_winding_order", true);

            m_context = API.Tango3DR_create(config);
            API.Tango3DR_Config_destroy(config);
        }