Changeset 2317
 Timestamp:
 Feb 2, 2013, 4:00:28 PM (6 years ago)
 Location:
 trunk
 Files:

 6 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/math/real.h
r2183 r2317 122 122 template<int M> friend Real<M> round(Real<M> const &x); 123 123 template<int M> friend Real<M> fmod(Real<M> const &x, Real<N> const &y); 124 125 /* Functions inherited from GLSL */ 126 template<int M> friend Real<M> abs(Real<M> const &x); 127 template<int M> friend Real<M> fract(Real<M> const &x); 124 128 125 129 void hexprint() const; … … 270 274 template<> real round(real const &x); 271 275 template<> real fmod(real const &x, real const &y); 276 template<> real abs(real const &x); 277 template<> real fract(real const &x); 272 278 273 279 template<> void real::hexprint() const; 
trunk/src/lol/math/vector.h
r2279 r2317 1041 1041 * vec /(vec, vec) 1042 1042 */ 1043 #define LOL_VECTOR_VECTOR_ COERCE_OP(tname, op, tprefix, t1, t2, tf) \1044 tprefix \ 1045 inline tname<t f> operator op(tname<t1> const &a, tname<t2> const &b) \1046 { \ 1047 tname<t f> ret; \1048 for (size_t n = 0; n < sizeof(a) / sizeof(t 1); n++) \1043 #define LOL_VECTOR_VECTOR_OP(tname, op, tprefix, type) \ 1044 tprefix \ 1045 inline tname<type> operator op(tname<type> const &a, tname<type> const &b) \ 1046 { \ 1047 tname<type> ret; \ 1048 for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ 1049 1049 ret[n] = a[n] op b[n]; \ 1050 1050 return ret; \ … … 1057 1057 * vec /=(vec, vec) 1058 1058 */ 1059 #define LOL_VECTOR_VECTOR_ OP(tname, op, tprefix, type) \1059 #define LOL_VECTOR_VECTOR_NONCONST_OP(tname, op, tprefix, type) \ 1060 1060 tprefix \ 1061 1061 inline tname<type> operator op##=(tname<type> &a, tname<type> const &b) \ … … 1162 1162 * bool <(vec, vec) 1163 1163 */ 1164 #define LOL_VECTOR_VECTOR_BOOL_OP(tname, op, op2, ret, tprefix, t 1, t2) \1165 tprefix \ 1166 inline bool operator op(tname<t 1> const &a, tname<t2> const &b) \1167 { \ 1168 for (size_t n = 0; n < sizeof(a) / sizeof(t 1); n++) \1164 #define LOL_VECTOR_VECTOR_BOOL_OP(tname, op, op2, ret, tprefix, type) \ 1165 tprefix \ 1166 inline bool operator op(tname<type> const &a, tname<type> const &b) \ 1167 { \ 1168 for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ 1169 1169 if (!(a[n] op2 b[n])) \ 1170 1170 return !ret; \ … … 1176 1176 * vec /(vec, scalar) (also complex & quaternion) 1177 1177 */ 1178 #define LOL_VECTOR_SCALAR_ COERCE_OP(tname, op, tprefix, t1, t2, tf) \1179 tprefix \ 1180 inline tname<t f> operator op(tname<t1> const &a, t2const &val) \1181 { \ 1182 tname<t f> ret; \1183 for (size_t n = 0; n < sizeof(a) / sizeof(t 1); n++) \1178 #define LOL_VECTOR_SCALAR_OP(tname, op, tprefix, type) \ 1179 tprefix \ 1180 inline tname<type> operator op(tname<type> const &a, type const &val) \ 1181 { \ 1182 tname<type> ret; \ 1183 for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ 1184 1184 ret[n] = a[n] op val; \ 1185 1185 return ret; \ … … 1190 1190 * vec /(scalar, vec) (NOT for complex & quaternion!) 1191 1191 */ 1192 #define LOL_SCALAR_VECTOR_ COERCE_OP(tname, op, tprefix, t1, t2, tf) \1193 tprefix \ 1194 inline tname<t f> operator op(t1 const &val, tname<t2> const &a) \1195 { \ 1196 tname<t f> ret; \1197 for (size_t n = 0; n < sizeof(a) / sizeof(t 2); n++) \1192 #define LOL_SCALAR_VECTOR_OP(tname, op, tprefix, type) \ 1193 tprefix \ 1194 inline tname<type> operator op(type const &val, tname<type> const &a) \ 1195 { \ 1196 tname<type> ret; \ 1197 for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ 1198 1198 ret[n] = a[n] op val; \ 1199 1199 return ret; \ … … 1204 1204 * vec /=(vec, scalar) (also complex & quaternion) 1205 1205 */ 1206 #define LOL_VECTOR_SCALAR_ OP(tname, op, tprefix, type) \1206 #define LOL_VECTOR_SCALAR_NONCONST_OP(tname, op, tprefix, type) \ 1207 1207 tprefix \ 1208 1208 inline tname<type> operator op##=(tname<type> &a, type const &val) \ … … 1262 1262 } 1263 1263 1264 #define LOL_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1265 LOL_VECTOR_VECTOR_COERCE_OP(tname, , tprefix, t1, t2, tf) \ 1266 LOL_VECTOR_VECTOR_COERCE_OP(tname, +, tprefix, t1, t2, tf) \ 1267 \ 1268 LOL_VECTOR_SCALAR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1269 LOL_VECTOR_SCALAR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \ 1270 LOL_SCALAR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1271 \ 1272 LOL_VECTOR_VECTOR_BOOL_OP(tname, ==, ==, true, tprefix, t1, t2) \ 1273 LOL_VECTOR_VECTOR_BOOL_OP(tname, !=, ==, false, tprefix, t1, t2) 1274 1275 #define LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, tprefix, t1, t2, tf) \ 1276 tprefix \ 1277 inline tf dot(tname<t1> const &a, tname<t2> const &b) \ 1278 { \ 1279 tf ret = 0; \ 1280 for (size_t n = 0; n < sizeof(a) / sizeof(t1); n++) \ 1264 #define LOL_BINARY_NONVECTOR_FUNS(tname, tprefix, type) \ 1265 tprefix \ 1266 inline type dot(tname<type> const &a, tname<type> const &b) \ 1267 { \ 1268 type ret = 0; \ 1269 for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ 1281 1270 ret += a[n] * b[n]; \ 1282 1271 return ret; \ 1283 1272 } \ 1284 tprefix \ 1285 inline tname<tf> lerp(tname<t1> const &a, tname<t2> const &b, tf x) \ 1286 { \ 1287 tname<tf> ret; \ 1288 for (size_t n = 0; n < sizeof(a) / sizeof(t1); n++) \ 1273 \ 1274 tprefix \ 1275 inline tname<type> lerp(tname<type> const &a, \ 1276 tname<type> const &b, type x) \ 1277 { \ 1278 tname<type> ret; \ 1279 for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ 1289 1280 ret[n] = a[n] + (b[n]  a[n]) * x; \ 1290 1281 return ret; \ 1291 1282 } 1292 1283 1293 #define LOL_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1294 LOL_SCALAR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) 1295 1296 #define LOL_VEC_3_COERCE_FUNS(tname, tprefix, t1, t2, tf) \ 1297 tprefix \ 1298 inline tname<tf> cross(tname<t1> const &a, tname<t2> const &b) \ 1299 { \ 1300 return tname<tf>((tf)(a.y * b.z)  (tf)(a.z * b.y), \ 1301 (tf)(a.z * b.x)  (tf)(a.x * b.z), \ 1302 (tf)(a.x * b.y)  (tf)(a.y * b.x)); \ 1284 #define LOL_VEC_3_FUNS(tname, tprefix, type) \ 1285 tprefix \ 1286 inline tname<type> cross(tname<type> const &a, tname<type> const &b) \ 1287 { \ 1288 return tname<type>((type)(a.y * b.z  a.z * b.y), \ 1289 (type)(a.z * b.x  a.x * b.z), \ 1290 (type)(a.x * b.y  a.y * b.x)); \ 1303 1291 } 1304 1292 1305 1293 #define LOL_BINARY_NONVECTOR_OPS(tname, tprefix, type) \ 1306 LOL_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, type, type, type) \1307 \1308 1294 LOL_VECTOR_VECTOR_OP(tname, , tprefix, type) \ 1309 1295 LOL_VECTOR_VECTOR_OP(tname, +, tprefix, type) \ 1296 LOL_VECTOR_SCALAR_OP(tname, *, tprefix, type) \ 1297 LOL_VECTOR_SCALAR_OP(tname, /, tprefix, type) \ 1298 LOL_SCALAR_VECTOR_OP(tname, *, tprefix, type) \ 1310 1299 \ 1311 LOL_VECTOR_SCALAR_OP(tname, *, tprefix, type) \ 1312 LOL_VECTOR_SCALAR_OP(tname, /, tprefix, type) 1313 1314 #define LOL_BINARY_NONVECTOR_FUNS(tname, tprefix, type) \ 1315 LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, tprefix, type, type, type) \ 1300 LOL_VECTOR_VECTOR_NONCONST_OP(tname, , tprefix, type) \ 1301 LOL_VECTOR_VECTOR_NONCONST_OP(tname, +, tprefix, type) \ 1302 LOL_VECTOR_SCALAR_NONCONST_OP(tname, *, tprefix, type) \ 1303 LOL_VECTOR_SCALAR_NONCONST_OP(tname, /, tprefix, type) \ 1304 \ 1305 LOL_VECTOR_VECTOR_BOOL_OP(tname, ==, ==, true, tprefix, type) \ 1306 LOL_VECTOR_VECTOR_BOOL_OP(tname, !=, ==, false, tprefix, type) 1316 1307 1317 1308 #define LOL_BINARY_VECTOR_OPS(tname, tprefix, type) \ 1318 LOL_ BINARY_VECTOR_COERCE_OPS(tname, tprefix, type, type, type)1309 LOL_SCALAR_VECTOR_OP(tname, /, tprefix, type) 1319 1310 1320 1311 #define LOL_BINARY_VECTOR_FUNS(tname, tprefix, type) \ … … 1323 1314 LOL_VECTOR_MINMAX_FUN(tname, fmod, tprefix, type) \ 1324 1315 LOL_VECTOR_CLAMP_FUN(tname, tprefix, type) \ 1325 LOL_VECTOR_MIX_FUN(tname, tprefix, type) 1326 1327 #define LOL_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1328 LOL_VECTOR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1329 LOL_VECTOR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \ 1316 LOL_VECTOR_MIX_FUN(tname, tprefix, type) \ 1330 1317 \ 1331 LOL_VECTOR_VECTOR_BOOL_OP(tname, <=, <=, true, tprefix, t 1, t2) \1332 LOL_VECTOR_VECTOR_BOOL_OP(tname, >=, >=, true, tprefix, t 1, t2) \1333 LOL_VECTOR_VECTOR_BOOL_OP(tname, <, <, true, tprefix, t 1, t2) \1334 LOL_VECTOR_VECTOR_BOOL_OP(tname, >, >, true, tprefix, t 1, t2)1318 LOL_VECTOR_VECTOR_BOOL_OP(tname, <=, <=, true, tprefix, type) \ 1319 LOL_VECTOR_VECTOR_BOOL_OP(tname, >=, >=, true, tprefix, type) \ 1320 LOL_VECTOR_VECTOR_BOOL_OP(tname, <, <, true, tprefix, type) \ 1321 LOL_VECTOR_VECTOR_BOOL_OP(tname, >, >, true, tprefix, type) 1335 1322 1336 1323 #define LOL_VECTOR_OPS(tname, tprefix, type) \ 1337 LOL_VECTOR_COERCE_OPS(tname, static, type, type, type) \ 1324 LOL_VECTOR_VECTOR_OP(tname, *, tprefix, type) \ 1325 LOL_VECTOR_VECTOR_OP(tname, /, tprefix, type) \ 1338 1326 \ 1339 LOL_VECTOR_VECTOR_ OP(tname, *, tprefix, type) \1340 LOL_VECTOR_VECTOR_ OP(tname, /, tprefix, type)1327 LOL_VECTOR_VECTOR_NONCONST_OP(tname, *, tprefix, type) \ 1328 LOL_VECTOR_VECTOR_NONCONST_OP(tname, /, tprefix, type) 1341 1329 1342 1330 #define LOL_ALL_NONVECTOR_OPS_AND_FUNS(tname) \ … … 1368 1356 LOL_ALL_VECTOR_FUNS_INNER(Vec3, type) \ 1369 1357 LOL_ALL_VECTOR_FUNS_INNER(Vec4, type) \ 1370 LOL_VEC_3_COERCE_FUNS(Vec3, static, type, type, type) 1371 1372 #define LOL_VEC_ANY_COERCE_OPS(tname, tlow, thigh) \ 1373 LOL_BINARY_NONVECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1374 LOL_BINARY_NONVECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1375 LOL_BINARY_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1376 LOL_BINARY_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1377 \ 1378 LOL_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1379 LOL_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) 1380 1381 #define LOL_VEC_ANY_COERCE_FUNS(tname, tlow, thigh) \ 1382 LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, static, tlow, thigh, thigh) \ 1383 LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, static, thigh, tlow, thigh) 1384 1385 #define LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(tlow, thigh) \ 1386 namespace x##tlow##thigh \ 1387 { \ 1388 LOL_VEC_ANY_COERCE_OPS(Vec2, tlow, thigh) \ 1389 LOL_VEC_ANY_COERCE_OPS(Vec3, tlow, thigh) \ 1390 LOL_VEC_ANY_COERCE_OPS(Vec4, tlow, thigh) \ 1391 } \ 1392 LOL_VEC_ANY_COERCE_FUNS(Vec2, tlow, thigh) \ 1393 LOL_VEC_ANY_COERCE_FUNS(Vec3, tlow, thigh) \ 1394 LOL_VEC_ANY_COERCE_FUNS(Vec4, tlow, thigh) \ 1395 LOL_VEC_3_COERCE_FUNS(Vec3, static, tlow, thigh, thigh) \ 1396 LOL_VEC_3_COERCE_FUNS(Vec3, static, thigh, tlow, thigh) 1358 LOL_VEC_3_FUNS(Vec3, static, type) 1397 1359 1398 1360 LOL_ALL_NONVECTOR_OPS_AND_FUNS(Cmplx) … … 1418 1380 LOL_ALL_VECTOR_OPS_AND_FUNS(uint64_t) 1419 1381 1382 /* FIXME: vectors of "real" are deactivated for now, because we do 1383 * not implement all combinations of operators for these types yet. */ 1384 LOL_ALL_VECTOR_OPS_AND_FUNS(real) 1385 1420 1386 #if defined _MSC_VER 1421 1387 # pragma warning(pop) 1422 1388 #endif 1423 1389 1424 /* Disable warnings in the >= > etc. operators about comparing signed and1425 * unsigned. Ideally we would like to get these warnings only when the1426 * inlined operators are actually used, but they seem to be triggered at1427 * the code parsing step, so the compiler does not yet know whether they1428 * will be used.1429 * Also we do this for the whole block of declarations, because GCC prior1430 * to 4.6.3 does not appear to support _Pragma() inside a macro. */1431 #if defined __GNUC__ && (__GNUC__ > 4  (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))1432 # pragma GCC diagnostic push1433 # pragma GCC diagnostic ignored "Wsigncompare"1434 #elif defined _MSC_VER1435 # pragma warning(push)1436 # pragma warning(disable: 4018)1437 #endif1438 1439 /* Apply the same coercion rules as in the C++ standard. However, instead1440 * of always promoting smaller types to int, we allow int8_t op int16_t to1441 * return an int16_t. */1442 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint8_t)1443 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int16_t)1444 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint16_t)1445 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int32_t)1446 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint32_t)1447 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int64_t)1448 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint64_t)1449 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, float)1450 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, double)1451 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, ldouble)1452 1453 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int16_t)1454 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint16_t)1455 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int32_t)1456 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint32_t)1457 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int64_t)1458 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint64_t)1459 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, float)1460 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, double)1461 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, ldouble)1462 1463 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint16_t)1464 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, int32_t)1465 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint32_t)1466 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, int64_t)1467 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint64_t)1468 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, float)1469 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, double)1470 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, ldouble)1471 1472 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, int32_t)1473 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, uint32_t)1474 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, int64_t)1475 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, uint64_t)1476 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, float)1477 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, double)1478 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, ldouble)1479 1480 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, uint32_t)1481 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, int64_t)1482 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, uint64_t)1483 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, float)1484 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, double)1485 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, ldouble)1486 1487 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, int64_t)1488 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, uint64_t)1489 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, float)1490 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, double)1491 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, ldouble)1492 1493 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, uint64_t)1494 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, float)1495 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, double)1496 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, ldouble)1497 1498 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, float)1499 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, double)1500 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, ldouble)1501 1502 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, double)1503 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, ldouble)1504 1505 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(double, ldouble)1506 1507 /* FIXME: vectors of "half" are deactivated for now, because they1508 * induce extremely long compilation times (about 17 seconds per TU). */1509 1510 #if 01511 /* All integer types are promoted to half; all floating point types1512 * cause half to be promoted. */1513 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, half)1514 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, half)1515 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, half)1516 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, half)1517 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, half)1518 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, half)1519 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, half)1520 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, half)1521 1522 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, float)1523 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, double)1524 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, ldouble)1525 #endif1526 1527 /* FIXME: vectors of "real" are deactivated for now, because we do1528 * not implement all combinations of operators for these types yet. */1529 1530 #if 01531 /* All types are promoted to real */1532 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, real)1533 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, real)1534 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, real)1535 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, real)1536 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, real)1537 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, real)1538 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, real)1539 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, real)1540 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, real)1541 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, real)1542 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(double, real)1543 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(ldouble, real)1544 #endif1545 1546 /* Activate all the namespaces that we created. Delaying this activation1547 * reduces compilation times significantly. */1548 #define ACTIVATE_COERCE_NAMESPACES_INNER(tlow, thigh) \1549 namespace x##tlow##thigh {} \1550 using namespace x##tlow##thigh;1551 1552 #define ACTIVATE_COERCE_NAMESPACES(tlow) \1553 namespace x##tlow {} \1554 using namespace x##tlow; \1555 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, int8_t) \1556 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, uint8_t) \1557 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, int16_t) \1558 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, uint16_t) \1559 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, int32_t) \1560 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, uint32_t) \1561 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, int64_t) \1562 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, uint64_t) \1563 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, half) \1564 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, float) \1565 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, double) \1566 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, ldouble) \1567 ACTIVATE_COERCE_NAMESPACES_INNER(tlow, real)1568 1569 ACTIVATE_COERCE_NAMESPACES(int8_t)1570 ACTIVATE_COERCE_NAMESPACES(uint8_t)1571 ACTIVATE_COERCE_NAMESPACES(int16_t)1572 ACTIVATE_COERCE_NAMESPACES(uint16_t)1573 ACTIVATE_COERCE_NAMESPACES(int32_t)1574 ACTIVATE_COERCE_NAMESPACES(uint32_t)1575 ACTIVATE_COERCE_NAMESPACES(int64_t)1576 ACTIVATE_COERCE_NAMESPACES(uint64_t)1577 ACTIVATE_COERCE_NAMESPACES(half)1578 ACTIVATE_COERCE_NAMESPACES(float)1579 ACTIVATE_COERCE_NAMESPACES(double)1580 ACTIVATE_COERCE_NAMESPACES(ldouble)1581 ACTIVATE_COERCE_NAMESPACES(real)1582 1583 #if defined __GNUC__ && (__GNUC__ > 4  (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))1584 # pragma GCC diagnostic pop1585 #elif defined _MSC_VER1586 # pragma warning(pop)1587 #endif1588 1589 1390 #undef LOL_MEMBER_OPS 1590 1391 1591 #undef LOL_VECTOR_VECTOR_COERCE_OP1592 1392 #undef LOL_VECTOR_VECTOR_OP 1393 #undef LOL_VECTOR_VECTOR_NONCONST_OP 1593 1394 #undef LOL_VECTOR_MINMAX_FUN 1594 1395 #undef LOL_VECTOR_CLAMP_FUN 1595 1396 #undef LOL_VECTOR_MIX_FUN 1596 1397 #undef LOL_VECTOR_VECTOR_BOOL_OP 1597 #undef LOL_VECTOR_SCALAR_ COERCE_OP1598 #undef LOL_SCALAR_VECTOR_ COERCE_OP1398 #undef LOL_VECTOR_SCALAR_OP 1399 #undef LOL_SCALAR_VECTOR_OP 1599 1400 #undef LOL_VECTOR_SCALAR_OP 1600 1401 … … 1605 1406 #undef LOL_UNARY_OPS 1606 1407 #undef LOL_UNARY_FUNS 1607 #undef LOL_BINARY_NONVECTOR_COERCE_OPS 1608 #undef LOL_BINARY_NONVECTOR_COERCE_FUNS 1609 #undef LOL_BINARY_VECTOR_COERCE_OPS 1610 #undef LOL_VECTOR_COERCE_OPS 1611 #undef LOL_VEC_3_COERCE_FUNS 1612 #undef LOL_VEC_ANY_COERCE_OPS 1613 #undef LOL_VEC_ANY_COERCE_FUNS 1408 #undef LOL_VEC_3_FUNS 1614 1409 #undef LOL_VECTOR_OPS 1615 1410 … … 1618 1413 #undef LOL_ALL_VECTOR_FUNS_INNER 1619 1414 #undef LOL_ALL_VECTOR_OPS_AND_FUNS 1620 #undef LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS1621 1415 1622 1416 /* 
trunk/src/math/real.cpp
r2216 r2317 824 824 } 825 825 826 template<> real abs(real const &x) 827 { 828 return fabs(x); 829 } 830 831 template<> real fract(real const &x) 832 { 833 return x  floor(x); 834 } 835 826 836 static real fast_log(real const &x) 827 837 { 
trunk/src/math/vector.cpp
r2216 r2317 532 532 1.f  2.f * (q.z * q.z + q.y * q.y))); 533 533 534 return ( 180.0f / M_PI / n) * ret;534 return (float)(180.0f / M_PI / n) * ret; 535 535 } 536 536 … … 539 539 mat3 ret; 540 540 541 vec3 radians = ( M_PI / 180.0f) * v;541 vec3 radians = (float)(M_PI / 180.0f) * v; 542 542 float s0 = sin(radians[0]), c0 = cos(radians[0]); 543 543 float s1 = sin(radians[1]), c1 = cos(radians[1]); … … 605 605 static inline quat quat_fromeuler_generic(vec3 const &v, int i, int j, int k) 606 606 { 607 vec3 half_angles = ( M_PI / 360.0f) * v;607 vec3 half_angles = (float)(M_PI / 360.0f) * v; 608 608 float s0 = sin(half_angles[0]), c0 = cos(half_angles[0]); 609 609 float s1 = sin(half_angles[1]), c1 = cos(half_angles[1]); 
trunk/tools/neercs/video/textrender.cpp
r2277 r2317 187 187 glColor3f(1.0f, 1.0f, 1.0f); 188 188 189 vec2 tc = (vec2)m_canvas_size * m_font_size /m_fbo_size;189 vec2 tc = (vec2)m_canvas_size * (vec2)m_font_size / (vec2)m_fbo_size; 190 190 191 191 glLoadIdentity(); 
trunk/tutorial/11_fractal.cpp
r2312 r2317 49 49 else 50 50 m_window2world = 0.5 / m_window_size.x; 51 m_texel2world = ( vec2)m_window_size /m_size * m_window2world;51 m_texel2world = (dvec2)m_window_size / (dvec2)m_size * m_window2world; 52 52 53 53 m_oldmouse = ivec2(0, 0);
Note: See TracChangeset
for help on using the changeset viewer.