Changeset 485 for trunk/thune/math.c

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

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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 \