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.
File last commit:
Show/Diff file:
Action:
ImGui.NET/RangeAccessor.cs
68 lines | 1.8 KiB | text/x-csharp | CSharpLexer
using System;
using System.Runtime.CompilerServices;
using System.Text;
namespace ImGuiNET
{
public unsafe struct RangeAccessor<T> where T : struct
{
private static readonly int s_sizeOfT = Unsafe.SizeOf<T>();
public readonly void* Data;
public readonly int Count;
public RangeAccessor(IntPtr data, int count) : this(data.ToPointer(), count) { }
public RangeAccessor(void* data, int count)
{
Data = data;
Count = count;
}
public ref T this[int index]
{
get
{
if (index < 0 || index >= Count)
{
throw new IndexOutOfRangeException();
}
return ref Unsafe.AsRef<T>((byte*)Data + s_sizeOfT * index);
}
}
}
public unsafe struct RangePtrAccessor<T> where T : struct
{
public readonly void* Data;
public readonly int Count;
public RangePtrAccessor(IntPtr data, int count) : this(data.ToPointer(), count) { }
public RangePtrAccessor(void* data, int count)
{
Data = data;
Count = count;
}
public T this[int index]
{
get
{
if (index < 0 || index >= Count)
{
throw new IndexOutOfRangeException();
}
return Unsafe.Read<T>((byte*)Data + sizeof(void*) * index);
}
}
}
public static class RangeAccessorExtensions
{
public static unsafe string GetStringASCII(this RangeAccessor<byte> stringAccessor)
{
return Encoding.ASCII.GetString((byte*)stringAccessor.Data, stringAccessor.Count);
}
}
}