Suppose I create a bitmask blueprint enum, with values ValA, ValB, ValC and ValD.
Now, I want to keep a bitmask variable that contains zero or more of these bits set.
I can’t figure out how I’m supposed to do this.
There is something called a bitmask integer.
I can specify my enum as the “type” of that bitmask.
There is a “Set” operation for this bitmask where I can choose one of the various bit values.
However, if I already have one of the enum values, how do I set that into the given variable?
I can convert-byte-to-int, and then route that into the bitmask-set-node, but the value of “ValD” is actually 3, not 8 as I would expect.
Does “Set” for a bitmask value do the appropriate left-shift for me?
It doesn’t seem like it to me. The value of the bitmak integer is “3” after the SET, not “8.”
Is casting enum byte to integer what I should do?
It would seem like enum bitmask “Union” and “Intersect” and “Disjoint” operations would be great Nodes to have.
“I have these bits, add them to those other bits over there.” (OR)
“I have these bits, remove them from those other bits over there.” (AND NOT)
“I have these bits, only keep those other bits over there that match.” (AND)
Maybe I’m just misunderstanding blueprint bitmask enums. They don’t seem to generate any values different from a regular enum.
I e, checking the “bitmask” checkbox does not change the values to 1, 2, 4, 8, 16 … – I still get 0, 1, 2, 3, 4.
That being said, there are no bit shift operators in the Blueprint math library, so I’ll have to create those for myself.
No, that’s not the problem.
My problem is that I want to pipe which bit to set into the left input of the SET operation.
But, the actual values of the enum types are not bit values, but just sequential integers.
I need to create the correct value to put in by left-shifting by the value of the enum.
Except there is no left-shift operator in the Blueprint system!
I believe that flagging enum with bitmask flag does not change the behaviour of the enumerator itself. It does allow you to use that enum as a bitmasked int, though. Consider the following:
So, you’re suggesting that the intended use case is that, every time I want to use a bitmask enum to specify which flag I want to set or clear, I have to create a “select” node and manually set up each of the values within the bitmask?
That’s … not optimal! Maybe I should send my byte-to-bitmask node back as a pull request !