Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cocos/physics-2d/box2d-wasm/physics-contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ export class PhysicsContact implements IPhysics2DContact {
}

init (b2contact: number): void {
const ab = B2.ContactGetFixture(b2contact) as Vec2;
this.colliderA = (getTSObjectFromWASMObjectPtr<B2Shape2D>(B2ObjectType.Fixture, ab.x)).collider;
this.colliderB = (getTSObjectFromWASMObjectPtr<B2Shape2D>(B2ObjectType.Fixture, ab.y)).collider;
const fixtureA = B2.ContactGetFixtureA(b2contact) as number;
const fixtureB = B2.ContactGetFixtureB(b2contact) as number;
this.colliderA = (getTSObjectFromWASMObjectPtr<B2Shape2D>(B2ObjectType.Fixture, fixtureA)).collider;
this.colliderB = (getTSObjectFromWASMObjectPtr<B2Shape2D>(B2ObjectType.Fixture, fixtureB)).collider;
this.disabled = false;
this.disabledOnce = false;
this._impulsePtr = 0;
Expand Down
7 changes: 7 additions & 0 deletions cocos/physics-2d/box2d-wasm/shapes/box-shape-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,11 @@ export class B2BoxShape extends B2Shape2D implements IBoxShape {
B2.PolygonShapeSetAsBoxWithCenterAndAngle(shape, width, height, offsetX, offsetY, 0);
return [shape];
}

destroy (): void {
for (let i = 0; i < this._shapes.length; i++) {
B2.PolygonShapeDelete(this._shapes[i]);
}
super.destroy();
}
}
7 changes: 7 additions & 0 deletions cocos/physics-2d/box2d-wasm/shapes/circle-shape-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ export class B2CircleShape extends B2Shape2D implements ICircleShape {

return [shape];
}

destroy (): void {
for (let i = 0; i < this._shapes.length; i++) {
B2.CircleShapeDelete(this._shapes[i]);
}
super.destroy();
}
}
7 changes: 7 additions & 0 deletions cocos/physics-2d/box2d-wasm/shapes/polygon-shape-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,11 @@ export class B2PolygonShape extends B2Shape2D implements IPolygonShape {

return shapes;
}

destroy (): void {
for (let i = 0; i < this._shapes.length; i++) {
B2.PolygonShapeDelete(this._shapes[i]);
}
super.destroy();
}
}
Loading