Models/Textures & like_ship

General discussion for players of Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

Models/Textures & like_ship

Post 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
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Models/Textures & like_ship

Post 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.
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

?!?

Post 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
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: ?!?

Post 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.
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

...

Post 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.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post 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.
Post Reply