-
|
Hello! I am trying to define a special entity registry that uses a smaller entity type size (uint16_t, specifically). I am trying this: I declare the traits like so: (Yes, 14 bits for id and merely 2 bits for version is enough for my purposes) And then try to use my registry given by: However if I try to compile I get this: I assume I do not need to implement every single member needed for the entity traits, but I don't understand what is the correct way to set this up. Can someone point me to how am I supposed to create a registry with such entity traits? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Unless you want the same traits for all entity types based on enum my_own_entity : std::uint16_t {};
struct my_own_entity_traits {
using value_type = my_own_entity;
using entity_type = std::uint16_t;
using version_type = std::uint8_t;
static constexpr entity_type entity_mask = (1u << 14) - 1;
static constexpr entity_type version_mask = (1u << 2) - 1;
};
template<>
struct entt::entt_traits<my_own_entity>: entt::basic_entt_traits<my_own_entity_traits> {}; |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the reply! I tried a couple things going from your guidance but I could still not make it to work. It seems to me that overall using short types is not supported by the library out of the box. For example after trying this which is the simplest I could do exemplify the issues I run into: I got this a type cast error in I then went ahead and hacked the code in there to do type casts for the bitwise operators (which return an int type), but then I just hit: If I do something more inline to what you suggested I get a complain that traits for I'll grant that generally using a short type for entity is not super useful in general, but I am still surprised I am the first to try it! |
Beta Was this translation helpful? Give feedback.
Oh, yeah, 2020, here we go: removed support for 16b identifiers.
It's been too long to remember the reason, but I think it's something along the lines of too much trouble, no benefit.
With a slightly suboptimal version, the number of entities was still negligible for any application.