CI / build-test (push) Failing after 1m8s
Add MrGameEng.AI utility-AI module; format codebase with CSharpier New MrGameEng.AI module (ResponseCurve, Consideration, UtilityAction, UtilityAi selector, Blackboard) plus CSharpier formatting applied across the whole engine. Documents the CSharpier convention in CLAUDE.md. @
26 lines
954 B
C#
26 lines
954 B
C#
namespace MrGameEng.Graphics;
|
|
|
|
/// <summary>
|
|
/// Builds the 64-bit sort key the batcher orders sprites by:
|
|
/// layer (8 bits) → depth (32 bits) → texture (24 bits).
|
|
/// Texture bits only group equal textures for batching; collisions are harmless.
|
|
/// </summary>
|
|
public static class SpriteSortKey
|
|
{
|
|
/// <summary>Composes a sort key from layer, depth and texture grouping key.</summary>
|
|
public static ulong Make(byte layer, float depth, int textureKey) =>
|
|
((ulong)layer << 56)
|
|
| ((ulong)DepthToSortableBits(depth) << 24)
|
|
| ((uint)textureKey & 0xFF_FFFF);
|
|
|
|
/// <summary>
|
|
/// Maps a float to bits whose unsigned order matches the float order
|
|
/// (negative depths sort before positive ones).
|
|
/// </summary>
|
|
public static uint DepthToSortableBits(float depth)
|
|
{
|
|
var bits = BitConverter.SingleToUInt32Bits(depth);
|
|
return (bits & 0x8000_0000) != 0 ? ~bits : bits | 0x8000_0000;
|
|
}
|
|
}
|