fix body enabled after add or remove shapes (#6024)

This commit is contained in:
jiaxin.lai
2020-01-04 09:30:14 +08:00
committed by pandamicro
parent 88dac32d85
commit 2fec62b5cf
2 changed files with 4 additions and 10 deletions
+4
View File
@@ -197,12 +197,14 @@ export class AmmoSharedBody {
if (index < 0) {
this.ghostStruct.wrappedShapes.push(v);
v.setCompound(this.ghostCompoundShape);
this.ghostEnabled = true;
}
} else {
const index = this.bodyStruct.wrappedShapes.indexOf(v);
if (index < 0) {
this.bodyStruct.wrappedShapes.push(v);
v.setCompound(this.bodyCompoundShape);
this.bodyEnabled = true;
}
}
}
@@ -213,12 +215,14 @@ export class AmmoSharedBody {
if (index >= 0) {
this.ghostStruct.wrappedShapes.splice(index, 1);
v.setCompound(null);
this.ghostEnabled = false;
}
} else {
const index = this.bodyStruct.wrappedShapes.indexOf(v);
if (index >= 0) {
this.bodyStruct.wrappedShapes.splice(index, 1);
v.setCompound(null);
this.bodyEnabled = false;
}
}
}
-10
View File
@@ -97,11 +97,6 @@ export class AmmoShape implements IBaseShape {
onEnable () {
this._isEnabled = true;
this._sharedBody.addShape(this, this._isTrigger);
if (this._isTrigger) {
this._sharedBody.ghostEnabled = true;
} else {
this._sharedBody.bodyEnabled = true;
}
this.material = this.collider.sharedMaterial!;
}
@@ -109,11 +104,6 @@ export class AmmoShape implements IBaseShape {
onDisable () {
this._isEnabled = false;
this._sharedBody.removeShape(this, this._isTrigger);
if (this._isTrigger) {
this._sharedBody.ghostEnabled = false;
} else {
this._sharedBody.bodyEnabled = false;
}
}
onDestroy () {