lance-gg / lance

Multiplayer game server based on Node.JS
https://lance-gg.github.io/
Apache License 2.0
1.58k stars 168 forks source link

fix the code about Memory leak on BruteCollisionDetection #66

Closed cshyeon closed 6 years ago

cshyeon commented 6 years ago

Hi, I added 'collisionStay' event to BruteCollisionDetection.js This will help to identify whether or not to remain in collision.

namel commented 6 years ago

Is it possible to do this a little different? I assume the list of collisions is very small. So at the beginning of detect(), simply go over all the collisions, and if either id1 or id2 are not in Object.keys(objects) then delete that collision.

OpherV commented 6 years ago

I feel as if this might not be an ideal architecture. Emitting so many collisionStay events will actually degrade performance with the overhead involved in emitting them for every collision on every game step. The majority of the time you're not actually using these, so it makes more sense to actively query only the colliding pairs you do care about.

cshyeon commented 6 years ago

Thanks, code about Memory leak was modified according to namel's opinion and removed the "collisionStay" event temporarily. Also, PR title was edited.

namel commented 6 years ago

Thanks !