Changeset 1952


Ignore:
Timestamp:
Sep 26, 2012, 3:51:26 PM (5 years ago)
Author:
sam
Message:

gpu: if 2D tiles have negative scaling, switch the triangle winding.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tileset.cpp

    r1808 r1952  
    269269                       float *vertex, float *texture)
    270270{
    271     float tx = data->tx * ((id & 0xffff) % data->count.x);
    272     float ty = data->ty * ((id & 0xffff) / data->count.x);
     271    float dtx = data->tx;
     272    float dty = data->ty;
     273    float tx = dtx * ((id & 0xffff) % data->count.x);
     274    float ty = dty * ((id & 0xffff) / data->count.x);
    273275
    274276    int dx = data->size.x * scale.x;
     
    276278    int dz = o ? data->size.y * scale.y : 0;
    277279
     280    /* If scaling is negative, switch triangle winding */
     281    if (scale.x * scale.y < 0.0f)
     282    {
     283        pos.x += dx;
     284        dx = -dx;
     285
     286        tx += dtx;
     287        dtx = -dtx;
     288    }
     289
    278290    if (!data->img && data->m_tex)
    279291    {
     
    283295        *vertex++ = pos.y + dy;
    284296        *vertex++ = pos.z + dz;
    285         *texture++ = tx + data->tx;
     297        *texture++ = tx + dtx;
    286298        *texture++ = ty;
    287299
     
    295307        *vertex++ = tmp[6] = pos.y;
    296308        *vertex++ = tmp[7] = pos.z;
    297         *texture++ = tmp[8] = tx + data->tx;
    298         *texture++ = tmp[9] = ty + data->ty;
     309        *texture++ = tmp[8] = tx + dtx;
     310        *texture++ = tmp[9] = ty + dty;
    299311
    300312        *vertex++ = tmp[5];
     
    314326        *vertex++ = pos.z;
    315327        *texture++ = tx;
    316         *texture++ = ty + data->ty;
     328        *texture++ = ty + dty;
    317329    }
    318330    else
Note: See TracChangeset for help on using the changeset viewer.