From b900dfde2d332611ac16175b3df9065144dfbc34 Mon Sep 17 00:00:00 2001 From: RUSshy <18348637+RUSshy@users.noreply.github.com> Date: Sat, 17 Jul 2021 14:04:10 +0200 Subject: [PATCH] Update handles.zig --- zig-ecs/src/ecs/handles.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zig-ecs/src/ecs/handles.zig b/zig-ecs/src/ecs/handles.zig index e444fa3..c4d9f5a 100644 --- a/zig-ecs/src/ecs/handles.zig +++ b/zig-ecs/src/ecs/handles.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const registry = @import("registry.zig"); /// generates versioned "handles" (https://floooh.github.io/2018/06/17/handles-vs-pointers.html) /// you choose the type of the handle (aka its size) and how much of that goes to the index and the version. @@ -38,7 +39,6 @@ pub fn Handles(comptime HandleType: type, comptime IndexType: type, comptime Ver return h; } } - return null; } }; @@ -59,15 +59,15 @@ pub fn Handles(comptime HandleType: type, comptime IndexType: type, comptime Ver } pub fn extractId(_: Self, handle: HandleType) IndexType { - return @truncate(IndexType, handle); + return @truncate(IndexType, handle & @as(IndexType, registry.entity_traits.entity_mask)); } pub fn extractVersion(_: Self, handle: HandleType) VersionType { - return @truncate(VersionType, handle >> @bitSizeOf(IndexType)); + return @truncate(VersionType, handle >> registry.entity_traits.entity_shift); } fn forge(id: IndexType, version: VersionType) HandleType { - return id | @as(HandleType, version) << @bitSizeOf(IndexType); + return id | @as(HandleType, version) << registry.entity_traits.entity_shift; } pub fn create(self: *Self) HandleType {