Game Development Community

RTS OnRender iteration performances

by Novack · in RTS Starter Kit · 01/16/2008 (5:30 am) · 2 replies

People I have a good one.

I want to render a custom draw (an extra bar) on some given sceneObjects, independently if they are selected or not, so I cannot use the object selection iterators.

What option would have better performance:

1) To have a simset where I mantain a list of objects in which I want to render the draw, and then iterate over that simset (and render the draw on all the objects on it)

or

2) To use a flag-field and then iterate over All the sceneObjects, looking for the flag status to render the draw (or not)


The draw (bar) settings are ghosted, so in both cases I would need to packUpdate a flag-field anyway, the only difference will ocurr on unpacking it: I could just read it, or, also include that given object on a simset.

So I guess the real question is: it is justified by a performance gain the existance of such simset? would be any real difference?

Hope anybody be overhere to help me on this dilemma :)

#1
01/16/2008 (11:47 am)
Hey Novack,

well personally I would do whichever way is easiest to implement, for something like that. The performance difference just isn't going to be that big. Even if you're running at a high frame rate like 100 FPS, the time you've got between redraws will be at least 10 milliseconds. The time it takes to iterate over 1000 or so SceneObjects and test a boolean flag will be a tiny fraction of that.

I usually find Donald Knuth's famous slogan, "Premature optimization is the root of all evil", to be true. So in questionable cases, I always give myself permission to be lazy and do whatever way's easiest to implement, unless it's just fun to code up the optimization!

But I always figure my coding is in more danger of not getting finished, than it's in danger from some slightly un-optimized code. So I usually make the coding easier on me.
#2
01/16/2008 (12:01 pm)
Excelent!

Good reading, and I think you are quite right pal, thanks.