Changeset 1135 for trunk/monsterz


Ignore:
Timestamp:
Jan 27, 2012, 9:05:00 AM (8 years ago)
Author:
sam
Message:

math: move most vector and matrix member functions to global functions.

Location:
trunk/monsterz
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/board.cpp

    r1134 r1135  
    133133    position = ivec3(24, 72, 1);
    134134    bbox[0] = position;
    135     bbox[1] = bbox[0] + ivec3(384, 384, 0);
     135    bbox[1] = bbox[0] + vec3(384, 384, 0);
    136136
    137137    Input::TrackMouse(this);
     
    189189            if (cur_cell.x < 0 || cur_cell.x >= data->dim.x
    190190                 || cur_cell.y < 0 || cur_cell.y >= data->dim.y
    191                  || (cur_pos - cur_cell * data->size).sqlen() > data->size.sqlen() / 8
    192                  || (cur_cell - data->src_cell).sqlen() != 1)
     191                 || sqlen(cur_pos - cur_cell * data->size) > sqlen(data->size) / 8
     192                 || sqlen(cur_cell - data->src_cell) != 1)
    193193                cur_cell = ivec2(-1);
    194194            /* If potential target changed, update our cache. */
     
    221221
    222222        /* Mouse released, or exited window, or dragged too far. */
    223         if (!buttons[0] || mousepos.x == -1
    224              || (data->src_cell * data->size - data->grabbed.piece->GetPos()
    225                   - data->grabbed.piece->GetOffset()).sqlen() > 100 * 100)
     223        if (!buttons[0] || mousepos.x == -1 ||
     224             sqlen(data->src_cell * data->size - data->grabbed.piece->GetPos()
     225                  - data->grabbed.piece->GetOffset()) > 100 * 100)
    226226        {
    227227            ivec2 cell_a = data->src_cell;
  • trunk/monsterz/interface.cpp

    r1046 r1135  
    6262    position = ivec3(0, 0, 1);
    6363    bbox[0] = position;
    64     bbox[1] = bbox[0] + ivec3(640, 480, 0);
     64    bbox[1] = bbox[0] + vec3(640, 480, 0);
    6565}
    6666
  • trunk/monsterz/piece.cpp

    r1046 r1135  
    201201    case PieceData::MOVE:
    202202        /* Only allow swaps when piece is close enough to its target cell. */
    203         if (GetShift().sqlen() > data->size.sqlen() / 8)
     203        if (sqlen(GetShift()) > sqlen(data->size) / 8)
    204204            return 0;
    205205        /* Fall through */
     
    277277
    278278        ivec2 trip = data->pos_dst - data->pos_src;
    279         float pos_time = trip.len() / data->speed;
     279        float pos_time = len(trip) / data->speed;
    280280        float t = pos_time ? data->timer / pos_time : 1.0f;
    281281        if (t >= 1.0f)
    282282            t = 1.0f;
    283         data->pos = data->pos_src + t * vec2(trip) + vec2(0.5f);
    284 
    285         float off_time = data->off_src.len() / data->speed;
     283        data->pos = vec2(data->pos_src) + t * vec2(trip) + vec2(0.5f);
     284
     285        float off_time = len(data->off_src) / data->speed;
    286286        t = off_time ? data->timer / off_time : 1.0f;
    287287        if (t >= 1.0f)
     
    354354        break;
    355355    case PieceData::UNGRAB:
    356         if ((data->cell * data->size - data->pos_src).sqlen()
    357               > data->size.sqlen() / 8)
     356        if (sqlen(data->cell * data->size - data->pos_src)
     357              > sqlen(data->size) / 8)
    358358            off = 7;
    359359        z = 8;
  • trunk/monsterz/title.cpp

    r1046 r1135  
    135135    position = ivec3(0, 0, 1);
    136136    bbox[0] = position;
    137     bbox[1] = bbox[0] + ivec3(640, 480, 0);
     137    bbox[1] = bbox[0] + vec3(640, 480, 0);
    138138
    139139    srand(rand() ^ time(NULL));
     
    145145
    146146    data->ground = Tiler::Register(PNG_TITLE_GROUND, ivec2(384, 80), ivec2(0), 1.0f);
    147     data->ground_pos = ivec2((bbox[1] - bbox[0]).xy() / ivec2(2, 4))
     147    data->ground_pos = ivec2((bbox[1] - bbox[0]).xy() / vec2(2, 4))
    148148                     - ivec2(192, 80);
    149149
    150150    data->rocks = Tiler::Register(PNG_TITLE_ROCKS, ivec2(640, 155), ivec2(0), 1.0f);
    151     data->rocks_pos = ivec2((bbox[1] - bbox[0]).xy() / ivec2(2, 2))
     151    data->rocks_pos = ivec2((bbox[1] - bbox[0]).xy() / vec2(2, 2))
    152152                    - ivec2(320, 240);
    153153
Note: See TracChangeset for help on using the changeset viewer.