Handmade Hero»Forums»Code
Simon Anciaux
1337 posts
Questions about flags in day 66
Edited by Simon Anciaux on
Shouldn't the first flag value be set to 1 (1 << 0) instead of 2 (1 << 1) ?

The isSet function returns true if any of the flags is set, not all the flags are set. Is this the intended behaviour ? Should we rename it to isAnySet ?

There is a way to specify that an enum must be of a specific integer type (might be c++11). But it doesn't help with the compiler error. Using ( 1u << 31 ) seems to work.
1
2
3
4
5
6
7
enum sim_entity_flags : uint32
{
    EntityFlag_Collides = (1 << 1),
    EntityFlag_Nonspatial = (1 << 2),
    
    EntityFlag_Simming = (1u << 31),
};

Edit: the combination of the two seems to work.
Kim
Kim Jørgensen
64 posts
Questions about flags in day 66
There are many not checks on EntityFlag_Nonspatial. Maybe it would better to rename it to EntityFlag_Spatial?