Usage of Bit fields

Hey guys,

I was wondering why there is an extensive use of bit fields in the core code of the engine and also in the examples that Epic made. Is it because of memory optimization reasons or is there some compiler optimization in the way they’re handled for example? I understand that they’re useful for flags and the such but sometimes i don’t get why a uint_32 is being used for example instead of a uint_8 for setting 3 bits. Portability? :smiley: excuse me if this is a naive question but it has been troubling me for some time

Only 3 bits of the uint_32 are used. The next variable will use the next bits

For example:

uint_32  var1 : 3;
uint_32  var2 : 6;

Uses only 9 bits of the 32. I still have 23 bits to spare for other variables.
Yes it’s an optimization thing. This way many variables are stored tightly, while maintaining pretty names and easy to use.
Modern computer’s bottleneck is data transfer.