hrydgard/ppsspp — pull request #2834 by neobrain (2013-07-18 18:54:12+00:00)
Title: Math3d extensions

**Build should be fixed now, tested on gcc 4.7.2 and msvc2010**

Enhances the feature set of the existing utility Vec3 class by:
- supporting arbitrary base types for each component (e.g. Vec3\, Vec3\)
- supporting two-component and four-component vectors
- supporting vectors acting purely on references, thus being effective on memory usage (although I guess the compiler should've done this before already)
- supporting fast access of individual vector components as a subvector (e.g Vec4::rgb() returns a Vec3Ref consisting of references to the r, g, and b components)
- supporting more flexible component naming (e.g. "rgba" or "xyzw")

Additionally, this patch
- cleanly abstracts using Vec3 as a color or as an actual position vector.
- fixes some confusing oddities of the Vec3 API.
- might fix bugs caused by incorrect constructor usage (see below for details).

Changes for other people who used the code before:
- The star operator (*) refers to per-component product now (i.e. Vec2(v1.x*v1.x,v2.y*v2.y)) instead of the dot product. This is more consistent with what other APIs are doing (most notably GLSL/HLSL). For the dot product, a new Dot() function has been introduced. Additionally, Lerp has been made a global function instead of a VecXRef method. Existing code has been fixed to respect these changes.
- The % operator has been removed because it's not clear what it means. The new Cross() function should be used instead. There was no code using this functionality.
- The Vec3(u32 rgb) constructor has been removed due to its ambiguity. There have been some cases where the wrong constructor has been actually used, so this might even fix a bug. Anyway, instead the new static member functions Vec3::FromRGB and Vec4::FromRGBA should be used instead.
- What used to be Vec3 (i.e. a three-component vector acting on floats) is now Vec3f.