Mutagen-Modding / Mutagen.Bethesda.Analyzers

A project to diagnose and analyze the health of a mod or a load order
GNU General Public License v3.0
14 stars 4 forks source link

Idea: Analyzer to fix large reference errors for a given load order #106

Open Prepubescent-Blastoise opened 2 years ago

Prepubescent-Blastoise commented 2 years ago

A full description of large references as well large references bugs is well documented by Sheson on the Dyndolod 3 webpage: https://dyndolod.info/Help/Large-References

The large reference grid is a feature of SSE/SVR to show a pre-select list of full models outside the loaded exterior cells. The large reference bug occurs when LOD models are not properly unloaded and full models are loaded in which leads to z-Fighting.

Briefly, the bug can occur if: -A Large Reference is flagged as initially disabled -A large reference defined in a master files is overwritten by a plugin that is not flagged ESM. -The base record for a large reference is not STAT or MSST

The most common current approach to fixing these bugs is to flagged all required plugins as ESM, but this can lead to significant amount of work and manual patching as it greatly impacts the load order, and often leads to ESM-flagging all of the plugins.

The idea is to create an analyzer that does the following for a given load order: 1) Identify all large references that are overwritten by non-ESM flagged plugins. 2) Copy those references (and any required dependencies such as new STAT/MSST/Locations/etc. to a new ESM flagged plugin 3) Make copies of all the non-ESM flagged plugins that contain those overwrites. 4) Delete all overwrites in the newly copied plugins. 5) Identify all large references flagged as initially disabled 6) Unflag those large references as initially disabled and change their z position = -30000, as a documented solution per the above Dyndolod page

This approach should allow a user to non-destructively and automatically fix most large reference bugs, and maintain their current working load order. By editing copies of plugins, those plugins can then be placed into a mod in MO2 (or I guess Vortex? I don't use it) to overwrite the original plugins. A suggested approach would be to finalizes a load order. Run this analyzer, then run Texgen/Dyndolod prior to starting a game. It seems unlikely to me that this could fix references where the base record is not STAT or MSST.

Potential problems/areas of concern: -If the Large Reference also references a new STAT/MSST/Location/Texture Set/etc, those would need to be copied as new records to the ESM flagged output in order to prevent needing the original plugin as a master -If the Large Reference also references a location, by copying the location as a new record, all records that reference that location would also need to be patched to use the new location defined in the ESM -There may be issues is there are linked references or enable parents that I haven't thought of.