/// <summary> /// Makes sure that the line buffer has enough capacity to fit the specified /// amount of additional characters in it /// </summary> /// <param name="additionalSize">Number of required additional characters</param> private void ensureAdditionalStoreCapacity(int additionalSize) { // See whether we need to do anything at all bool needsExpansion = ((this.storedByteCount + additionalSize) > this.storedBytes.Length); // If we need to expand, resize the store buffer to the next highest power of 2 if (needsExpansion) { int newSize = IntegerHelper.NextPowerOf2( this.storedByteCount + additionalSize ); byte[] newStoredBytes = new byte[newSize]; Array.Copy(this.storedBytes, newStoredBytes, this.storedByteCount); this.storedBytes = newStoredBytes; } }
/// <summary> /// Updates the particle system and primitive batch holder arrays if needed /// </summary> private void updateHolderArraysIfNeeded() { if (this.holderArraysDirty) { if (this.particleSystemHolders.Length < this.particleSystems.Count) { this.particleSystemHolders = new IParticleSystemHolder[ IntegerHelper.NextPowerOf2(this.particleSystems.Count) ]; } if (this.primitiveBatchHolders.Length < this.primitiveBatches.Count) { this.primitiveBatchHolders = new PrimitiveBatchHolder[ IntegerHelper.NextPowerOf2(this.primitiveBatches.Count) ]; } this.primitiveBatches.Values.CopyTo(this.primitiveBatchHolders, 0); this.particleSystems.Values.CopyTo(this.particleSystemHolders, 0); this.holderArraysDirty = false; } }