/// <summary> /// Update triangle connections and edge error after a edge is collapsed. /// </summary> private void UpdateTriangles(int i0, ref Vertex v, ResizableArray <bool> deleted, ref int deletedTriangles) { Vector3d p; int tcount = v.tcount; var triangles = this.triangles.Data; for (int k = 0; k < tcount; k++) { Ref r = refs[v.tstart + k]; int tid = r.tid; Triangle t = triangles[tid]; if (t.deleted) { continue; } if (deleted[k]) { triangles[tid].deleted = true; ++deletedTriangles; continue; } t[r.tvertex] = i0; t.dirty = true; //t.area = CalculateArea(t.v0, t.v1, t.v2); t.err0 = CalculateError(t.v0, t.v1, out p); t.err1 = CalculateError(t.v1, t.v2, out p); t.err2 = CalculateError(t.v2, t.v0, out p); t.err3 = MathHelper.Min(t.err0, t.err1, t.err2); triangles[tid] = t; refs.Add(r); } }
/// <summary> /// Drops the actual item and stops the ability. /// </summary> private void DropItem() { // DropItem may be triggered by the animation event even when the ability isn't active. if (!IsActive) { return; } // Drop each item. If a drop prefab is specified then the item will be dropped. if (m_DroppedItems == null) { m_DroppedItems = new ResizableArray <GameObject>(); } else { m_DroppedItems.Clear(); } for (int i = 0; i < m_Items.Length; ++i) { if (m_Items[i] != null) { var droppedItem = m_Inventory.RemoveItem(m_Items[i].ItemIdentifier, m_Items[i].SlotID, 1, true); if (droppedItem != null) { m_DroppedItems.Add(droppedItem); } m_Items[i] = null; } } StopAbility(); }
public void AddLastRange(ReadOnlySpan <T> items) { lock (SyncRoot) { if (capacity <= buffer.Count + items.Length) { // calc remove count var remCount = Math.Min(buffer.Count, buffer.Count + items.Length - capacity); using (var ys = new ResizableArray <T>(remCount)) { for (int i = 0; i < remCount; i++) { ys.Add(buffer.RemoveFirst()); } CollectionChanged?.Invoke(NotifyCollectionChangedEventArgs <T> .Remove(ys.Span, 0)); } } var index = buffer.Count; var span = items; if (span.Length > capacity) { span = span.Slice(span.Length - capacity); } foreach (var item in span) { buffer.AddLast(item); } CollectionChanged?.Invoke(NotifyCollectionChangedEventArgs <T> .Add(span, index)); } }
/// <summary> /// Get all materials of a mesh. /// </summary> static public Graphics.Materials.MaterialAPI[] GetMaterials(this ModelMesh mesh) { ResizableArray <Graphics.Materials.MaterialAPI> ret = new ResizableArray <Graphics.Materials.MaterialAPI>(); foreach (Effect effect in mesh.Effects) { ret.Add(effect.Tag as Graphics.Materials.MaterialAPI); } ret.Trim(); return(ret.InternalArray); }
public void AddRange(ReadOnlySpan <T> items) { lock (SyncRoot) { using (var list = new ResizableArray <T>(items.Length)) { foreach (var item in items) { if (set.Add(item)) { list.Add(item); } } CollectionChanged?.Invoke(NotifyCollectionChangedEventArgs <T> .Add(list.Span, -1)); } } }
private Task <BucketContainer> StartProcessingEventsWithPipeline( IEventReader reader, IProgress <int> progress) { var tcs = new TaskCompletionSource <BucketContainer>(); var thread = new Thread(() => { try { var bucketsList = new ResizableArray <Bucket>(); double processedEventsCount = 0; int bucketCount = 0; foreach (var bucket in reader.GetAllBuckets()) { processedEventsCount += bucket.Events.Length; bucketsList.Add(bucket); _eventProcessor.ProcessBucket(bucketsList.GetArraySegment(), bucketCount); if (reader.TotalEventsCount > 0) { progress.Report((int)Math.Min(processedEventsCount / reader.TotalEventsCount * 100, 100)); } bucketCount++; } progress.Report(100); var buckets = bucketsList.ToArray(); bucketsList = null; var container = new BucketContainer(buckets, reader.FirstTimestamp); _eventProcessor.Complete(container); tcs.SetResult(container); } catch (TaskCanceledException) { tcs.SetCanceled(); } catch (Exception exc) { tcs.SetException(exc); } }); thread.Start(); return(tcs.Task); }
public void AddRange(IEnumerable <T> items) { lock (SyncRoot) { if (!items.TryGetNonEnumeratedCount(out var capacity)) { capacity = 4; } using (var list = new ResizableArray <T>(capacity)) { foreach (var item in items) { if (set.Add(item)) { list.Add(item); } } CollectionChanged?.Invoke(NotifyCollectionChangedEventArgs <T> .Add(list.Span, -1)); } } }
public void Add(T item) { _items.Add(item); }
public void Append(char character) { _buffer.Add((byte)character); _buffer.Add((byte)(character >> 8)); }