mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 01:12:42 +08:00
fix body enabled after add or remove shapes (#6024)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user