From 83d6c60fea30300902989b0aac73b592ea0f405b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 21 Feb 2010 22:17:29 +0000 Subject: [PATCH] fixed bug in 3d picking; ag.pickObjects() working now git-svn-id: svn://anubis/anaglym/trunk@255 99a6e188-d820-4881-8870-2d33a10e2619 --- .todo | 2 +- ag.cc | 4 ++-- tests/managed_objects.lua | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.todo b/.todo index 34f09ef..e53b7f5 100644 --- a/.todo +++ b/.todo @@ -1,2 +1,2 @@ -add 3d-picking routines using temporary ODE ray geometries +add API documentation for ag.pickObjects() add audio capabilities diff --git a/ag.cc b/ag.cc index 39013fc..a6a57ba 100644 --- a/ag.cc +++ b/ag.cc @@ -100,8 +100,8 @@ namespace ag lua_getfield(L, -1, "_objects"); /* pushes 1 */ lua_pushinteger(L, *it); /* pushes 1 */ lua_gettable(L, -2); /* replace top */ + lua_remove(L, -3); /* remove 1 */ lua_remove(L, -2); /* remove 1 */ - lua_remove(L, -1); /* remove 1 */ if (!lua_isnil(L, -1)) { lua_pushinteger(L, next_index++); /* push key */ @@ -300,7 +300,7 @@ namespace ag lua_getfield(L, LUA_GLOBALSINDEX, "ag"); /* pushes 1 */ lua_getfield(L, -1, "_objects"); /* pushes 1 */ lua_pushinteger(L, id); /* pushes 1 */ - lua_pushvalue(L, 1); /* pushes 1 */ + lua_pushvalue(L, -4); /* pushes 1 */ lua_settable(L, -3); /* pops 2 */ lua_pop(L, 2); /* pops 2 */ } diff --git a/tests/managed_objects.lua b/tests/managed_objects.lua index 7450479..cee29d8 100644 --- a/tests/managed_objects.lua +++ b/tests/managed_objects.lua @@ -60,6 +60,11 @@ end function mousebutton_down_event(button, x, y) if (button == 1) then - ag.pickObjects(x, y) + objects = ag.pickObjects(x, y) + if (objects ~= nil) then + for id, obj in ipairs(objects) do + obj:setColor(0, 0, 1) + end + end end end