[Suggestion] Same-same collisions with var checks

Discussion and feedback on Construct 2

Post » Sat May 11, 2013 12:32 am

Maybe you are right, but I'm not currently aware if C2 does this optimization of not checking already checked pairs in reverse order.

I used to believe it just did two nested loops checking every instance from Family1 Vs every instance of Family2, since the most usual cases of use doesn't involve checking the same instances.

In this case 'Family On Collision with Family' would check X-X, X-Y, X-Z, Y-X, Y-Y, Y-Z, Z-X, Z-Y, Z-Z.

I'm in doubt now about what really happens under the hood.Animmaniac2013-05-11 00:45:05
Scirra Employee
Posts: 704
Reputation: 15,286

Post » Sat May 11, 2013 12:48 am

As I understand it, the way the engine is setup it can't really do a single nested loop for all collisions internally, because the user can setup all kinds of different collision detection wherever they want (even between events/actions that could change the positions of objects) in their event sheets.

EDIT: Ignore this next paragraph, I'm clearly tired as this would very much *not* address the order problem that I just described, aka events which change positions of objects.
(In order to do something like that, it would have to "read-ahead" for all possible collision checking events, aggregate them, filter for the distinct checks and remove duplicates, run the collision detection against this unique set, and finally store this in some kind of temporary Game Loop Cycle CollisionMap which any Collision events would just internally map against.) -- Bla bla bla

EDIT: Resume reading here. :)

Out of curiosity, I just did a profiling test of the two approaches:
Object to Family
Family to Family

Family to Family is about ~1.5-2x times more performant.

Benchmarking Capxcacotigon2013-05-11 01:19:49
Posts: 232
Reputation: 6,089


Return to Construct 2 General

Who is online

Users browsing this forum: WolfB and 13 guests