rendered paste body/* create big matrix */
DO_INLINE fmatrix3x3 *create_bfmatrix(void)
{
// TODO: check if memory allocation was successfull */
return MEM_callocN (sizeof (fmatrix3x3) * (CLOTHPARTICLES + CLOTHSPRINGS), "cloth_implicit_alloc_matrix");
}
/* copy 3x3 matrix */
DO_INLINE static void cp_fmatrix(float to[3][3], float from[3][3])
{
memcpy(to, from, sizeof (float) * 9);
}
...later call:
fmatrix3x3 *matrix = create_bfmatrix();
for(i = 0; i < CLOTHPARTICLES; i++)
{
printf("iA: %d\n", i);
cp_fmatrix(matrix[i].m, m3);
}
for(i = CLOTHPARTICLES; i < CLOTHPARTICLES+CLOTHPARTICLES; i++)
{
printf("iB: %d\n", i); // debug output
cp_fmatrix(matrix[i].m, tmatrix); // crashes here after some iterations
}