TransformationMatrices[mesh_count-1][0] = n->mTransformation.a1;
TransformationMatrices[mesh_count-1][1] = n->mTransformation.a2;
TransformationMatrices[mesh_count-1][2] = n->mTransformation.a3;
TransformationMatrices[mesh_count-1][3] = n->mTransformation.a4;
TransformationMatrices[mesh_count-1][4] = n->mTransformation.b1;
TransformationMatrices[mesh_count-1][5] = n->mTransformation.b2;
TransformationMatrices[mesh_count-1][6] = n->mTransformation.b3;
TransformationMatrices[mesh_count-1][7] = n->mTransformation.b4;
TransformationMatrices[mesh_count-1][8] = n->mTransformation.c1;
TransformationMatrices[mesh_count-1][9] = n->mTransformation.c2;
TransformationMatrices[mesh_count-1][10] = n->mTransformation.c3;
TransformationMatrices[mesh_count-1][11] = n->mTransformation.c4;
TransformationMatrices[mesh_count-1][12] = n->mTransformation.d1;
TransformationMatrices[mesh_count-1][13] = n->mTransformation.d2;
TransformationMatrices[mesh_count-1][14] = n->mTransformation.d3;
TransformationMatrices[mesh_count-1][15] = n->mTransformation.d4;
编辑:替换为替换为较短的格式。
答案 0 :(得分:1)
嗯,你有你的选择,
方法1)会是这样的:
double *dest = &TransformationMatrices[mesh_count-1][0];
double *src = &n->mTransformation.a1;
memcpy(dest, src, sizeof(double) * 16);
这取决于各种未定义的行为,应该工作.....
答案 1 :(得分:1)
我不完全确定我会关注这个问题,但您可以使用预处理器来缩短这一点。例如,
int WriteIndex = 0;
#define WRITE_MATRIX(prefix) \
do { \
TransformationMatrices[mesh_count-1][WriteIndex++] = n->mTransformation.prefix ## 1; \
TransformationMatrices[mesh_count-1][WriteIndex++] = n->mTransformation.prefix ## 2; \
TransformationMatrices[mesh_count-1][WriteIndex++] = n->mTransformation.prefix ## 3; \
TransformationMatrices[mesh_count-1][WriteIndex++] = n->mTransformation.prefix ## 4; \
} while(0)
WRITE_MATRIX(a);
WRITE_MATRIX(b);
WRITE_MATRIX(c);
WRITE_MATRIX(d);
我不会用这种方式编写代码,但它演示了这种技术......