Changeset 1157
 Timestamp:
 Mar 12, 2012, 2:57:07 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/math/vector.h
r1154 r1157 954 954 #define DECLARE_VECTOR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \ 955 955 tprefix \ 956 static inline tname<tf> operator op(tname<t1> const &a, \ 957 tname<t2> const &b) \ 956 inline tname<tf> operator op(tname<t1> const &a, tname<t2> const &b) \ 958 957 { \ 959 958 tname<tf> ret; \ … … 965 964 #define DECLARE_VECTOR_VECTOR_OP(tname, op, tprefix, type) \ 966 965 tprefix \ 967 static inline tname<type> operator op##=(tname<type> &a, \ 968 tname<type> const &b) \ 966 inline tname<type> operator op##=(tname<type> &a, tname<type> const &b) \ 969 967 { \ 970 968 return a = a op b; \ … … 973 971 #define DECLARE_VECTOR_VECTOR_BOOLOP(tname, op, op2, ret, tprefix, t1, t2) \ 974 972 tprefix \ 975 static inline bool operator op(tname<t1> const &a, \ 976 tname<t2> const &b) \ 973 inline bool operator op(tname<t1> const &a, tname<t2> const &b) \ 977 974 { \ 978 975 for (size_t n = 0; n < sizeof(a) / sizeof(t1); n++) \ … … 984 981 #define DECLARE_VECTOR_SCALAR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \ 985 982 tprefix \ 986 staticinline tname<tf> operator op(tname<t1> const &a, t2 const &val) \983 inline tname<tf> operator op(tname<t1> const &a, t2 const &val) \ 987 984 { \ 988 985 tname<tf> ret; \ … … 993 990 \ 994 991 tprefix \ 995 staticinline tname<tf> operator op(t1 const &val, tname<t2> const &a) \992 inline tname<tf> operator op(t1 const &val, tname<t2> const &a) \ 996 993 { \ 997 994 tname<tf> ret; \ … … 1003 1000 #define DECLARE_VECTOR_SCALAR_OP(tname, op, tprefix, type) \ 1004 1001 tprefix \ 1005 staticinline tname<type> operator op##=(tname<type> &a, type const &val) \1002 inline tname<type> operator op##=(tname<type> &a, type const &val) \ 1006 1003 { \ 1007 1004 return a = a op val; \ … … 1010 1007 #define DECLARE_UNARY_OPS(tname, tprefix, type) \ 1011 1008 tprefix \ 1012 staticinline tname<type> operator (tname<type> const &a) \1009 inline tname<type> operator (tname<type> const &a) \ 1013 1010 { \ 1014 1011 tname<type> ret; \ … … 1019 1016 \ 1020 1017 tprefix \ 1021 staticinline type sqlen(tname<type> const &a) \1018 inline type sqlen(tname<type> const &a) \ 1022 1019 { \ 1023 1020 type acc = 0; \ … … 1028 1025 \ 1029 1026 tprefix \ 1030 staticinline double len(tname<type> const &a) \1027 inline double len(tname<type> const &a) \ 1031 1028 { \ 1032 1029 using namespace std; \ … … 1035 1032 \ 1036 1033 tprefix \ 1037 staticinline tname<type> normalize(tname<type> const &val) \1034 inline tname<type> normalize(tname<type> const &val) \ 1038 1035 { \ 1039 1036 type norm = (type)len(val); \ … … 1052 1049 \ 1053 1050 tprefix \ 1054 staticinline tf dot(tname<t1> const &a, tname<t2> const &b) \1051 inline tf dot(tname<t1> const &a, tname<t2> const &b) \ 1055 1052 { \ 1056 1053 tf ret = 0; \ … … 1079 1076 1080 1077 #define DECLARE_VECTOR_OPS(tname, tprefix, type) \ 1081 DECLARE_VECTOR_COERCE_OPS(tname, /* empty */, type, type, type) \1078 DECLARE_VECTOR_COERCE_OPS(tname, static, type, type, type) \ 1082 1079 \ 1083 1080 DECLARE_VECTOR_VECTOR_OP(tname, *, tprefix, type) \ … … 1085 1082 1086 1083 #define DECLARE_ALL_NONVECTOR_OPS(tname) \ 1087 DECLARE_BINARY_OPS(tname, template<typename T> , T) \1088 DECLARE_UNARY_OPS(tname, template<typename T> , T)1084 DECLARE_BINARY_OPS(tname, template<typename T> static, T) \ 1085 DECLARE_UNARY_OPS(tname, template<typename T> static, T) 1089 1086 1090 1087 #define DECLARE_ALL_VECTOR_OPS_INNER(tname, type) \ 1091 DECLARE_BINARY_OPS(tname, /* empty */, type) \1092 DECLARE_UNARY_OPS(tname, /* empty */, type) \1093 DECLARE_VECTOR_OPS(tname, /* empty */, type) \1088 DECLARE_BINARY_OPS(tname, static, type) \ 1089 DECLARE_UNARY_OPS(tname, static, type) \ 1090 DECLARE_VECTOR_OPS(tname, static, type) \ 1094 1091 1095 1092 #define DECLARE_ALL_VECTOR_OPS(tname) \ … … 1107 1104 1108 1105 #define DECLARE_ALL_VECTOR_COERCE_OPS_INNER(tname, tlow, thigh) \ 1109 DECLARE_BINARY_COERCE_OPS(tname, /* empty */, tlow, thigh, thigh) \1110 DECLARE_BINARY_COERCE_OPS(tname, /* empty */, thigh, tlow, thigh) \1111 \ 1112 DECLARE_VECTOR_COERCE_OPS(tname, /* empty */, tlow, thigh, thigh) \1113 DECLARE_VECTOR_COERCE_OPS(tname, /* empty */, thigh, tlow, thigh)1106 DECLARE_BINARY_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1107 DECLARE_BINARY_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1108 \ 1109 DECLARE_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1110 DECLARE_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) 1114 1111 1115 1112 #define DECLARE_ALL_VECTOR_COERCE_OPS(tname) \
Note: See TracChangeset
for help on using the changeset viewer.