google / mathfu

C++ math library developed primarily for games focused on simplicity and efficiency.

Home Page:http://google.github.io/mathfu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vector and matrix copy to C array.

panzergame opened this issue · comments

I'm trying to use mathfu in this project: https://github.com/UPBGE/blender, but i could not find a simple way to copy data from a vector or matrix to a C array.
The current library we use has a function named getValue which is used as below:

float a[3];
vec.getValue(a); // content of vec is copied to the a array

But i can't found a way to do similar work using VectorPack and Vector::Pack.

So, what is the simple way to copy the vector content to an array assuming this array could not be replaced by VectorPack ?

Yeah, there's no convenient function for that, and I agree that be nice to have.

For now you'd have to do:

memcpy(&a[0], &vec[0], sizeof(a));

In this commit : UPBGE/upbge@77dee10 I implemented some operator to copy to a C array and to get a constant C array pointer.

Is these functions safe with SIMD ?

Yes, looks safe to me.