How do I expand bits for any N dimension?( to a reasonable N anyways)

3 weeks ago 7
ARTICLE AD BOX

How do I expand bits for any N dimension for a morton code generator?
Currently I have this function:

uint32_t ExpandBits(uint32_t Value) { Value &= 0xFFFF; Value = (Value | Value << 8) & 0x00FF00FF; Value = (Value | Value << 4) & 0x0F0F0F0F; Value = (Value | Value << 2) & 0x33333333; Value = (Value | Value << 1) & 0x55555555; return Value; };

it works good for two dimensions, but im not sure how to expand it for N dimensions like 3d and above;

Read Entire Article