kripken / box2d.js

Port of Box2D to JavaScript using Emscripten
1.33k stars 196 forks source link

b2Manifold b2ManifoldPoint[] points #84

Open GuillaumeBouchetEpitech opened 7 years ago

GuillaumeBouchetEpitech commented 7 years ago

Hi,

I like this Box2D port and started using it for a project. But I am facing an issue and need to know if it can be solved.

Short story:

I would like to know if someone can make it possible to access this b2Manifold attribute: -> [Value] attribute b2ManifoldPoint[] points;

which is marked as TODO here:

interface b2Manifold {
  void b2Manifold();
  // TODO: webidl_binder support for array types.
  // [Value] attribute b2ManifoldPoint[] points;
  [Value] attribute b2Vec2 localNormal;
  [Value] attribute b2Vec2 localPoint;
  attribute b2ManifoldType type;
  attribute long pointCount;
};

Long story:

I am creating a platformer, and would like to use b2ContactListener::PreSolve([...]) or b2ContactListener::BeginContact([...]) to record the b2Contact as they are created/released while stepping the world.

The point is to stop a "player body" to go left/right if it hit something in the world or to know if this "player body" is on the ground thanks to the contact normal.

Anyway, the need of the b2WorldManifold is high... and the way of obtaining that object is from this b2Contact::GetWorldManifold([...]) method.

The point this time, I got the source code of b2Contact::GetWorldManifold([...]) and can easely recode it from the c++ version BUT.... this method use the [Value] attribute b2ManifoldPoint[] points; from b2Manifold...

alperencaliskan commented 7 years ago

Yes, GetWorldManifold is missing in bindings. I have modified idl bindings for my game and have just created pull request for it. https://github.com/kripken/box2d.js/pull/88