class BWAVector3 { private: float x; float y; float z; public: ... float& operator[] (const int index); }; float& BWAVector3::operator[] (const int index) { if (index == 0) { return x; } else if (index == 1) { return y; } else { return z; } }(Thanks for the submission Graham Wihlidal)
Epic failures in the game development field.
This blog covers funny/weird issues and bugs from games that happened during development.
Send your own contributions to igetyourfail at repi.se (can be anonymous if specified)
Tuesday, April 30, 2013
Highly optimized and accurate vector subscript operator
Subscribe to:
Post Comments (Atom)
2 comments:
Would you deem something like this acceptable?
float operator[](int idx) { return *((float*)&x)+idx); }
do a union with float[3].
Post a Comment