Birch-san / box2d-wasm

Box2D physics engine compiled to WebAssembly. Supports TypeScript and ES modules.
265 stars 21 forks source link

GetFixtureList().Next() Never returns falsey #11

Closed mfs409 closed 3 years ago

mfs409 commented 3 years ago

I am trying to port from a different TypeScript Box2D port, but I am finding that all code of this form has infinite loops:

// Set all fixtures to be sensors
for (let f = this.body.GetFixtureList(); f; f = f.GetNext()) {
    f.SetSensor(!true);
}

It seems that f.GetNext() never returns undefined, null, or false, and so the loop keeps running forever.

jordandcarter commented 3 years ago

I had the same issue and used this with success. I am iterating over the bodies list though, but it might work out the same.

for(let body = world.GetBodyList(); box2D.getPointer(body) !== 0; body = body.GetNext()){

mfs409 commented 3 years ago

Awesome. Thanks a ton :)