Cloth: Fix mistake in big matrix multiplication

Only the upper triangle of the block matrix is stored, thus when
executing operations on the lower triangle, each block must be
transposed. This transposition was not ocurring in the matrix-vector
multiplication function, which is fixed by this commit.

Reviewed By: brecht

Differential Revision: http://developer.blender.org/D3619
This commit is contained in:
Luca Rood 2018-08-17 13:08:47 +02:00
parent 1a7837596c
commit b30d103cf6
Notes: blender-bot 2023-05-03 10:14:48 +02:00
Referenced by issue #56722, Crash - Entering mesh Edit Mode
Referenced by issue #56559, UVProject modifier missing function and crashes
Referenced by issue #56544, Blender 2.80 crashes at startup
Referenced by issue #56545, Normal map node with named UV map crashes material preview
Referenced by issue #56550, Blender2.8 crash when going out of editmode with bolean + bevel modifiers
1 changed files with 10 additions and 3 deletions

View File

@ -456,6 +456,13 @@ DO_INLINE void muladd_fmatrix_fvector(float to[3], float matrix[3][3], float fro
to[2] += dot_v3v3(matrix[2], from);
}
DO_INLINE void muladd_fmatrixT_fvector(float to[3], float matrix[3][3], float from[3])
{
to[0] += matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2];
to[1] += matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2];
to[2] += matrix[0][2] * from[0] + matrix[1][2] * from[1] + matrix[2][2] * from[2];
}
BLI_INLINE void outerproduct(float r[3][3], const float a[3], const float b[3])
{
mul_v3_v3fl(r[0], a, b[0]);
@ -599,7 +606,9 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
#pragma omp section
{
for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) {
muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
/* This is the lower triangle of the sparse matrix,
* therefore multiplication occurs with transposed submatrices. */
muladd_fmatrixT_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
}
}
#pragma omp section
@ -612,8 +621,6 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
add_lfvector_lfvector(to, to, temp, from[0].vcount);
del_lfvector(temp);
}
/* SPARSE SYMMETRIC sub big matrix with big matrix*/