Page 1 of 1

problem accessing fixture userdata from rayCast & BB

Posted: Sun May 20, 2012 2:23 am
by doofoid
Hi All

I seem to be getting a function back from fixture:getUserData() in the callbacks of
world:queryBoundingBox and world:rayCast - not the table I expect.
(the only userData set anywhere in my code is a table, no functions)

for the fixtures in beginContact, endContact etc it's working as expected
i.e.
function beginContact(a, b, coll)
a:getUserData(), b:getUserData() -- works fine.

Some code:

function bbCallback(fixt)
local t = fixt:getUserData()
print('userdata was '..type(t)..' huh?') -- getting function should be table

function rayCallback(fixt)
print('type fixt '..type(fixt))

world:queryBoundingBox(mx, my, mx, my, bbCallback)
world:rayCast( mx, my, mx+20, my, rayCallback )

Like I mentioned, the collision fixtures have userdata ok.

Can anybody confirm if this is bug in love (0.8), or see a problem in my code?

Thanks

Re: problem accessing fixture userdata from rayCast & BB

Posted: Sun May 20, 2012 3:50 am
by Boolsheet
Don't see it with my test. Can you provide a working example that shows the behaviour?

I hope I didn't break Reference. :/

Re: problem accessing fixture userdata from rayCast & BB

Posted: Sun May 20, 2012 1:26 pm
by doofoid
A test example is working. (darn it)
I'll look into it some more. Seems weird, I'm only setting userdata in one place and
the access to it from collision callbacks is working.

Thanks for a quick response. If it really has me stuck perhaps I'll post the project here.

Re: problem accessing fixture userdata from rayCast & BB

Posted: Sun May 20, 2012 2:07 pm
by doofoid
Well I may as well post the project. Perhaps it's something another pair of eyes can spot.

unexpected userdata is at line 32 of file controls.lua

userdata accessed ok at line 12 of file physics.lua

only place userdata set:
line 66 & 77 of physics.lua
(where did the function userdata come from?)



In addition any criticism of the code would be appreciated.
(although it's early version..)
Mucho thanks to anybody who takes a look!

Re: problem accessing fixture userdata from rayCast & BB

Posted: Mon May 21, 2012 3:41 am
by Boolsheet
Ah, coroutines. The warning on the wiki applies to Lua threads as well for now.

I'm looking into possible fixes.

Re: problem accessing fixture userdata from rayCast & BB

Posted: Mon May 21, 2012 11:46 am
by doofoid
That'd be it.
Would be nice if that wasn't a limitation, but now I know what it is - I can work around it.
Thanks a lot.