|
2 registered members (TipmyPip, 1 invisible),
18,758
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: too many entities = sudden unexpected slowdown
[Re: ChrisB]
#32982
09/14/04 02:18
09/14/04 02:18
|
Joined: Oct 2003
Posts: 1,258 Virginia, USA
qwerty823
Senior Developer
|
Senior Developer
Joined: Oct 2003
Posts: 1,258
Virginia, USA
|
Quote:
I noticed an also strange fps drop. On my level all entitys are ent_created. I use a code which calculate every frame a new universal scale (nothing special, only one line). Every entity has an action which updates his own my.scale with the univeral scale every frame (the level looks much bigger with this trick ). But this process kills my fps!!!! It runs nearly smooth without this code (setting the universall scale to 1), but with the calculation its unplayable. The calculation of the scale its not the problem, but the update of entity scales.
So my question: How fast is my.scale_x=value;???? Note: every frame for 500+ entitys
ChrisB
Well, the changing of my.scale_x to something else, should be fast (afterall its just a variable assignment).
Internally (and I'm speculating some here) the engine may know that scale_x changed, and recaclulate a transformation (scaling) matrix and/or adjust the vertices to be drawn directly. This may take some time. If it doesnt internally chache the old value (the previous scale_x), it wont know when its changed, and will compute the transform each frame (which could be expensive).
Personally, I would have a function trigger all this, like so:
Code:
entity* scale_ent; var universal_scale;
function UpdateUniversalScale(new_val); { universal_scale = new_val; scale_ent = ent_next(NULL); while ( scale_ent != NULL ) { if ( scale_ent.skill1 == 1 ) { scale_ent.scale_x = universal_scale; } scale_ent = ent_next(scale_ent); } }
This code assumes that all entities that have there skill1 value set to 1 will use the unviersal scale. Feel free to change the if to only chnage the entities you want to change. Then, in places where you would change the code like so:
universal_scale = new_val;
do this:
UpdateUniversalScale(new_val);
instead.
This should minimize changes that need to be checked for each frame ( a polling technique, best to be avoided ), and turn it in to a notifacation technique.
Never argue with an idiot. They drag you down to their level then beat you with experience
|
|
|
|
|
|