problem accessing fixture userdata from rayCast & BB

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
doofoid
Prole
Posts: 4
Joined: Sun May 20, 2012 2:04 am

problem accessing fixture userdata from rayCast & BB

Post 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
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: problem accessing fixture userdata from rayCast & BB

Post 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. :/
Shallow indentations.
doofoid
Prole
Posts: 4
Joined: Sun May 20, 2012 2:04 am

Re: problem accessing fixture userdata from rayCast & BB

Post 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.
doofoid
Prole
Posts: 4
Joined: Sun May 20, 2012 2:04 am

Re: problem accessing fixture userdata from rayCast & BB

Post 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!
Attachments
love1.zip
(902.66 KiB) Downloaded 128 times
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: problem accessing fixture userdata from rayCast & BB

Post by Boolsheet »

Ah, coroutines. The warning on the wiki applies to Lua threads as well for now.

I'm looking into possible fixes.
Shallow indentations.
doofoid
Prole
Posts: 4
Joined: Sun May 20, 2012 2:04 am

Re: problem accessing fixture userdata from rayCast & BB

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 10 guests