Culling?

For questions about using Classic.

Post » Sun Oct 31, 2010 12:18 pm

Is it possible to do some sort of manual offscreen culling for sprites? I've tried a bunch of things and it's not really working.
B
2
G
2
Posts: 19
Reputation: 688

Post » Sun Oct 31, 2010 2:38 pm

Construct already does that automatically. Why would you want to do it manually?
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Oct 31, 2010 10:38 pm

Well It didn't seem like it had culling to me because I have a game with 50000+ sprites in the area, I added a machine gun, and whenever I shoot it it starts to lag. I flew out so that there were no objects on the screen and it didn't help. So I wasn't sure whether there's culling or not. When I made it so there were only around 10000 objects in the area it was fine.
B
2
G
2
Posts: 19
Reputation: 688

Post » Sun Oct 31, 2010 10:53 pm

50,000 sprites is a lot. Seriously, a lot. My computer can only manage 100,000 invisible or offscreen sprites total without any code or behaviors at all before it dips below vsync. It isn't your GPU getting slammed, it's the CPU. An instance of an object requires some CPU time, even with no code. If you do any sort of checking on that many sprites, your game's framerate is going to take a massive nosedive.

If you want tons of objects about (like bullet casings or tiles or something) I suggest instead saving their locations and any relevant info to an array and deleting them when they're offscreen, then recreating them when they would be onscreen again.

More info in this thread: viewtopic.php?f=3&t=7547

Edit: You're probably doing collision checks - if you set the offscreen sprites' collision mode to 'none' that might help somewhat, but it's still a lot of checking to do.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Oct 31, 2010 11:17 pm

I agree. My CPU usage goes up to about 50% when I'm running the game. I was surprised it even worked with that many. I could easily use half as many/twice as big sprites I wanted to make the terrain destroyable when a bullet hits one of the sprites. And that's exactly what I meant in my first post with deleting objects offscreen and re-creating them and things like that. Thanks, and another thanks for the quick reply. I'll try this out.
B
2
G
2
Posts: 19
Reputation: 688

Post » Thu Nov 11, 2010 3:15 am

What is slowing you down is not graphics, it's collision detection.
Each bullet gets tested aganist each object.
Culling won't help you there... try disabling collision and see if it goes faster (remove solid attributes from both objects, if that's what you're using).
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests