Show More
Commit Description:
Fix issue with simulation....
Commit Description:
Fix issue with simulation.
Previously, if there was more than one tick being advanced at once, it would
overshoot how many ticks it covered. So if it was covering 5 ticks and each
tick happens every 100 units, rather than recording that it had simulated
through t= 500, it would increase the cumulative time for each tick, recording
that it had simulated through t=2500.
Add error message, too.
References:
File last commit:
Show/Diff file:
Action:
FNA/src/Graphics/TextureCollection.cs
103 lines | 1.9 KiB | text/x-csharp | CSharpLexer
103 lines | 1.9 KiB | text/x-csharp | CSharpLexer
r0 | #region License | |||
/* FNA - XNA4 Reimplementation for Desktop Platforms | ||||
r690 | * Copyright 2009-2022 Ethan Lee and the MonoGame Team | |||
r0 | * | |||
* Released under the Microsoft Public License. | ||||
* See LICENSE for details. | ||||
*/ | ||||
#endregion | ||||
#region Using Statements | ||||
using System; | ||||
#endregion | ||||
namespace Microsoft.Xna.Framework.Graphics | ||||
{ | ||||
public sealed class TextureCollection | ||||
{ | ||||
#region Public Array Access Property | ||||
public Texture this[int index] | ||||
{ | ||||
get | ||||
{ | ||||
return textures[index]; | ||||
} | ||||
set | ||||
{ | ||||
#if DEBUG | ||||
// XNA checks for disposed textures here! -flibit | ||||
r690 | if (value != null) | |||
r0 | { | |||
r690 | if (value.IsDisposed) | |||
{ | ||||
throw new ObjectDisposedException( | ||||
value.GetType().ToString() | ||||
); | ||||
} | ||||
if (!ignoreTargets) | ||||
for (int i = 0; i < value.GraphicsDevice.renderTargetCount; i += 1) | ||||
{ | ||||
if (value == value.GraphicsDevice.renderTargetBindings[i].RenderTarget) | ||||
{ | ||||
throw new InvalidOperationException( | ||||
"The render target must not be set on the" + | ||||
" device when it is used as a texture." | ||||
); | ||||
} | ||||
} | ||||
r0 | } | |||
#endif | ||||
textures[index] = value; | ||||
modifiedSamplers[index] = true; | ||||
} | ||||
} | ||||
#endregion | ||||
r690 | #region Internal Variables | |||
internal bool ignoreTargets; | ||||
#endregion | ||||
r0 | #region Private Variables | |||
private readonly Texture[] textures; | ||||
private readonly bool[] modifiedSamplers; | ||||
#endregion | ||||
#region Internal Constructor | ||||
internal TextureCollection( | ||||
int slots, | ||||
bool[] modSamplers | ||||
) { | ||||
textures = new Texture[slots]; | ||||
modifiedSamplers = modSamplers; | ||||
for (int i = 0; i < textures.Length; i += 1) | ||||
{ | ||||
textures[i] = null; | ||||
} | ||||
r690 | ignoreTargets = false; | |||
} | ||||
#endregion | ||||
#region Internal Functions | ||||
internal void RemoveDisposedTexture(Texture tex) | ||||
{ | ||||
for (int i = 0; i < textures.Length; i += 1) | ||||
{ | ||||
if (tex == textures[i]) | ||||
{ | ||||
this[i] = null; | ||||
} | ||||
} | ||||
r0 | } | |||
#endregion | ||||
} | ||||
} | ||||