Changeset View
Changeset View
Standalone View
Standalone View
source/blender/physics/intern/implicit_blender.c
| Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | typedef struct fmatrix3x3 { | ||||
| unsigned int scount; /* spring count */ | unsigned int scount; /* spring count */ | ||||
| } fmatrix3x3; | } fmatrix3x3; | ||||
| /////////////////////////// | /////////////////////////// | ||||
| // float[3] vector | // float[3] vector | ||||
| /////////////////////////// | /////////////////////////// | ||||
| /* simple vector code */ | /* simple vector code */ | ||||
| /* STATUS: verified */ | /* STATUS: verified */ | ||||
| DO_INLINE void mul_fvector_S(float to[3], float from[3], float scalar) | DO_INLINE void mul_fvector_S(float to[3], const float from[3], float scalar) | ||||
| { | { | ||||
| to[0] = from[0] * scalar; | to[0] = from[0] * scalar; | ||||
| to[1] = from[1] * scalar; | to[1] = from[1] * scalar; | ||||
| to[2] = from[2] * scalar; | to[2] = from[2] * scalar; | ||||
| } | } | ||||
| /* simple v^T * v product ("outer product") */ | /* simple v^T * v product ("outer product") */ | ||||
| /* STATUS: HAS TO BE verified (*should* work) */ | /* STATUS: HAS TO BE verified (*should* work) */ | ||||
| DO_INLINE void mul_fvectorT_fvector(float to[3][3], float vectorA[3], float vectorB[3]) | DO_INLINE void mul_fvectorT_fvector(float to[3][3], float vectorA[3], float vectorB[3]) | ||||
| ▲ Show 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| mul_fvector_S(matrix[0], matrix[0], scalar); | mul_fvector_S(matrix[0], matrix[0], scalar); | ||||
| mul_fvector_S(matrix[1], matrix[1], scalar); | mul_fvector_S(matrix[1], matrix[1], scalar); | ||||
| mul_fvector_S(matrix[2], matrix[2], scalar); | mul_fvector_S(matrix[2], matrix[2], scalar); | ||||
| } | } | ||||
| /* a vector multiplied by a 3x3 matrix */ | /* a vector multiplied by a 3x3 matrix */ | ||||
| /* STATUS: verified */ | /* STATUS: verified */ | ||||
| DO_INLINE void mul_fvector_fmatrix(float *to, float *from, float matrix[3][3]) | DO_INLINE void mul_fvector_fmatrix(float *to, const float *from, float matrix[3][3]) | ||||
| { | { | ||||
| to[0] = matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2]; | 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[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]; | to[2] = matrix[0][2] * from[0] + matrix[1][2] * from[1] + matrix[2][2] * from[2]; | ||||
| } | } | ||||
| /* 3x3 matrix multiplied by a vector */ | /* 3x3 matrix multiplied by a vector */ | ||||
| /* STATUS: verified */ | /* STATUS: verified */ | ||||
| Show All 32 Lines | |||||
| /* STATUS: verified */ | /* STATUS: verified */ | ||||
| DO_INLINE void muladd_fmatrix_fvector(float to[3], float matrix[3][3], float from[3]) | DO_INLINE void muladd_fmatrix_fvector(float to[3], float matrix[3][3], float from[3]) | ||||
| { | { | ||||
| to[0] += dot_v3v3(matrix[0], from); | to[0] += dot_v3v3(matrix[0], from); | ||||
| to[1] += dot_v3v3(matrix[1], from); | to[1] += dot_v3v3(matrix[1], from); | ||||
| to[2] += dot_v3v3(matrix[2], from); | to[2] += dot_v3v3(matrix[2], from); | ||||
| } | } | ||||
| DO_INLINE void muladd_fmatrixT_fvector(float to[3], float matrix[3][3], float from[3]) | DO_INLINE void muladd_fmatrixT_fvector(float to[3], float matrix[3][3], const float from[3]) | ||||
| { | { | ||||
| to[0] += matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2]; | 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[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]; | 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]) | BLI_INLINE void outerproduct(float r[3][3], const float a[3], const float b[3]) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,374 Lines • ▼ Show 20 Lines | if (length < restlen) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| else { | else { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| BLI_INLINE void poly_avg(lfVector *data, int *inds, int len, float r_avg[3]) | BLI_INLINE void poly_avg(lfVector *data, const int *inds, int len, float r_avg[3]) | ||||
| { | { | ||||
| float fact = 1.0f / (float)len; | float fact = 1.0f / (float)len; | ||||
| zero_v3(r_avg); | zero_v3(r_avg); | ||||
| for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
| madd_v3_v3fl(r_avg, data[inds[i]], fact); | madd_v3_v3fl(r_avg, data[inds[i]], fact); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 480 Lines • Show Last 20 Lines | |||||