I am obviously trying to use the core engine types and structures whenever possible rather than duplicating things unnecessarily, however I was very surprised when I discovered that a bug I had was caused because I’d been wrong in assuming that the EAxis enumeration corresponded to the 0-based index of the components of a vector.
namespace EAxis
{
enum Type
{
None,
X,
Y,
Z,
}
}
So X is 1, meaning I can’t do the following:
EAxis::Type axis = GetAxisFromSomewhere();
FVector vector = SomeVector;
float component = vector[axis];
There are heaps of times I want to manipulate components based on some runtime dependent axis. If I use EAxis, I need to either remember to add “-1” all over the place, or resort to switching instead leading to code like this.
Then I came across the [FVector::operator code and now I’m really confused. Am I completely off here and writing out hard coded accesses with if-elses is actually faster than the non-branching integer indexing alternative?
Very interested in any reasons or opinions on this.