Michael Edwards wrote:
What's the best way to either remove or reset a Body object? I'm making a bowling game (which has made an amazing amount of progress in just a couple days thanks to Soya!) After the pins knock down, I want to reset the pins and the ball. I wasn't able to find a way to reset the bodies to their previous positions without residual forces from the previous roll continuing to act on them.For example, when I reset the position of the ball and do ball.set_force((0.0,0.0,0.0)), it still retains the forward-moving (-Z) force from the previous roll. I tried to get around this by simply deleting the ball and pins and then re-creating them. Unfortunately, it looks as if I haven't released the resources, because my processor usage keeps bumping up after every new set of objects gets created. I tried doing this (for the pins): for pin in pins: pin.space.remove(pin.pin_geom) space.remove(pin.space) scene.remove(pin) pin.space = None pin.pin_geom = None pin.mass = None pin.enabled = 0 pin = None ...but I still seem to have resources in use. Using the "del" statement doesn't seem to help either. Any ideas?
You need to remove the pins from their world too, not just the space. I hope that's even possible; I haven't tried it before. To set the velocity to zero, use pin.linear_velocity = (0, 0, 0). You need today's CVS for that because I forgot to include it before now. It helps a lot finally having someone using ODE, because my tests really aren't good enough to catch stuff I might have omitted.
signature.asc
Description: OpenPGP digital signature
