Polygon: whats better?

Discussion and feedback on Construct 2

Post » Wed Jan 25, 2012 1:25 am

What is more cpu-intensive: 100 objects with 4 polygon points, or one object with 400 points?
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Wed Jan 25, 2012 1:26 am

It depends on what you are doing with the objects.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Wed Jan 25, 2012 1:31 am

Just simple non-physics collision between the player and the objects
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Wed Jan 25, 2012 1:44 am

Presumably the 100 objects, but again it depends on what they are doing, before and after the collisions.
Likewise if you have the one sprite with all the poly's moving around, that could add up as well.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Wed Jan 25, 2012 1:56 am

The object is static, but the layout is rotating
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Wed Jan 25, 2012 2:42 am

I guess that if it's static you are probably planning to use it as ground/walls, so in this case I think it would be better to use invisible tilled-backgrounds as collision. Lots of objects with bounding-box collision are probably faster than one giant collision polygon.
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Wed Jan 25, 2012 3:00 am

It's for my rotary compo game, the level is made on photoshop, and is round. Here's a picture of a level:

Left: the level
Right: what I'm doing now

I have to create a sprite for each shape, import into construct, set the polygons and cover the level with them.
So, right now I have 32 collision objects on a level (12 unique, the rest are instances) and each has 4~8 vertices
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Wed Jan 25, 2012 4:55 am

Consider making the level off-screen and not wrapped around, which handles all the physics. Therfore it would only require one rectangular sprite for all objects.

Then, take the coordinates of the object your simulating, and bend that around a central point, giving the appearance shown, in a dummy level on-screen.
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Post » Wed Jan 25, 2012 5:17 am

[QUOTE=cow_trix] Consider making the level off-screen and not wrapped around, which handles all the physics.[/QUOTE]
There are no physics in my game

And, is there such way to bend objects?
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Wed Jan 25, 2012 4:41 pm

[QUOTE=7Soul] What is more cpu-intensive: 100 objects with 4 polygon points, or one object with 400 points?[/QUOTE]
It's probably more CPU intensive to use one object with 400 points. It's best to use more objects with fewer collision points.

If an object is overlapping an object with 400 collision points, it will probably check all 400 collision points in that object. If it is overlapping an object with 4 collision points, it will check just those 4 collision points (100 times less!) and it will skip checking any of the other objects.

Of course using more objects has its own performance impact, but using lots of collision points isn't very efficient in the engine at the moment, so it's probably better to avoid that. This can probably be optimised in future, but this is how it is at the moment.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 15 guests