From 7c7b7302d33b9a43f5436589a726bc733be91a33 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 20 Jul 2014 14:01:42 +1000 Subject: Math Lib: use variable length args for mul_serie_m3,m4 (instead of trailing NULL's) --- source/blender/blenlib/BLI_math_matrix.h | 35 ++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'source/blender/blenlib/BLI_math_matrix.h') diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 49183934412..1c1e4e7eb3f 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -34,6 +34,8 @@ extern "C" { #endif +#include "BLI_compiler_attrs.h" + /********************************* Init **************************************/ void zero_m3(float R[3][3]); @@ -67,12 +69,33 @@ void mul_m4_m4m3(float R[4][4], float A[4][4], float B[3][3]); void mul_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]); void mul_m3_m3m4(float R[3][3], float A[4][4], float B[3][3]); -void mul_serie_m3(float R[3][3], - float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], - float M5[3][3], float M6[3][3], float M7[3][3], float M8[3][3]); -void mul_serie_m4(float R[4][4], - float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], - float M5[4][4], float M6[4][4], float M7[4][4], float M8[4][4]); +/* mul_serie_m3 */ +void _va_mul_serie_m3_3(float R[3][3], float M1[3][3], float M2[3][3]) ATTR_NONNULL(); +void _va_mul_serie_m3_4(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3]) ATTR_NONNULL(); +void _va_mul_serie_m3_5(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3]) ATTR_NONNULL(); +void _va_mul_serie_m3_6(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3]) ATTR_NONNULL(); +void _va_mul_serie_m3_7(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3], float M6[3][3]) ATTR_NONNULL(); +void _va_mul_serie_m3_8(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3], float M6[3][3], float M7[3][3]) ATTR_NONNULL(); +void _va_mul_serie_m3_9(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3], float M6[3][3], float M7[3][3], float M8[3][3]) ATTR_NONNULL(); +/* mul_serie_m4 */ +void _va_mul_serie_m4_3(float R[4][4], float M1[4][4], float M2[4][4]) ATTR_NONNULL(); +void _va_mul_serie_m4_4(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4]) ATTR_NONNULL(); +void _va_mul_serie_m4_5(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4]) ATTR_NONNULL(); +void _va_mul_serie_m4_6(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], + float M5[4][4]) ATTR_NONNULL(); +void _va_mul_serie_m4_7(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], + float M5[4][4], float M6[4][4]) ATTR_NONNULL(); +void _va_mul_serie_m4_8(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], + float M5[4][4], float M6[4][4], float M7[4][4]) ATTR_NONNULL(); +void _va_mul_serie_m4_9(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], + float M5[4][4], float M6[4][4], float M7[4][4], float M8[4][4]) ATTR_NONNULL(); + +#define mul_serie_m3(...) VA_NARGS_CALL_OVERLOAD(_va_mul_serie_m3_, __VA_ARGS__) +#define mul_serie_m4(...) VA_NARGS_CALL_OVERLOAD(_va_mul_serie_m4_, __VA_ARGS__) void mul_m4_v3(float M[4][4], float r[3]); void mul_v3_m4v3(float r[3], float M[4][4], const float v[3]); -- cgit v1.2.3 From 8489b94e07f9e73bd3c9c3e4f6a91f1f0a259827 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Jul 2014 18:55:12 +1000 Subject: Math Lib: rename mul_serie_m3 to mul_m3_series & reorder args Importantly, reversed mul_serie_m3 argument order (so it matches the m4 function) --- source/blender/blenlib/BLI_math_matrix.h | 52 ++++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'source/blender/blenlib/BLI_math_matrix.h') diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 1c1e4e7eb3f..68d8e3b9499 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -69,33 +69,33 @@ void mul_m4_m4m3(float R[4][4], float A[4][4], float B[3][3]); void mul_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]); void mul_m3_m3m4(float R[3][3], float A[4][4], float B[3][3]); -/* mul_serie_m3 */ -void _va_mul_serie_m3_3(float R[3][3], float M1[3][3], float M2[3][3]) ATTR_NONNULL(); -void _va_mul_serie_m3_4(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3]) ATTR_NONNULL(); -void _va_mul_serie_m3_5(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3]) ATTR_NONNULL(); -void _va_mul_serie_m3_6(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], - float M5[3][3]) ATTR_NONNULL(); -void _va_mul_serie_m3_7(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], - float M5[3][3], float M6[3][3]) ATTR_NONNULL(); -void _va_mul_serie_m3_8(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], - float M5[3][3], float M6[3][3], float M7[3][3]) ATTR_NONNULL(); -void _va_mul_serie_m3_9(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], - float M5[3][3], float M6[3][3], float M7[3][3], float M8[3][3]) ATTR_NONNULL(); -/* mul_serie_m4 */ -void _va_mul_serie_m4_3(float R[4][4], float M1[4][4], float M2[4][4]) ATTR_NONNULL(); -void _va_mul_serie_m4_4(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4]) ATTR_NONNULL(); -void _va_mul_serie_m4_5(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4]) ATTR_NONNULL(); -void _va_mul_serie_m4_6(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], +/* mul_m3_series */ +void _va_mul_m3_series_3(float R[3][3], float M1[3][3], float M2[3][3]) ATTR_NONNULL(); +void _va_mul_m3_series_4(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3]) ATTR_NONNULL(); +void _va_mul_m3_series_5(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3]) ATTR_NONNULL(); +void _va_mul_m3_series_6(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3]) ATTR_NONNULL(); +void _va_mul_m3_series_7(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3], float M6[3][3]) ATTR_NONNULL(); +void _va_mul_m3_series_8(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3], float M6[3][3], float M7[3][3]) ATTR_NONNULL(); +void _va_mul_m3_series_9(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3], float M6[3][3], float M7[3][3], float M8[3][3]) ATTR_NONNULL(); +/* mul_m4_series */ +void _va_mul_m4_series_3(float R[4][4], float M1[4][4], float M2[4][4]) ATTR_NONNULL(); +void _va_mul_m4_series_4(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4]) ATTR_NONNULL(); +void _va_mul_m4_series_5(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4]) ATTR_NONNULL(); +void _va_mul_m4_series_6(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], float M5[4][4]) ATTR_NONNULL(); -void _va_mul_serie_m4_7(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], - float M5[4][4], float M6[4][4]) ATTR_NONNULL(); -void _va_mul_serie_m4_8(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], - float M5[4][4], float M6[4][4], float M7[4][4]) ATTR_NONNULL(); -void _va_mul_serie_m4_9(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], - float M5[4][4], float M6[4][4], float M7[4][4], float M8[4][4]) ATTR_NONNULL(); - -#define mul_serie_m3(...) VA_NARGS_CALL_OVERLOAD(_va_mul_serie_m3_, __VA_ARGS__) -#define mul_serie_m4(...) VA_NARGS_CALL_OVERLOAD(_va_mul_serie_m4_, __VA_ARGS__) +void _va_mul_m4_series_7(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], + float M5[4][4], float M6[4][4]) ATTR_NONNULL(); +void _va_mul_m4_series_8(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], + float M5[4][4], float M6[4][4], float M7[4][4]) ATTR_NONNULL(); +void _va_mul_m4_series_9(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], + float M5[4][4], float M6[4][4], float M7[4][4], float M8[4][4]) ATTR_NONNULL(); + +#define mul_m3_series(...) VA_NARGS_CALL_OVERLOAD(_va_mul_m3_series_, __VA_ARGS__) +#define mul_m4_series(...) VA_NARGS_CALL_OVERLOAD(_va_mul_m4_series_, __VA_ARGS__) void mul_m4_v3(float M[4][4], float r[3]); void mul_v3_m4v3(float r[3], float M[4][4], const float v[3]); -- cgit v1.2.3 From 3c9e11df37581c6faf937bbe974710a7fc95e380 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 1 Aug 2014 16:28:31 +0200 Subject: Cleanup: Move SpaceTransform helpers from `BKE_shrinkwrap` to `BLI_math_matrix`. --- source/blender/blenlib/BLI_math_matrix.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/blender/blenlib/BLI_math_matrix.h') diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 68d8e3b9499..7bcaab1f939 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -224,6 +224,22 @@ bool is_negative_m4(float mat[4][4]); bool is_zero_m3(float mat[3][3]); bool is_zero_m4(float mat[4][4]); +/* SpaceTransform helper */ +typedef struct SpaceTransform { + float local2target[4][4]; + float target2local[4][4]; + +} SpaceTransform; + +void BLI_space_transform_from_matrices(struct SpaceTransform *data, float local[4][4], float target[4][4]); +void BLI_space_transform_apply(const struct SpaceTransform *data, float co[3]); +void BLI_space_transform_invert(const struct SpaceTransform *data, float co[3]); +void BLI_space_transform_apply_normal(const struct SpaceTransform *data, float no[3]); +void BLI_space_transform_invert_normal(const struct SpaceTransform *data, float no[3]); + +#define BLI_SPACE_TRANSFORM_SETUP(data, local, target) \ + BLI_space_transform_from_matrices((data), (local)->obmat, (target)->obmat) + /*********************************** Other ***********************************/ void print_m3(const char *str, float M[3][3]); -- cgit v1.2.3 From 671f75a12a1d9e57d9f609148538bcb9cf8b3a46 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Sep 2014 11:19:34 +1000 Subject: Math Lib: Add copy_m2_m2, unit_m2, zero_m2 --- source/blender/blenlib/BLI_math_matrix.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenlib/BLI_math_matrix.h') diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 7bcaab1f939..0eac92c1db9 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -38,12 +38,15 @@ extern "C" { /********************************* Init **************************************/ +void zero_m2(float R[2][2]); void zero_m3(float R[3][3]); void zero_m4(float R[4][4]); +void unit_m2(float R[2][2]); void unit_m3(float R[3][3]); void unit_m4(float R[4][4]); +void copy_m2_m2(float R[2][2], float A[2][2]); void copy_m3_m3(float R[3][3], float A[3][3]); void copy_m4_m4(float R[4][4], float A[4][4]); void copy_m3_m4(float R[3][3], float A[4][4]); -- cgit v1.2.3