A nil joint remains active in box2d until the garbage collector runs.
Is there a way to destroy joints explicitly without calling collectgarbage?
destroying joints
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: destroying joints
Not currently, no.
I think my original reasoning was:
That goes for the other objects too. I have no problem with the methods failing after destroy has been called, but they need to fail with the usual error message.
I just got this (obvious) idea:
... but I'm not sure if that works. I'll check it out. (Other suggestions are welcome).
I think my original reasoning was:
Code: Select all
joint = love.physics.newJoint( etc )
-- Do stuff
-- Removes instantly. (Pointer to Box2D object is destroyed here).
joint:destroy()
-- Methods can still be called, but will fail in all
-- kinds of horrible ways.
x1, y1, x2, y2 = joint:getPoints() -- doom
I just got this (obvious) idea:
Code: Select all
function Joint:destroy()
self:remove()
self.__index = function() return error("Object has been destroyed.") end
end
Re: destroying joints
It might be ok to fail in horrible ways after an explicit destroy().
Can you simply assign the symbol a nil value after the explicit destroy()?
Something like that, or possibly your example (not sure), would be ok too.
Can you simply assign the symbol a nil value after the explicit destroy()?
Something like that, or possibly your example (not sure), would be ok too.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 9 guests