mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
worldupdate subbody repositioning - #99
This commit is contained in:
parent
2e01a093fc
commit
e370adf746
2 changed files with 42 additions and 0 deletions
|
|
@ -43,6 +43,30 @@ function (Parent, Settings, Nc) {
|
||||||
}, Settings.RAGDOLL_DESTRUCTION_TIME * 1000);
|
}, Settings.RAGDOLL_DESTRUCTION_TIME * 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RubeDoll.prototype.getUpdateData = function(getSleeping) {
|
||||||
|
var updateData = Parent.prototype.getUpdateData.call(this, getSleeping);
|
||||||
|
|
||||||
|
// if parent is asleep it sends null, to do no update
|
||||||
|
if(!updateData) {
|
||||||
|
return updateData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// adding limb update data
|
||||||
|
var limbUpdateData = {};
|
||||||
|
|
||||||
|
for(var name in this.limbs) {
|
||||||
|
limbUpdateData[name] = {
|
||||||
|
p: this.limbs[name].GetPosition(),
|
||||||
|
a: this.limbs[name].GetAngle(),
|
||||||
|
lv: this.limbs[name].GetLinearVelocity(),
|
||||||
|
av: this.limbs[name].GetAngularVelocity()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
updateData['limbs'] = limbUpdateData;
|
||||||
|
|
||||||
|
return updateData;
|
||||||
|
}
|
||||||
|
|
||||||
RubeDoll.prototype.destroy = function() {
|
RubeDoll.prototype.destroy = function() {
|
||||||
if(this.scheduledForDestruction) {
|
if(this.scheduledForDestruction) {
|
||||||
clearTimeout(this.destructionTimeout);
|
clearTimeout(this.destructionTimeout);
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,24 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, RubeDollJson) {
|
||||||
return this.limbs.head.GetPosition().Copy();
|
return this.limbs.head.GetPosition().Copy();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RubeDoll.prototype.setUpdateData = function(update) {
|
||||||
|
|
||||||
|
Parent.prototype.setUpdateData.call(this, update);
|
||||||
|
|
||||||
|
for(var name in update.limbs) {
|
||||||
|
Assert.number(update.limbs[name].p.x, update.limbs[name].p.y);
|
||||||
|
Assert.number(update.limbs[name].a);
|
||||||
|
Assert.number(update.limbs[name].lv.x, update.limbs[name].lv.y);
|
||||||
|
Assert.number(update.limbs[name].av);
|
||||||
|
|
||||||
|
this.limbs[name].SetAwake(true);
|
||||||
|
this.limbs[name].SetPosition(update.limbs[name].p);
|
||||||
|
this.limbs[name].SetAngle(update.limbs[name].a);
|
||||||
|
this.limbs[name].SetLinearVelocity(update.limbs[name].lv);
|
||||||
|
this.limbs[name].SetAngularVelocity(update.limbs[name].av);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RubeDoll.prototype.destroy = function() {
|
RubeDoll.prototype.destroy = function() {
|
||||||
|
|
||||||
var world = this.body.GetWorld();
|
var world = this.body.GetWorld();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue