-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix IPhysicsScene.removeColliderShape
not cleaned up eventMap
#2008
Fix IPhysicsScene.removeColliderShape
not cleaned up eventMap
#2008
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
eventPool.push(event); | ||
} | ||
} | ||
delete this._eventMap[shapeID]; | ||
delete eventMap[shapeID]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write this to save map access performance and strengthen logical rigor
/**
* {@inheritDoc IPhysicsManager.removeColliderShape }
*/
removeColliderShape(colliderShape: LiteColliderShape): void {
const { _eventPool: eventPool, _currentEvents: currentEvents, _eventMap: eventMap } = this;
const { _id: shapeID } = colliderShape;
for (let i = currentEvents.length - 1; i >= 0; i--) {
const event = currentEvents.get(i);
const isShape2 = event.index2 == shapeID;
if (isShape2 || event.index1 == shapeID) {
currentEvents.deleteByIndex(i);
eventPool.push(event);
// If the shape is big index, should clear from the small index shape subMap
isShape2 && (eventMap[event.index1][event.index2] = undefined);
}
}
delete eventMap[shapeID];
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Bad news: @luzhuang |
No description provided.