# HG changeset patch # User spq@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1216053567 0 # Node ID 9ec572a5a9441527617a06e101b3e4db062d4a61 # Parent 47979f9dce558b9d2dbed8be190b35dd08e24434 reworked matrix vector multiplication, patch by yonibear diff -r 47979f9dce55 -r 9ec572a5a944 engine/core/util/math/matrix.h --- a/engine/core/util/math/matrix.h Mon Jul 14 14:41:12 2008 +0000 +++ b/engine/core/util/math/matrix.h Mon Jul 14 16:39:27 2008 +0000 @@ -210,25 +210,11 @@ /** Transform given point using this matrix */ inline PointType3D operator* (const PointType3D& vec) { - PointType3D ret(T(0)); - for (register unsigned j = 0; j < 3; ++j) - for (register unsigned i = 0; i < 3; ++i) - ret.val[j] += vec.val[i]*m[j+i*4]; //scale and rotate disregarding w scaling - - for (register unsigned i = 0; i < 3; ++i) - ret.val[i] += m[i+3*4]; //translate - - //do w scaling - T w = m[15]; - for (register unsigned i = 0; i < 3; ++i) - w += vec.val[i]*m[3+i*4]; - - register T resip = 1/w; - - for (register unsigned i = 0; i < 3; ++i) - ret[i] *= resip; - - return ret; + return PointType3D ( + vec.x * m0 + vec.y * m4 + vec.z * m8 + m12, + vec.x * m1 + vec.y * m5 + vec.z * m9 + m13, + vec.x * m2 + vec.y * m6 + vec.z * m10 + m14 + ); } /** Direct access to the matrix elements, just remember they are in column major format!!