Changeset 2317


Ignore:
Timestamp:
Feb 2, 2013, 4:00:28 PM (6 years ago)
Author:
sam
Message:

math: remove coercion rules in the vector classes, they increase the
compilation time for very little benefit and maybe even confusion.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/math/real.h

    r2183 r2317  
    122122    template<int M> friend Real<M> round(Real<M> const &x);
    123123    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);
    124128
    125129    void hexprint() const;
     
    270274template<> real round(real const &x);
    271275template<> real fmod(real const &x, real const &y);
     276template<> real abs(real const &x);
     277template<> real fract(real const &x);
    272278
    273279template<> void real::hexprint() const;
  • trunk/src/lol/math/vector.h

    r2279 r2317  
    10411041 * vec /(vec, vec)
    10421042 */
    1043 #define LOL_VECTOR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
    1044     tprefix \
    1045     inline tname<tf> operator op(tname<t1> const &a, tname<t2> const &b) \
    1046     { \
    1047         tname<tf> ret; \
    1048         for (size_t n = 0; n < sizeof(a) / sizeof(t1); 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++) \
    10491049            ret[n] = a[n] op b[n]; \
    10501050        return ret; \
     
    10571057 * vec /=(vec, vec)
    10581058 */
    1059 #define LOL_VECTOR_VECTOR_OP(tname, op, tprefix, type) \
     1059#define LOL_VECTOR_VECTOR_NONCONST_OP(tname, op, tprefix, type) \
    10601060    tprefix \
    10611061    inline tname<type> operator op##=(tname<type> &a, tname<type> const &b) \
     
    11621162 * bool <(vec, vec)
    11631163 */
    1164 #define LOL_VECTOR_VECTOR_BOOL_OP(tname, op, op2, ret, tprefix, t1, t2) \
    1165     tprefix \
    1166     inline bool operator op(tname<t1> const &a, tname<t2> const &b) \
    1167     { \
    1168         for (size_t n = 0; n < sizeof(a) / sizeof(t1); 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++) \
    11691169            if (!(a[n] op2 b[n])) \
    11701170                return !ret; \
     
    11761176 * vec /(vec, scalar)   (also complex & quaternion)
    11771177 */
    1178 #define LOL_VECTOR_SCALAR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
    1179     tprefix \
    1180     inline tname<tf> operator op(tname<t1> const &a, t2 const &val) \
    1181     { \
    1182         tname<tf> ret; \
    1183         for (size_t n = 0; n < sizeof(a) / sizeof(t1); 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++) \
    11841184            ret[n] = a[n] op val; \
    11851185        return ret; \
     
    11901190 * vec /(scalar, vec)   (NOT for complex & quaternion!)
    11911191 */
    1192 #define LOL_SCALAR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
    1193     tprefix \
    1194     inline tname<tf> operator op(t1 const &val, tname<t2> const &a) \
    1195     { \
    1196         tname<tf> ret; \
    1197         for (size_t n = 0; n < sizeof(a) / sizeof(t2); 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++) \
    11981198            ret[n] = a[n] op val; \
    11991199        return ret; \
     
    12041204 * vec /=(vec, scalar)   (also complex & quaternion)
    12051205 */
    1206 #define LOL_VECTOR_SCALAR_OP(tname, op, tprefix, type) \
     1206#define LOL_VECTOR_SCALAR_NONCONST_OP(tname, op, tprefix, type) \
    12071207    tprefix \
    12081208    inline tname<type> operator op##=(tname<type> &a, type const &val) \
     
    12621262    }
    12631263
    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++) \
    12811270            ret += a[n] * b[n]; \
    12821271        return ret; \
    12831272    } \
    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++) \
    12891280            ret[n] = a[n] + (b[n] - a[n]) * x; \
    12901281        return ret; \
    12911282    }
    12921283
    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)); \
    13031291    }
    13041292
    13051293#define LOL_BINARY_NONVECTOR_OPS(tname, tprefix, type) \
    1306     LOL_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, type, type, type) \
    1307     \
    13081294    LOL_VECTOR_VECTOR_OP(tname, -, tprefix, type) \
    13091295    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) \
    13101299    \
    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)
    13161307
    13171308#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)
    13191310
    13201311#define LOL_BINARY_VECTOR_FUNS(tname, tprefix, type) \
     
    13231314    LOL_VECTOR_MINMAX_FUN(tname, fmod, tprefix, type) \
    13241315    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) \
    13301317    \
    1331     LOL_VECTOR_VECTOR_BOOL_OP(tname, <=, <=, true, tprefix, t1, t2) \
    1332     LOL_VECTOR_VECTOR_BOOL_OP(tname, >=, >=, true, tprefix, t1, t2) \
    1333     LOL_VECTOR_VECTOR_BOOL_OP(tname, <, <, true, tprefix, t1, t2) \
    1334     LOL_VECTOR_VECTOR_BOOL_OP(tname, >, >, true, tprefix, t1, 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)
    13351322
    13361323#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) \
    13381326    \
    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)
    13411329
    13421330#define LOL_ALL_NONVECTOR_OPS_AND_FUNS(tname) \
     
    13681356    LOL_ALL_VECTOR_FUNS_INNER(Vec3, type) \
    13691357    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)
    13971359
    13981360LOL_ALL_NONVECTOR_OPS_AND_FUNS(Cmplx)
     
    14181380LOL_ALL_VECTOR_OPS_AND_FUNS(uint64_t)
    14191381
     1382/* FIXME: vectors of "real" are deactivated for now, because we do
     1383 * not implement all combinations of operators for these types yet. */
     1384LOL_ALL_VECTOR_OPS_AND_FUNS(real)
     1385
    14201386#if defined _MSC_VER
    14211387#   pragma warning(pop)
    14221388#endif
    14231389
    1424 /* Disable warnings in the >= > etc. operators about comparing signed and
    1425  * unsigned. Ideally we would like to get these warnings only when the
    1426  * inlined operators are actually used, but they seem to be triggered at
    1427  * the code parsing step, so the compiler does not yet know whether they
    1428  * will be used.
    1429  * Also we do this for the whole block of declarations, because GCC prior
    1430  * 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 push
    1433 #   pragma GCC diagnostic ignored "-Wsign-compare"
    1434 #elif defined _MSC_VER
    1435 #   pragma warning(push)
    1436 #   pragma warning(disable: 4018)
    1437 #endif
    1438 
    1439 /* Apply the same coercion rules as in the C++ standard. However, instead
    1440  * of always promoting smaller types to int, we allow int8_t op int16_t to
    1441  * 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 they
    1508  * induce extremely long compilation times (about 17 seconds per TU). */
    1509 
    1510 #if 0
    1511 /* All integer types are promoted to half; all floating point types
    1512  * 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 #endif
    1526 
    1527 /* FIXME: vectors of "real" are deactivated for now, because we do
    1528  * not implement all combinations of operators for these types yet. */
    1529 
    1530 #if 0
    1531 /* 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 #endif
    1545 
    1546 /* Activate all the namespaces that we created. Delaying this activation
    1547  * 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 pop
    1585 #elif defined _MSC_VER
    1586 #   pragma warning(pop)
    1587 #endif
    1588 
    15891390#undef LOL_MEMBER_OPS
    15901391
    1591 #undef LOL_VECTOR_VECTOR_COERCE_OP
    15921392#undef LOL_VECTOR_VECTOR_OP
     1393#undef LOL_VECTOR_VECTOR_NONCONST_OP
    15931394#undef LOL_VECTOR_MINMAX_FUN
    15941395#undef LOL_VECTOR_CLAMP_FUN
    15951396#undef LOL_VECTOR_MIX_FUN
    15961397#undef LOL_VECTOR_VECTOR_BOOL_OP
    1597 #undef LOL_VECTOR_SCALAR_COERCE_OP
    1598 #undef LOL_SCALAR_VECTOR_COERCE_OP
     1398#undef LOL_VECTOR_SCALAR_OP
     1399#undef LOL_SCALAR_VECTOR_OP
    15991400#undef LOL_VECTOR_SCALAR_OP
    16001401
     
    16051406#undef LOL_UNARY_OPS
    16061407#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
    16141409#undef LOL_VECTOR_OPS
    16151410
     
    16181413#undef LOL_ALL_VECTOR_FUNS_INNER
    16191414#undef LOL_ALL_VECTOR_OPS_AND_FUNS
    1620 #undef LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS
    16211415
    16221416/*
  • trunk/src/math/real.cpp

    r2216 r2317  
    824824}
    825825
     826template<> real abs(real const &x)
     827{
     828    return fabs(x);
     829}
     830
     831template<> real fract(real const &x)
     832{
     833    return x - floor(x);
     834}
     835
    826836static real fast_log(real const &x)
    827837{
  • trunk/src/math/vector.cpp

    r2216 r2317  
    532532                   1.f - 2.f * (q.z * q.z + q.y * q.y)));
    533533
    534     return (180.0f / M_PI / n) * ret;
     534    return (float)(180.0f / M_PI / n) * ret;
    535535}
    536536
     
    539539    mat3 ret;
    540540
    541     vec3 radians = (M_PI / 180.0f) * v;
     541    vec3 radians = (float)(M_PI / 180.0f) * v;
    542542    float s0 = sin(radians[0]), c0 = cos(radians[0]);
    543543    float s1 = sin(radians[1]), c1 = cos(radians[1]);
     
    605605static inline quat quat_fromeuler_generic(vec3 const &v, int i, int j, int k)
    606606{
    607     vec3 half_angles = (M_PI / 360.0f) * v;
     607    vec3 half_angles = (float)(M_PI / 360.0f) * v;
    608608    float s0 = sin(half_angles[0]), c0 = cos(half_angles[0]);
    609609    float s1 = sin(half_angles[1]), c1 = cos(half_angles[1]);
  • trunk/tools/neercs/video/text-render.cpp

    r2277 r2317  
    187187    glColor3f(1.0f, 1.0f, 1.0f);
    188188
    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;
    190190
    191191    glLoadIdentity();
  • trunk/tutorial/11_fractal.cpp

    r2312 r2317  
    4949        else
    5050            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;
    5252
    5353        m_oldmouse = ivec2(0, 0);
Note: See TracChangeset for help on using the changeset viewer.