This will work a lot better
Code: Select all
//! Transforms a plane by this matrix
template <class T>
inline void CMatrix4<T>::transformPlane( core::plane3d<f32> &plane) const
{
core::plane3df temp;
transformPlane(plane,temp);
plane = temp;
}
//! Transforms a plane by this matrix
template <class T>
inline void CMatrix4<T>::transformPlane( const core::plane3d<f32> &in, core::plane3d<f32> &out) const
{
CMatrix4<T> transposedInverse(*this, EM4CONST_INVERSE);
out.Normal.X = in.Normal.X*transposedInverse[0] + in.Normal.Y*transposedInverse[1] + in.Normal.Z*transposedInverse[2] + in.D*transposedInverse[3];
out.Normal.Y = in.Normal.X*transposedInverse[4] + in.Normal.Y*transposedInverse[5] + in.Normal.Z*transposedInverse[6] + in.D*transposedInverse[7];
out.Normal.Z = in.Normal.X*transposedInverse[8] + in.Normal.Y*transposedInverse[9] + in.Normal.Z*transposedInverse[10] + in.D*transposedInverse[11];
out.D = in.Normal.X*transposedInverse[12] + in.Normal.Y*transposedInverse[13] + in.Normal.Z*transposedInverse[14] + in.D*transposedInverse[15];
}