Removing a RigidBody then adding it back causes an infinite loop

5 views
Skip to first unread message

Alain-Daniel Bourdages

unread,
Dec 12, 2011, 2:09:13 PM12/12/11
to glaze Engine
Hello,

I have started using Glaze recently and I am pretty happy with it so
far - great job! However, I think I have found a problem: I have a
rigid body that I use as a sensor and when it is tripped, I remove it
from the space (maybe there is a better way to disable it?). Later
when some new condition arise, I add it back to the world... and that
causes the program the hang due to an infinite loop in physicsStep()
at


while (shape) {
if (!shape.body.isSleeping)
shape.Update();
shape = shape.next;
}

The reason I found is that when removing a shape/body from the space,
prev and next have lingering values that should be nulled. So, when
the body/shape is added back at the top of the list, the next/prev
properties still hold some values. Under some conditions, that messes
up the linked list and cause it to loop upon itself.

Simply adding "body.prev = body.next = null' in addBody and the same
in addShape fixes the problem.

Cheers,
Alain-Daniel

Reply all
Reply to author
Forward
0 new messages