Open Joncom opened 11 years ago
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;
};
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.
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.
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/kripken/box2d.js/issues/38#issuecomment-21123335 .
Test case:
box2d.js/html5canvas_demo/testbed.html
in browser.massData = new Box2D.b2MassData();
in console.Error:
TypeError: undefined is not a function