ice1000 / gdx-box2d

Support ropes, up-to-date box2dLight

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include functions from the Collisions API

APXEOLOG opened this issue · comments

Hello, can we add binding for some functions available in the Box2D Collision API?

I'm specifically interested in b2TestOverlap, but there are many functions out there that are useful as well.

Which overload are you specifically interested in?

For my project it would be useful to have access to the following functions:

b2TestOverlap from b2_collision.h

b2TestOverlap (const b2Shape *shapeA, int32 indexA, const b2Shape *shapeB, int32 indexB, const b2Transform &xfA, const b2Transform &xfB)

(The AABB version bool b2TestOverlap (const b2AABB &a, const b2AABB &b) can be useful as well, even though I do not have use case for it right now)

b2Distance from b2_distance.h

B2_API void b2Distance(b2DistanceOutput* output,
                 b2SimplexCache* cache,
                 const b2DistanceInput* input);

Working with b2DistanceProxy in the b2DistanceInput looks a bit hard, but the others are just trivial work. I'll try to do them this week.

@APXEOLOG I've implemented b2TestOverlap. I don't want to do the AABB version because it's an inline function on C++ side, so IMO it should be implemented in Java, instead of through JNI. How do you plan to use b2DistanceProxy? I don't want to make too complicated interface just for b2Distance...

So I'll avoid b2Distance for now, and publish a newer version. I've also updated the libgdx dependency in this project, hopefully it can be nicer this way.

com.badlogic.gdx.physics.box2d.Shape#testOverlap

@APXEOLOG I've implemented b2TestOverlap. I don't want to do the AABB version because it's an inline function on C++ side, so IMO it should be implemented in Java, instead of through JNI. How do you plan to use b2DistanceProxy? I don't want to make too complicated an interface just for b2Distance...

As far as I see b2Distance allows us to calculate the distance between the two "bodies" (shape + transform vs share + transform). This is what I intended to use it for. But it's fine without it, I did a workaround approximate implementation for now, maybe I'll look into this issue later, if I'll need an improved version.

Thank you very much for adding b2TestOverlap!

@APXEOLOG I've implemented b2TestOverlap. I don't want to do the AABB version because it's an inline function on C++ side, so IMO it should be implemented in Java, instead of through JNI. How do you plan to use b2DistanceProxy? I don't want to make too complicated an interface just for b2Distance...

As far as I see b2Distance allows us to calculate the distance between the two "bodies" (shape + transform vs share + transform). This is what I intended to use it for. But it's fine without it, I did a workaround approximate implementation for now, maybe I'll look into this issue later, if I'll need an improved version.

Thank you very much for adding b2TestOverlap!

If you look close enough at my recent commits on adding testOverlap it should be fairly easy to infer how to add distance. It remains to figure out if we can just dodge those callbacks at all, and it could possibly be worked out this way. Contribution is always welcome.