Skip to content

Commit

Permalink
Improve queueUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
shakiba committed Dec 24, 2024
1 parent 4b06bb3 commit 97bb79e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-glasses-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"planck": patch
---

Improve world.queueUpdate
6 changes: 4 additions & 2 deletions src/dynamics/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class World {
/** @internal */ m_positionIterations: number;
/** @internal */ m_t: number;

/** @internal */ m_step_callback: ((world: World) => unknown)[] = [];
/** @internal */ m_step_callback: ((world: World) => unknown)[];

// TODO
/** @internal */ _listeners: {
Expand Down Expand Up @@ -186,6 +186,8 @@ export class World {
this.m_positionIterations = def.positionIterations;

this.m_t = 0;

this.m_step_callback = [];
}

/** @internal */
Expand Down Expand Up @@ -861,7 +863,7 @@ export class World {
this.m_locked = false;

let callback: (world: World) => unknown;
while(callback = this.m_step_callback.pop()) {
while(callback = this.m_step_callback.shift()) {
callback(this);
}

Expand Down

0 comments on commit 97bb79e

Please sign in to comment.