first attempt of implmenting asm style box2d engine

This commit is contained in:
logsol 2014-06-15 01:36:02 +02:00
parent ebf167107a
commit cca3a258ba
12 changed files with 12255 additions and 10876 deletions

View file

@ -50,7 +50,9 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
}
GameController.prototype.onLevelLoaded = function() {
console.log("onLevelLoaded updateWorld pre")
this.updateWorld();
console.log("onLevelLoaded updateWorld post")
};
GameController.prototype.onUserJoined = function (user) {
@ -115,20 +117,22 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
getSleeping = getSleeping || false;
var update = {};
var body = this.physicsEngine.world.GetBodyList();
do {
if((getSleeping || body.IsAwake()) && body.GetType() === Box2D.Dynamics.b2Body.b2_dynamicBody) {
var userData = body.GetUserData();
if (userData instanceof GameObject) {
var gameObject = userData;
update[gameObject.uid] = {
p: body.GetPosition(),
p: body.GetPosition().Copy(),
a: body.GetAngle(),
lv: body.GetLinearVelocity(),
av: body.GetAngularVelocity()
lv: body.GetLinearVelocity().Copy(),
av: body.GetAngularVelocity().Copy()
};
if(gameObject instanceof Doll) {
@ -138,6 +142,12 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
}
}
if(Settings.USE_ASM) {
if(body.GetNext() == body) {
break;
}
}
} while (body = body.GetNext());
return update;