Page 1 of 1

Models/Textures & like_ship

Posted: Wed Jan 07, 2009 4:37 pm
by Lestradae
A question to the Devs:

If I create a like_ship tree and make, say, ten ships from one model and textures, does the game keep the model and textures separately in memory ten times or are they kept once and allocated to the ten different ship keys?

I have a suspicion that the game takes those as ten separate textures/models, which would not be good at all.

:?:

L

Re: Models/Textures & like_ship

Posted: Wed Jan 07, 2009 6:11 pm
by JensAyton
Lestradae wrote:
If I create a like_ship tree and make, say, ten ships from one model and textures, does the game keep the model and textures separately in memory ten times or are they kept once and allocated to the ten different ship keys?
Textures are cached by file name and options. In general, that means that the texture will be shared.

In all releases to date, model data is stored once per entity. In 1.73, data will be cached by file name. In principle it should take smoothing into account, but I don’t think it does yet.

No data is cached per ship type, except the actual shipdata.plist and shipyard.plist contents.

?!?

Posted: Wed Jan 07, 2009 11:35 pm
by Lestradae
Hi Ahruman,

I am afraid I still didn't understand the answer to my question :oops:

A practical example:

I have taken the Tiger Mk I and heavily used is_template and like_ship to get a lot of different player and NPC versions out of it.

There are now 17 (!) different versions of Tiger, one palette for the players, and one each for pirates, police, scavengers/miners, traders/sunskimmers etc.

That means that there are now up to 60 <key>TIGERVERSION</key> variants coming from the same original Tiger entry via up to double like_ship'ing. All of those entries, via like_ship, still refer to the same Tiger model and that model's textures.

My question regarding this specific case would be: Will the game now store the same model and that one's textures 60 times over, or will the model and its textures be stored only once and then shared by all 60 Tiger variants?

My suspicion why it might store the models/textures multiple times comes from the observation that after doing this ship variant thing with more than one ship, my game suddenly starts to stutter and lag, something it hasn't been doing for months now.

Could be something entirely unrelated, but thought about excluding this possibility.

Thanks in advance for infos,

L

Re: ?!?

Posted: Thu Jan 08, 2009 9:50 am
by JensAyton
Lestradae wrote:
I am afraid I still didn't understand the answer to my question
Textures are cached by file name and options. (If you don’t know what the options are, you’re using the default ones, which are the same for every texture.) If two ships use the same texture file, only one texture object is created, entirely regardless of whether they’re the same type of ship.

In all releases to date, model data is stored once per entity. If there are two ships in the system, each one will have its own model data in memory, regardless of whether they’re the same type of ship.

In 1.73, data will be cached by file name. In 1.73, if two ships use the same model file, only one set of model data is created, entirely regardless of whether they’re the same type of ship.

There is some overhead to creating more ship types, because the shipdata is bigger. But it doesn’t cause the type of overhead you think you’re seeing signs of. The quickest way to slow the game down by adding more ships is probably to use conditions a lot.

...

Posted: Thu Jan 08, 2009 10:03 am
by Lestradae
Hi Ahruman,

thanks again for the patient explanation, now I got it.
In 1.73, data will be cached by file name. In 1.73, if two ships use the same model file, only one set of model data is created, entirely regardless of whether they’re the same type of ship.
Ah, that's one of those big improvements then which make the game use less resources again? Very good.

With my ship variations, that means that pretty big fleets become possible without lagging if they consist of ships that share the same models/textures. Nice.
There is some overhead to creating more ship types, because the shipdata is bigger. But it doesn’t cause the type of overhead you think you’re seeing signs of. The quickest way to slow the game down by adding more ships is probably to use conditions a lot.
Hm, I use a lot of conditions in the shipyard.plist, but not the shipdata.plist.

Is this conditions thing this mysterious bug in 1.72.1, or is it something more fundamental?

Because if the conditions in shipyard.plist slow the game down, there could be my culprit. Question would still be, why they slow the game down in-flight, with no shipyard to be populated.

Posted: Fri Jan 09, 2009 12:39 am
by JensAyton
Conditions in shipdata.plist slow down ship creation, in part because it takes time to evaluate the conditions and in part because the process of selecting a ship becomes slower once you start removing ships from the set of candidates.¹ Conditions in shipyard.plist are only evaluated when setting up a shipyard.

¹ Geek details: lookup in an immutable weighted-random set is O(log n) (binary search), but lookup in a mutable weighted-random set is linear.