You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a case where I am using this on the server side and I need to loop through all players, and, on each players loop iteration, I would do a tree retrieve with player object and then insert the player etc etc for up to 500 players. In your opinion is this the right approach? Each player has the x, y, width, and height, and unique id properties.
Pseudo-code: tree.clear() tree.insert(allBullets) for each player in players { player.update; // update this player position var objs = tree.retrieve(player) // first retrieve against this player // do coll checks with objs if any are found
tree.insert(player) // do this after so this player won't be in his own retrieve }
This way we only loop through the players once and each one is checked against all bullets and the previous players already inserted so all player to player checks are covered.
The text was updated successfully, but these errors were encountered:
This way we only loop through the players once and each one is checked against all bullets and the previous players already inserted so all player to player checks are covered.
From my understanding this wont check all players against each other but only - like you say, too - against previously inserted. So e.g. the first loop execution won't have any player in the Quadtree. I'm afraid you need two loops, one for inserting and one retrieving, and test the retrieved IDs to prevent self-collision.
Haven't thought about many-to-many yet and I cannot say if this is the best method. Let me know if this works for you or not.
I have a case where I am using this on the server side and I need to loop through all players, and, on each players loop iteration, I would do a tree retrieve with player object and then insert the player etc etc for up to 500 players. In your opinion is this the right approach? Each player has the x, y, width, and height, and unique id properties.
Pseudo-code:
tree.clear()
tree.insert(allBullets)
for each player in players {
player.update; // update this player position
var objs = tree.retrieve(player) // first retrieve against this player
// do coll checks with objs if any are found
tree.insert(player) // do this after so this player won't be in his own retrieve
}
This way we only loop through the players once and each one is checked against all bullets and the previous players already inserted so all player to player checks are covered.
The text was updated successfully, but these errors were encountered: