Browse Source

First implementation of the mouse tracker.

legacy
Sam Hocevar sam 14 years ago
parent
commit
f9cb712e81
1 changed files with 21 additions and 1 deletions
  1. +21
    -1
      src/input.cpp

+ 21
- 1
src/input.cpp View File

@@ -103,7 +103,27 @@ void Input::SetMousePos(int2 coord)
{
data->mouse = coord;

/* FIXME: parse all subscribed entities and update them */
WorldEntity *best = NULL;

for (int n = 0; n < data->nentities; n++)
{
if (coord.x < data->entities[n]->bbox[0].x
|| coord.x >= data->entities[n]->bbox[1].x
|| coord.y < data->entities[n]->bbox[0].y
|| coord.y >= data->entities[n]->bbox[1].y)
continue;

if (!best || best->bbox[1].z < data->entities[n]->bbox[1].z)
best = data->entities[n];
}

for (int n = 0; n < data->nentities; n++)
{
if (data->entities[n] == best)
data->entities[n]->mousepos = (int2)((int3)coord - best->bbox[0]);
else
data->entities[n]->mousepos = int2(-1);
}
}

void Input::SetMouseButton(int index)


Loading…
Cancel
Save