Update README.md to include project description, developer documentation links, and license information.
CI / build-test (push) Successful in 1m6s
CI / build-test (push) Successful in 1m6s
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user