SSE2: Add a few useful functions

--HG--
branch : sse2
hg/feature/sse2
kaetemi 11 years ago
parent 80f3516ef5
commit 26f9b25f65

@ -334,12 +334,11 @@ public:
CVector mulVector(const CVector &v) const; CVector mulVector(const CVector &v) const;
/// Multiply a point. ie v.w=1 so the Translation component do affect result. Projection doesn't affect result. /// Multiply a point. ie v.w=1 so the Translation component do affect result. Projection doesn't affect result.
CVector mulPoint(const CVector &v) const; CVector mulPoint(const CVector &v) const;
CVector3F mulPoint(const CVector3F &v) const;
/** Multiply a point. \sa mulPoint /** Multiply a point. \sa mulPoint
*/ */
CVector operator*(const CVector &v) const NL_FORCE_INLINE CVector operator*(const CVector &v) const { return mulPoint(v); }
{ NL_FORCE_INLINE CVector3F operator*(const CVector3F &v) const { return mulPoint(v); }
return mulPoint(v);
}
/// Multiply with an homogeneous vector /// Multiply with an homogeneous vector
CVectorH operator*(const CVectorH& v) const; CVectorH operator*(const CVectorH& v) const;
@ -363,11 +362,11 @@ public:
friend CPlane operator*(const CPlane &p, const CMatrix &m); friend CPlane operator*(const CPlane &p, const CMatrix &m);
#ifdef NL_HAS_SSE2 #ifdef NL_HAS_SSE2
inline CMatrix44F &getMatrix() { testExpandRot(); testExpandProj(); return MF; } inline CMatrix44F &getMatrix44F() { testExpandRot(); testExpandProj(); return MF; }
inline const CMatrix44F &getMatrix() const { testExpandRot(); testExpandProj(); return MF; } inline const CMatrix44F &getMatrix44F() const { testExpandRot(); testExpandProj(); return MF; }
#else #else
inline CMatrix44F &getMatrix() { return reinterpret_cast<CMatrix44F &>(*this); } inline CMatrix44F &getMatrix44F() { return reinterpret_cast<CMatrix44F &>(*this); }
inline const CMatrix44F &getMatrix() const { return reinterpret_cast<const CMatrix44F &>(*this); } inline const CMatrix44F &getMatrix44F() const { return reinterpret_cast<const CMatrix44F &>(*this); }
#endif #endif
private: private:

@ -687,6 +687,7 @@ NL_FORCE_INLINE CVector4F accumulateSplat(const CVector4F &v)
} }
*/ */
NL_ASSIMILATE_BI_FUNCTION(CVector3F, add, const CVector3F &)
NL_ASSIMILATE_BI_FUNCTION(CVector2F, minF, const CVector2F &) NL_ASSIMILATE_BI_FUNCTION(CVector2F, minF, const CVector2F &)
NL_ASSIMILATE_BI_FUNCTION(CVector2F, maxF, const CVector2F &) NL_ASSIMILATE_BI_FUNCTION(CVector2F, maxF, const CVector2F &)

@ -1325,6 +1325,34 @@ CVector CMatrix::mulPoint(const CVector &v) const
return ret; return ret;
} }
// ======================================================================================================
CVector3F CMatrix::mulPoint(const CVector3F &v) const
{
#ifdef NL_HAS_SSE2
CVector3F ret;
if (hasRot())
{
ret = add(
mul(xyz(MF.a), xxx(v)),
mul(xyz(MF.b), yyy(v)),
mul(xyz(MF.c), zzz(v)));
}
else
{
ret = v;
}
if (hasTrans())
{
ret = add(
ret,
xyz(MF.d));
}
return ret;
#else
return set3F(mulPoint(toVector(v)));
#endif
}
/* /*
* Multiply * Multiply

Loading…
Cancel
Save