PDA

View Full Version : Offscreen filtering: pointless



nih
March 5th, 2005, 06:43 PM
I got curious as to if all the hours I spent messing with filtering offscreen objects, testing location then testing bounds, etc were making any difference at all. So I compared them.

The skinny: there seems to be zero improvement for filtering offscreen objects. Flash, quite obviously, already handles this effectively and doesn't waste time drawing anything that won't be visible. This could have gone either way, don't laugh. ;)

Now to qualify the situation: I don't remove movies when they go offscreen. My gut feeling is that adding and removing movies is a bit slower than just leaving them there. All I do is set their _visible attribute to false. I can confirm that doing this does improve the framerate - but only if they're on screen when you do it.

Secondly, none of the objects I used do anything other than a bit of animation. No fancy cpu-hogging code. They're all graphics. Properly removing unnecessary offscreen objects that have an inordinate amount of frame-triggered script in them (or having them not execute if they fail an on-screen test) would obviously help your movie run faster, but this test didn't cover that.

Finally, I considered the impact of just having objects that have a position in the world that is maintained relative to the screen. What if you have a whole forest of trees out there, not drawn but having their parent objects being transformed each frame? In this I can tell you I've filled my movie with hundereds of objects and the effect is negligible. Transforming an empty (or undrawn) object can be considered to be of zero weight to the final result.

So to summarise: from this test I conclude is no need to remove tiles, sprites etc from your movie if they're offscreen.

Has anyone else found this, or the opposite result?

Blackspirit
March 6th, 2005, 04:47 AM
Interesting. I haven't really looked into it. I just assumed that flash will render everything. What computer have you got? Maybe the gains can only be seen on computers of yesteryear

nih
March 6th, 2005, 05:12 AM
Haha trust me, there are ways to make flash use every last drop.

I'm running on an AthlonXP 3200, and the difference can be worth noting. Taking out the object filtering added maybe a couple of frames to the overall speed.

I guess the point is that Flash adequately handles all the offscreen stuff. No need to reinvent the wheel.

Marz
March 8th, 2005, 02:19 PM
Here is something that will make your computer cringe :

object_particles is an example of code that correctly delets the particles or objects
object_particles_2 however, does not.......

If you are wondering about this particle system.. I've been creating this for a looooong time. Actually, I had this particle sstem before bit101 created his.. Earlier versions me and senocular both worked on it.

Marz
March 8th, 2005, 02:20 PM
And here is the bad particles since the upload manager is being a pain in the arse.

Nevermind... Hmm.. Lemme see what is going on with this.

nih
March 8th, 2005, 04:22 PM
Deliberate object overflows - beautiful. :D

Say, what's the upper limit size for a number variable in flash? Incrementing by 10 at 60fps must be unhealthy in the long run. I've been careful to reset any counters I use if they reach their target value.

Marz
March 8th, 2005, 05:30 PM
Well first, I never put things at 60fps. I run everything at 24 to 30 fps... And then increase if need-be.

Upper size limit for a number variable... Thinking off the top of my head.. I can't quite remember the limitations. For some reason these numbers come to mind though...

+2147483647 to -2147483648

That might be off though.. I'm not too sure.. That's the numbers for something.