Skip to content

Commit

Permalink
Also need to consider changing type back to Animated.
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar committed Nov 18, 2024
1 parent aed2806 commit 51ed427
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions cocos/physics-2d/box2d-wasm/physics-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,15 @@ export class B2PhysicsWorld implements IPhysicsWorld {
}

public _updateBodyType$ (body: B2RigidBody2D): void {
if (!this._animatedBodies.includes(body)) {
return;
}

const animatedBodies = this._animatedBodies;
const comp = body.rigidBody;
if (comp.type !== ERigidBody2DType.Animated) {
js.array.remove(this._animatedBodies, body);
js.array.remove(animatedBodies, body);
} else {
if (animatedBodies.includes(body)) {
return;
}
animatedBodies.push(body);
}
}

Expand Down
12 changes: 7 additions & 5 deletions cocos/physics-2d/box2d/physics-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,15 @@ export class b2PhysicsWorld implements IPhysicsWorld {
}

public _updateBodyType$ (body: b2RigidBody2D): void {
if (!this._animatedBodies.includes(body)) {
return;
}

const animatedBodies = this._animatedBodies;
const comp = body.rigidBody;
if (comp.type !== ERigidBody2DType.Animated) {
js.array.remove(this._animatedBodies, body);
js.array.remove(animatedBodies, body);
} else {
if (animatedBodies.includes(body)) {
return;
}
animatedBodies.push(body);
}
}

Expand Down

0 comments on commit 51ed427

Please sign in to comment.