SSE2: Add converter function for vectors

--HG--
branch : sse2
hg/feature/sse2
kaetemi 11 years ago
parent 3ec065c9a2
commit e66485bca9

@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// NLMISC includes
// Project includes
#include "vector.h"
namespace NLMISC {
@ -687,6 +688,36 @@ NL_FORCE_INLINE void swapW(CVector4F &left, CVector4F &right)
}
NL_FORCE_INLINE CVector toVector(const CVector3F &v)
{
#ifdef NL_HAS_SSE2
union { __m128 mm; float arr[4]; } temp;
temp.mm = v.mm;
CVector res;
res.x = temp.arr[0];
res.y = temp.arr[1];
res.z = temp.arr[2];
return res;
#else
CVector res;
res.x = v.x;
res.y = v.y;
res.z = v.z;
return res;
#endif
}
NL_FORCE_INLINE CVector3F set3F(const CVector &v)
{
return set3F(v.x, v.y, v.z);
}
NL_FORCE_INLINE CVector4F set4F(const CVector &v, float w)
{
return set4F(v.x, v.y, v.z, w);
}
} /* namespace NLMISC */
#endif /* #ifndef NLMISC_VECTORF_ACCESSORS_H */

Loading…
Cancel
Save