box2d.js icon indicating copy to clipboard operation
box2d.js copied to clipboard

Calling GetNext on fixture always return some object

Open ttRevan opened this issue 12 years ago • 7 comments
trafficstars

The next code snippet results in an infinte loop:

var fixture = body.GetFixtureList();
while (fixture) {
    aabb.Combine(aabb, fixture.GetAABB());
    fixture = fixture.GetNext();
}

As I understand, it happens because GetNext() and similar functions in turn calls some wrapping function, that always create some object (if none) to return:

function Z(b, d) {
    var e = d ? d.prototype.b : cW,
    f = e[b];
    if (f) {
        return f
    }
    d = d || Object;
    f = Object.create(d.prototype);
    f.a = b;
    f.c = d;
    return e[b] = f
}
Module.wrapPointer = Z;

ttRevan avatar Mar 03 '13 11:03 ttRevan

I have the same problem....

sebastianovide avatar Apr 12 '13 21:04 sebastianovide

Calling GetNext() on a body results in the same problem. A loop like the following will never exit:

for (var body = world.GetBodyList(); body; body = body.GetNext()) {
   // stuff
}

bunnyhero avatar May 29 '13 06:05 bunnyhero

Bit of a hack, but this seems to work:

for(var edge = this.body.GetContactList(); edge.ptr !== 0; edge = edge.get_next()) {}

Joncom avatar Jun 07 '13 16:06 Joncom

Nice, thanks!

bunnyhero avatar Jun 07 '13 18:06 bunnyhero

When looping through Bodies, .ptr resulted in an error. I had to use Box2D.getPointer(body) !== 0

bunnyhero avatar Jul 01 '13 00:07 bunnyhero

Yes, you are correct. And you've already discovered the workaround. Since there is a workaround, this issue is quite superficial. Just a heads up however, there are many deeper issues with this port which make it unusable for any non-experimental purposes. Box2DWeb is more reliable presently, albeit slightly older.

On 2013-06-30, at 5:16 PM, bunnyhero [email protected] wrote:

When looping through Bodies, .ptr resulted in an error. I had to use Box2D.getPointer(body) !== 0

— Reply to this email directly or view it on GitHub.

Joncom avatar Jul 01 '13 03:07 Joncom

Hi,

I also like the syntax better of this port. What other deeper issues there? I would prefer to include this port with RaptorGL instead of Box2DWeb. I'm happy to help out if you can give me some pointers.

Cheers

Laszlo http://twitter.com/LZAntal

On Jun 30, 2013, at 8:16 PM, Jonathan Commins [email protected] wrote:

Yes, you are correct. And you've already discovered the workaround. Since there is a workaround, this issue is quite superficial. Just a heads up however, there are many deeper issues with this port which make it unusable for any non-experimental purposes. Box2DWeb is more reliable presently, albeit slightly older.

On 2013-06-30, at 5:16 PM, bunnyhero [email protected] wrote:

When looping through Bodies, .ptr resulted in an error. I had to use Box2D.getPointer(body) !== 0

— Reply to this email directly or view it on GitHub. — Reply to this email directly or view it on GitHub.

lzantal avatar Jul 02 '13 18:07 lzantal

A bunch of functions do not properly return values. For example, body.GetMassData() returns an error always. In fact the b2MassData class is not bound, and thus is not available for use. This is not the issue however, because even if you were to use embind to make the class available, the function still does not appear to return valid data. Other important functionality like b2Manifold used when listening for collisions is also broken. There are actually quite a few classes which have not been bound. But who knows, maybe you won't need them...

On 2013-07-02, at 11:47 AM, lzantal [email protected] wrote:

Hi,

I also like the syntax better of this port. What other deeper issues there? I would prefer to include this port with RaptorGL instead of Box2DWeb. I'm happy to help out if you can give me some pointers.

Cheers

Laszlo http://twitter.com/LZAntal

On Jun 30, 2013, at 8:16 PM, Jonathan Commins [email protected] wrote:

Yes, you are correct. And you've already discovered the workaround. Since there is a workaround, this issue is quite superficial. Just a heads up however, there are many deeper issues with this port which make it unusable for any non-experimental purposes. Box2DWeb is more reliable presently, albeit slightly older.

On 2013-06-30, at 5:16 PM, bunnyhero [email protected] wrote:

When looping through Bodies, .ptr resulted in an error. I had to use Box2D.getPointer(body) !== 0

— Reply to this email directly or view it on GitHub. — Reply to this email directly or view it on GitHub. — Reply to this email directly or view it on GitHub.

Joncom avatar Jul 02 '13 23:07 Joncom