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

Differences to original box2d

Open Lusito opened this issue 4 years ago • 5 comments

While I'm trying to look for ways to compare the code to original box2d, I noticed a few places, where the logic is quite different (beyond typescript conversion) and I wonder if that is something you rewrote yourself or if that came from the liquidfun project.

For example b2FindMaxSeparation differs a lot in implementation.

Lusito avatar Oct 17 '20 15:10 Lusito

It looks like it's an older version of b2FindMaxSeparation; I must have missed that when porting one of the releases. Thanks for letting me know. Let me know if you find anything else.

flyover avatar Oct 17 '20 22:10 flyover

Here's something that seems completely off:

Your b2AABB.Contains method:

        if (lowerBound.x <= aabb.lowerBound.x) {
            return false;
        }
        if (lowerBound.y <= aabb.lowerBound.y) {
            return false;
        }
        if (aabb.upperBound.x <= upperBound.x) {
            return false;
        }
        if (aabb.upperBound.y <= upperBound.y) {
            return false;
        }
        return true;

Box2d Contains method:

	result = true;
	result = result && lowerBound.x <= aabb.lowerBound.x;
	result = result && lowerBound.y <= aabb.lowerBound.y;
	result = result && aabb.upperBound.x <= upperBound.x;
	result = result && aabb.upperBound.y <= upperBound.y;
	return result;

This seems to be the exact opposite.

Lusito avatar Oct 23 '20 07:10 Lusito

You're right; fixed. Again, thanks for finding these.

flyover avatar Oct 23 '20 12:10 flyover

Is the difference intended in b2ContactFilter.ShouldCollide?

Lusito avatar Oct 26 '20 08:10 Lusito

Yes; it allows for reporting collisions between kinematic bodies (enabled by default). It's functionally the same, it just brings the body type check into the contact filter. I brought this up with Erin, but he decided against merging it upstream. https://github.com/erincatto/box2d/pull/349

flyover avatar Oct 26 '20 11:10 flyover