Skip to content

Commit

Permalink
Added missing entity traits changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RUSshy committed Jul 17, 2021
1 parent bcdb34a commit adad896
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/ecs/entity.zig
Expand Up @@ -7,13 +7,13 @@ pub const EntityTraitsSize = enum { small, medium, large };

pub fn EntityTraitsType(comptime size: EntityTraitsSize) type {
return switch (size) {
.small => EntityTraitsDefinition(u16, u12, u4),
.medium => EntityTraitsDefinition(u32, u20, u12),
.large => EntityTraitsDefinition(u64, u32, u32),
.small => EntityTraitsDefinition(u16, u12, u4, 0xFFFF, 0xFFF, 10),
.medium => EntityTraitsDefinition(u32, u20, u12, 0xFFFFF, 0xFFF, 20),
.large => EntityTraitsDefinition(u64, u32, u32, 0xFFFFFFFF, 0xFFFFFFFF, 32),
};
}

fn EntityTraitsDefinition(comptime EntityType: type, comptime IndexType: type, comptime VersionType: type) type {
fn EntityTraitsDefinition(comptime EntityType: type, comptime IndexType: type, comptime VersionType: type, comptime EntityMask: EntityType, comptime VersionMask: EntityType, comptime EntityShift: EntityType) type {
std.debug.assert(@typeInfo(EntityType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(EntityType)) == EntityType);
std.debug.assert(@typeInfo(IndexType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(IndexType)) == IndexType);
std.debug.assert(@typeInfo(VersionType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(VersionType)) == VersionType);
Expand All @@ -26,9 +26,10 @@ fn EntityTraitsDefinition(comptime EntityType: type, comptime IndexType: type, c
index_type: type = IndexType,
version_type: type = VersionType,
/// Mask to use to get the entity index number out of an identifier
entity_mask: EntityType = std.math.maxInt(IndexType),
entity_mask: EntityType = EntityMask,
/// Mask to use to get the version out of an identifier
version_mask: EntityType = std.math.maxInt(VersionType),
version_mask: EntityType = VersionMask,
entity_shift: EntityType = EntityShift,

pub fn init() @This() {
return @This(){};
Expand Down

0 comments on commit adad896

Please sign in to comment.