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

JavaScript CreateFixture method no longer accesses global world variable... #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion liquidfun/Box2D/lfjs/jsBindings/Dynamics/b2Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function b2Body(ptr) {
this.buffer = new DataView(Module.HEAPU8.buffer, ptr);
this.ptr = ptr;
this.fixtures = [];
this.world = null;
}

b2Body.prototype.ApplyAngularImpulse = function(impulse, wake) {
Expand Down Expand Up @@ -110,7 +111,7 @@ b2Body.prototype.CreateFixtureFromDef = function(fixtureDef) {
fixture._SetPtr(fixtureDef.shape._CreateFixture(this, fixtureDef));
fixture.body = this;
b2World._Push(fixture, this.fixtures);
world.fixturesLookup[fixture.ptr] = fixture;
this.world.fixturesLookup[fixture.ptr] = fixture;
return fixture;
};

Expand Down Expand Up @@ -184,6 +185,10 @@ b2Body.prototype.GetUserData = function() {
return this.buffer.getUint32(b2Body_userData_offset, true);
};

b2Body.prototype.GetWorld = function() {
return this.world;
};

b2Body.prototype.GetWorldCenter = function() {
b2Body_GetWorldCenter(this.ptr, _vec2Buf.byteOffset);
var result = new Float32Array(_vec2Buf.buffer, _vec2Buf.byteOffset, _vec2Buf.length);
Expand Down
1 change: 1 addition & 0 deletions liquidfun/Box2D/lfjs/jsBindings/Dynamics/b2World.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ b2World.prototype.CreateBody = function(bodyDef) {
bodyDef.linearVelocity.y, bodyDef.position.x, bodyDef.position.y,
bodyDef.type, bodyDef.userData));
b2World._Push(body, this.bodies);
body.world = this;
this.bodiesLookup[body.ptr] = body;
return body;
};
Expand Down