redorav / hlslpp

Math library using hlsl syntax with SSE/NEON support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add operator [ ]

redorav opened this issue · comments

For vectors and matrices. Vectors return a float1, matrices a float4

I think this solution will necessarily be less efficient than using the swizzles directly, because doing something like

vector[0] = vector[1]

will swizzle twice. Since these kinds of operations are SIMD-unfriendly anyway, it won't be such a big deal. In the case of matrices, returning a float4 is enough and won't incur in any penalty. As a bonus, if a matrix does something like matrix[0][0], this will use the [] operator of the matrix and the [] operator of the vector, and it will be able to index a single float1

Close in favor of #63