Changeset 2054
- Timestamp:
- Nov 2, 2012, 12:22:00 AM (10 years ago)
- Location:
- trunk/src/lol/math
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lol/math/half.h
r1502 r2054 121 121 static inline half min(half a, half b) { return a < b ? a : b; } 122 122 static inline half max(half a, half b) { return a > b ? a : b; } 123 static inline half fmod(half a, half b) { return (half)fmod((float)a, (float)b); } 124 static inline half abs(half a) { return half::makebits(a.bits & 0x7fffu); } 123 125 124 126 static inline half clamp(half x, half a, half b) -
trunk/src/lol/math/vector.h
r1947 r2054 1066 1066 1067 1067 /* 1068 * vec min(vec, vec) (also max )1069 * vec min(vec, scalar) (also max )1070 * vec min(scalar, vec) (also max )1068 * vec min(vec, vec) (also max, fmod) 1069 * vec min(vec, scalar) (also max, fmod) 1070 * vec min(scalar, vec) (also max, fmod) 1071 1071 */ 1072 1072 #define DECLARE_VECTOR_MINMAX_OP(tname, op, tprefix, type) \ … … 1105 1105 * vec clamp(vec, vec, scalar) 1106 1106 * vec clamp(vec, scalar, vec) 1107 * vec clamp(vec, scalar, scalar) 1107 1108 */ 1108 1109 #define DECLARE_VECTOR_CLAMP_OP(tname, tprefix, type) \ … … 1124 1125 inline tname<type> clamp(tname<type> const &x, \ 1125 1126 tname<type> const &a, type const &b) \ 1127 { \ 1128 return max(min(x, b), a); \ 1129 } \ 1130 \ 1131 tprefix \ 1132 inline tname<type> clamp(tname<type> const &x, \ 1133 type const &a, type const &b) \ 1126 1134 { \ 1127 1135 return max(min(x, b), a); \ … … 1211 1219 \ 1212 1220 tprefix \ 1213 inline tname<type> normalize(tname<type> const &val) \ 1214 { \ 1215 type norm = (type)length(val); \ 1216 return norm ? val / norm : val * (type)0; \ 1221 inline tname<type> normalize(tname<type> const &a) \ 1222 { \ 1223 type norm = (type)length(a); \ 1224 return norm ? a / norm : a * (type)0; \ 1225 } \ 1226 \ 1227 tprefix \ 1228 inline tname<type> abs(tname<type> const &a) \ 1229 { \ 1230 using std::abs; \ 1231 tname<type> ret; \ 1232 for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ 1233 ret[n] = abs(a[n]); \ 1234 return ret; \ 1217 1235 } 1218 1236 … … 1271 1289 DECLARE_VECTOR_MINMAX_OP(tname, min, tprefix, type) \ 1272 1290 DECLARE_VECTOR_MINMAX_OP(tname, max, tprefix, type) \ 1291 DECLARE_VECTOR_MINMAX_OP(tname, fmod, tprefix, type) \ 1273 1292 DECLARE_VECTOR_CLAMP_OP(tname, tprefix, type) 1274 1293
Note: See TracChangeset
for help on using the changeset viewer.