Ok, weird programming question:

You haev like 10-20 sprites on screen and 100-200 bullets.

Which collision is faster to iterate: iterating bullets from entities or entities from bullets?

@sos with no other info available I would say it's hard to say one approach would be faster than another🤔

I mean, given you need to run one AABB for each pair, the number of checks will be the same

The overhead might be slightly lower if the outer loop is the one that runs less times, as the inner loop will have to be set up less... but hardly will make a difference I suppose...

Follow

@sverx @sos It's pretty likely that one may be faster than the other, but which one would it be depends on data structures used and the architecture of the machine it runs on (most notably its caches).

You'd probably have to go orders of magnitude higher with the number of sprites & bullets for it to make any practical difference though 😂

Sign in to participate in the conversation
Librem Social

Librem Social is an opt-in public network. Messages are shared under Creative Commons BY-SA 4.0 license terms. Policy.

Stay safe. Please abide by our code of conduct.

(Source code)

image/svg+xml Librem Chat image/svg+xml