Ignore:
Timestamp:
Feb 1, 2011, 11:07:12 PM (10 years ago)
Author:
sam
Message:

First implementation of the mouse tracker.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/input.cpp

    r329 r330  
    104104    data->mouse = coord;
    105105
    106     /* FIXME: parse all subscribed entities and update them */
     106    WorldEntity *best = NULL;
     107
     108    for (int n = 0; n < data->nentities; n++)
     109    {
     110        if (coord.x < data->entities[n]->bbox[0].x
     111             || coord.x >= data->entities[n]->bbox[1].x
     112             || coord.y < data->entities[n]->bbox[0].y
     113             || coord.y >= data->entities[n]->bbox[1].y)
     114            continue;
     115
     116        if (!best || best->bbox[1].z < data->entities[n]->bbox[1].z)
     117            best = data->entities[n];
     118    }
     119
     120    for (int n = 0; n < data->nentities; n++)
     121    {
     122        if (data->entities[n] == best)
     123            data->entities[n]->mousepos = (int2)((int3)coord - best->bbox[0]);
     124        else
     125            data->entities[n]->mousepos = int2(-1);
     126    }
    107127}
    108128
Note: See TracChangeset for help on using the changeset viewer.