Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"b2MassData" is not bound / is not accessible. #38

Open
Joncom opened this issue Jul 15, 2013 · 4 comments
Open

"b2MassData" is not bound / is not accessible. #38

Joncom opened this issue Jul 15, 2013 · 4 comments

Comments

@Joncom
Copy link
Contributor

Joncom commented Jul 15, 2013

Test case:

  1. Open up box2d.js/html5canvas_demo/testbed.html in browser.
  2. You should now be looking at the "dominos" test.
  3. Type massData = new Box2D.b2MassData(); in console.

Error:
TypeError: undefined is not a function

@kripken
Copy link
Owner

kripken commented Jul 16, 2013

You can "trick" the old bindings generator into generating code for something by making it a class with a constructor. This makes it be bound, but I did not test beyond seeing it shows up as Box2D.b2MassData:

class b2MassData
{
public:
  b2MassData() {}

    /// The mass of the shape, usually in kilograms.
    float32 mass;

    /// The position of the shape's centroid relative to the shape's origin.
    b2Vec2 center;

    /// The rotational inertia of the shape about the local origin.
    float32 I;
};

@Joncom
Copy link
Contributor Author

Joncom commented Jul 17, 2013

Yes, that's correct. Do you suggest this "trick" as an official fix? Although it may work in this instance, it does not seem viable for other similar cases. For example, b2Manifold is also unbound, but it will not work here. It seems that it fails because the struct in this case contains an enum.

Not sure why it makes a difference but it does...

struct b2Manifold
{
    b2Manifold() {}

    enum Type
    {
        e_circles,
        e_faceA,
        e_faceB
    };

    b2ManifoldPoint points[b2_maxManifoldPoints];   ///< the points of contact
    b2Vec2 localNormal;                             ///< not use for Type::e_points
    b2Vec2 localPoint;                              ///< usage depends on manifold type
    Type type;
    int32 pointCount;                               ///< the number of manifold points
};

Sorry for not providing an exact error message. I'm simply recalling from memory the events I experienced with your port a couple weeks ago.

@jagenjo
Copy link

jagenjo commented Jul 17, 2013

Same here, I wanted to change the mass of an object during the execution but I cant see how is it possible if b2MassData is not visible.

@kripken
Copy link
Owner

kripken commented Jul 19, 2013

It could be an official fix, yeah ;) the problem is the old bindings
generator needs hacks like this to work, that's why moving to embind is a
good idea.

An enum should not matter, but perhaps I forgot yet another weirdness in
the old bindings generator. If you move the enum of out if, does it work?
My first guess is that the issue is either that it is a struct and not a
class, or that points' length depends on a variable (making it a C constant
might help).

On Wed, Jul 17, 2013 at 8:57 AM, jagenjo notifications@github.com wrote:

Same here, I wanted to change the mass of an object during the execution
but I cant see how is it possible if b2MassData is not visible.


Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-21123335
.

@mlogan mlogan mentioned this issue Aug 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants