Changeset 485

Show
Ignore:
Timestamp:
10/14/07 05:15:23 (11 months ago)
Author:
krobillard
Message:

Math operators work on coord!.
GL - Added 'point-in.

Location:
trunk/thune
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/gl/gx.c

    r484 r485  
    14881488 
    14891489 
     1490#define ur_setLogic(c,b)      ur_initType(c,UT_LOGIC); ur_logic(c) = b 
     1491 
     1492// (rect pnt -- logic) 
     1493UR_CALL( uc_point_in ) 
     1494{ 
     1495    UCell* res = ur_s_prev(tos); 
     1496    if( ur_is(tos, UT_COORD) && ur_is(res, UT_COORD) ) 
     1497    { 
     1498        int inside; 
     1499        int16_t* pnt  = tos->coord.elem; 
     1500        int16_t* rect = res->coord.elem; 
     1501        if( pnt[0] < rect[0] || 
     1502            pnt[1] < rect[1] || 
     1503            pnt[0] > (rect[0] + rect[2]) || 
     1504            pnt[1] > (rect[1] + rect[3]) ) 
     1505            inside = 0; 
     1506        else 
     1507            inside = 1; 
     1508        ur_setLogic(res, inside); 
     1509        UR_S_DROP; 
     1510        return; 
     1511    } 
     1512    ur_throwErr( UR_ERR_DATATYPE, "point-in expected 2 coord! values" ); 
     1513} 
     1514 
     1515 
    14901516// Should 'gl-extensions, etc. be replaced with a single 'gl-info call that 
    14911517// returns a context holding version, extensions, max-textures, etc.? 
     
    17021728    { uc_curve_value,    "curve-value" }, 
    17031729    { uc_animate,        "animate" }, 
     1730    { uc_point_in,       "point-in" }, 
    17041731    { uc_gl_extensions,  "gl-extensions" }, 
    17051732    { uc_gl_max_textures,"gl-max-textures" }, 
  • trunk/thune/math.c

    r482 r485  
    3737 
    3838 
    39 #define MJ_INT_INT      0 
    40 #define MJ_INT_DEC      1 
    41 #define MJ_DEC_INT      2 
    42 #define MJ_DEC_DEC      3 
    43 #define MJ_VEC3_DEC     4 
    44 #define MJ_DEC_VEC3     5 
    45 #define MJ_VEC3_VEC3    6 
    46 #define MJ_INT_BIG      7 
    47 #define MJ_BIG_INT      8 
    48 #define MJ_DEC_BIG      9 
    49 #define MJ_BIG_DEC      10 
    50 #define MJ_BIG_BIG      11 
    51 #define MJ_NAN          12 
     39enum MathJumpPair 
     40{ 
     41    MJ_INT_INT, 
     42    MJ_INT_DEC, 
     43    MJ_DEC_INT, 
     44    MJ_DEC_DEC, 
     45    MJ_VEC3_DEC, 
     46    MJ_DEC_VEC3, 
     47    MJ_VEC3_VEC3, 
     48    MJ_COORD_INT, 
     49    MJ_COORD_COORD, 
     50    MJ_INT_BIG, 
     51    MJ_BIG_INT, 
     52    MJ_DEC_BIG, 
     53    MJ_BIG_DEC, 
     54    MJ_BIG_BIG, 
     55    MJ_NAN 
     56}; 
    5257 
    5358static int _mathJumpIndex( const UCell* a, const UCell* b ) 
     
    8893        if( ur_is(b, UT_BIGNUM) ) 
    8994            return MJ_BIG_BIG; 
     95    } 
     96    else if( ur_is(a, UT_COORD) ) 
     97    { 
     98        if( ur_is(b, UT_INT) ) 
     99            return MJ_COORD_INT; 
     100        if( ur_is(b, UT_COORD) ) 
     101            return MJ_COORD_COORD; 
    90102    } 
    91103 
     
    215227            res->vec3.xyz[1] = res->vec3.xyz[1] OP tos->vec3.xyz[1]; \ 
    216228            res->vec3.xyz[2] = res->vec3.xyz[2] OP tos->vec3.xyz[2]; \ 
    217             break; 
     229            break; \ 
     230        case MJ_COORD_INT: \ 
     231        {   int i, count = res->coord.len; \ 
     232            for( i = 0; i < count; ++i ) \ 
     233                res->coord.elem[i] = res->coord.elem[i] OP ur_int(tos); \ 
     234        }   break; \ 
     235        case MJ_COORD_COORD: \ 
     236        {   int i, count = res->coord.len; \ 
     237            if( tos->coord.len < count ) \ 
     238                count = tos->coord.len; \ 
     239            for( i = 0; i < count; ++i ) \ 
     240                res->coord.elem[i] = res->coord.elem[i] OP tos->coord.elem[i];\ 
     241        }   break; 
     242 
    218243 
    219244#define MATH_OPERATION_END \