-
Notifications
You must be signed in to change notification settings - Fork 196
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
helper tools #87
Comments
With new emscripten builds helper code doesn't work because they removed allocate and setvalue functions. https://github.com/kripken/ammo.js/pull/121 function createPolygonShape(vertices) {
var shape = new Box2D.b2PolygonShape();
// var buffer = Box2D.allocate(vertices.length * 8, 'float', Box2D.ALLOC_STACK);
var buffer = Box2D._malloc(vertices.length * 8);
var offset = 0;
for (var i = 0; i < vertices.length; i++) {
// Box2D.setValue(buffer + (offset), vertices[i].get_x(), 'float'); // x
Box2D.HEAPF32[buffer + offset >> 2] = vertices[i].get_x();
// Box2D.setValue(buffer + (offset + 4), vertices[i].get_y(), 'float'); // y
Box2D.HEAPF32[buffer + (offset + 4) >> 2] = vertices[i].get_y();
offset += 8;
}
var ptr_wrapped = Box2D.wrapPointer(buffer, Box2D.b2Vec2);
shape.Set(ptr_wrapped, vertices.length);
return shape;
} |
huy-nguyen
added a commit
to huy-nguyen/box2d.js
that referenced
this issue
Apr 18, 2020
Adapted from kripken#87 (comment).
Merged
kripken
pushed a commit
that referenced
this issue
Jun 1, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been trying to work with the helper tools, but found that they don't work as they come
I had to refactor the .allocate function to _malloc and change Box2D.SetValue to _memAlloc
But at the moment, I still can't create a polygon because I get an assertion error on PolygonShape.Set
I have tried placing my vertices clockwise and counterclockwise, both to no avail
Any ideas?
The text was updated successfully, but these errors were encountered: