Skip to content

Optimize UI model instance - #7246

Merged
BMagnu merged 2 commits into
scp-fs2open:masterfrom
MjnMixael:optimize_ui_model_instance
May 24, 2026
Merged

Optimize UI model instance#7246
BMagnu merged 2 commits into
scp-fs2open:masterfrom
MjnMixael:optimize_ui_model_instance

Conversation

@MjnMixael

@MjnMixael MjnMixael commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Addresses an issue that came up while reviewing #7225 (Note that this PR branches from that PR, so that one should be merged first) where we really shouldn't be creating instances for UI models every frame.

Here we use some of the model details to create a cache of instances for the UI. Each frame we check for stale instances and clear them as well as clearing all instances between game states. With this framework, the call sites can lazy load model instances as needed and the engine takes care of keeping things tidy. This is especially useful for the Lua side where any number of models can be rendered and we don't want to have to rely on the script to remember to clean up after itself.

Be aware that the code for using destroyed subsystems as part of the instance key is setting up for supporting #7218 . Additionally the tristatebool return type will allow for that code path to skip some model setup each frame if it returns true.

Also adds model instance support for 3D icons and Fixes #7054

@MjnMixael
MjnMixael force-pushed the optimize_ui_model_instance branch from 4d94863 to 0163107 Compare February 24, 2026 17:29
@wookieejedi wookieejedi added the cleanup A modification or rewrite of code to make it more understandable or easier to maintain. label Feb 24, 2026
@MjnMixael
MjnMixael force-pushed the optimize_ui_model_instance branch 2 times, most recently from a3948d0 to e9d13a0 Compare March 1, 2026 14:32
@wookieejedi wookieejedi added this to the Release 26.0 milestone Mar 14, 2026
@MjnMixael
MjnMixael force-pushed the optimize_ui_model_instance branch from 7c94c28 to c420993 Compare March 16, 2026 03:32
@MjnMixael
MjnMixael force-pushed the optimize_ui_model_instance branch from c420993 to 3da71d1 Compare March 24, 2026 17:34
@MjnMixael
MjnMixael force-pushed the optimize_ui_model_instance branch from 7081c52 to de8c573 Compare April 10, 2026 16:33
@wookieejedi

Copy link
Copy Markdown
Member

I'll defer to @BMagnu for this one

@MjnMixael
MjnMixael force-pushed the optimize_ui_model_instance branch from de8c573 to ea8eab8 Compare April 20, 2026 00:52

@BMagnu BMagnu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a touch wary of using timestamps instead of number of frames unused, but I guess it's fine. It'll be good enough to prevent frequent reinitialization of the model instance every frame when used through scripting

@MjnMixael
MjnMixael force-pushed the optimize_ui_model_instance branch from ea8eab8 to 7a8fdde Compare May 10, 2026 04:02
@MjnMixael

Copy link
Copy Markdown
Contributor Author

I'm a touch wary of using timestamps instead of number of frames unused, but I guess it's fine. It'll be good enough to prevent frequent reinitialization of the model instance every frame when used through scripting

Changing this to frames was actually trivial. So there we go.

@BMagnu
BMagnu merged commit 85f00be into scp-fs2open:master May 24, 2026
20 checks passed
@MjnMixael
MjnMixael deleted the optimize_ui_model_instance branch May 24, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup A modification or rewrite of code to make it more understandable or easier to maintain.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show model animations in ship selection screen

3 participants