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/ImVector.cs
75 lines | 1.9 KiB | text/x-csharp | CSharpLexer
using System;
using System.Runtime.CompilerServices;
namespace ImGuiNET
{
public unsafe struct ImVector
{
public readonly int Size;
public readonly int Capacity;
public readonly IntPtr Data;
public ref T Ref<T>(int index)
{
return ref Unsafe.AsRef<T>((byte*)Data + index * Unsafe.SizeOf<T>());
}
public IntPtr Address<T>(int index)
{
return (IntPtr)((byte*)Data + index * Unsafe.SizeOf<T>());
}
}
public unsafe struct ImVector<T>
{
public readonly int Size;
public readonly int Capacity;
public readonly IntPtr Data;
public ImVector(ImVector vector)
{
Size = vector.Size;
Capacity = vector.Capacity;
Data = vector.Data;
}
public ImVector(int size, int capacity, IntPtr data)
{
Size = size;
Capacity = capacity;
Data = data;
}
public ref T this[int index] => ref Unsafe.AsRef<T>((byte*)Data + index * Unsafe.SizeOf<T>());
}
public unsafe struct ImPtrVector<T>
{
public readonly int Size;
public readonly int Capacity;
public readonly IntPtr Data;
private readonly int _stride;
public ImPtrVector(ImVector vector, int stride)
: this(vector.Size, vector.Capacity, vector.Data, stride)
{ }
public ImPtrVector(int size, int capacity, IntPtr data, int stride)
{
Size = size;
Capacity = capacity;
Data = data;
_stride = stride;
}
public T this[int index]
{
get
{
byte* address = (byte*)Data + index * _stride;
T ret = Unsafe.Read<T>(&address);
return ret;
}
}
}
}