Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit 80f8dfc

Browse files
committed
Merge branch 'dev' of https://github.com/XRFoundation/XREngine into dev
2 parents 11af1e4 + b9d978c commit 80f8dfc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/engine/src/ecs/PriorityQueue.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DeepReadonly } from '@xrengine/common/src/DeepReadonly'
22

33
import { Entity } from './classes/Entity'
4+
import { entityExists } from './functions/EntityFunctions'
45

56
export const createPriorityQueue = (args: { accumulationBudget: number }) => {
67
const accumulatingPriorities = new Map<
@@ -32,8 +33,9 @@ export const createPriorityQueue = (args: { accumulationBudget: number }) => {
3233
for (const [entity, item] of accumulatingPriorities) {
3334
item.normalizedPriority += (item.accumulatedPriority * queue.accumulationBudget) / totalAccumulation
3435
item.accumulatedPriority = 0
35-
if (item.normalizedPriority >= 1) {
36-
priorityEntites.add(entity)
36+
const exists = entityExists(entity)
37+
if (item.normalizedPriority >= 1 || !exists) {
38+
if (exists) priorityEntites.add(entity)
3739
queue.removeEntity(entity)
3840
}
3941
}

0 commit comments

Comments
 (0)