Skip to content

Persistent Switch/DOF IDs and Export Validation#53

Draft
avan069 wants to merge 10 commits intoBenchmarkSims:mainfrom
avan069:switch-dof-persistence
Draft

Persistent Switch/DOF IDs and Export Validation#53
avan069 wants to merge 10 commits intoBenchmarkSims:mainfrom
avan069:switch-dof-persistence

Conversation

@avan069
Copy link

@avan069 avan069 commented Sep 24, 2025

Summary

Persistent IDs (PIDs)

  • Introduce intrinsic persistent IDs for switches (number / branch) and DOFs (number) to replace fragile list index reference
  • Maintain backward compatibility with list index if PID unset. Scene interpretation and export are still possible without setting PIDs in most cases if a user refuses to cooperate. (See export validation)
  • Provide warnings for unset/out-of-range IDs with suggestion to reload XML (see PR Fix #47, 10, 21: Reference points/alpha sorting, xml reload options, UV map preservation, performance improvements #52 )
  • Add (pop-up) batch/single switch/DOF ID assignment tools to UI. Extend 2-way sync between object selection and UI panel.

Universality

  • Adds new switch/dof number (branch) resolution helpers and implements them throughout codebase to prevent stale references.
  • Introduces "hydration" logic to initialize switch/DOF lists, prioritizing CACHED list saved within .blend file for compatibility. Allows maximal safe chances for user to migrate to PIDs before switch/DOF lists are reloaded from XML.

UI dressing for usability

  • Add UI elements to allow manual assignment of DOF/switch ID via number/branch
  • Display switches with number AND branch in UI (object name, switch_panel list) - circumvents lazy or missing .xml name data

Export Validation

  • Create an extensible system for validating a scene for issues at point of export, extensible for use prior to export
  • export_validation.py - Validation pipeline with ExportValidator performing analysis to detect common issues. Returns ValidationIssue (dataclass) objects containing type classification and list of affected objects for resolution
  • validation_dialogs.py - Dialog operators to guide user through contextual resolution options (eg. execute a batch operation, select issue objects and quit, ignore)

Why it's needed

  • List indices in external XML could shift leading to incorrect switch/DOF export with zero warning
  • Models from legacy plugin versions can now be future-proof
  • Switch/DOF lists are not perfectly dressed, plus the name for a particular animation might be specific to the F-16 and hard to find by name - better to have the ability to manually set number/branch as is possible in 3ds MAX
  • No formal export validation currently exists. Currently, for example, issues related to switch/DOF indexing on export are only provided in console without clarification of the offending object (and most users don't even know the console exists.)

- Fix reference points defaulting to geometric origin of meshes, instead use Blender object Origin.
- Enable alpha-sorting via reference point/object origin

Fix for 47: BenchmarkSims#47
- Reload option for DOF/switch/callback.xml source files added to add-on preferences dialog.
- Clears scene/global context/cache then forces reload, avoids persistent cache blocking xml updates.
- Fix BenchmarkSims#21 - At mesh join, rename active UV layer to "UVMap" if required to prevent data loss
- Improve performance in join loop by batching join operation - approx 10% performance increase in scenes heavy with non-mesh nodes, approx 50% in scenes heavy with mesh nodes (not thoroughly tested for actual performance gains, but it's definitely better :) )
- Introduce persistent properties for DOF and Switch numbers/branches
- Retain backward compatibility for list indices but new method is invariant to xml updates and allows manual switch/dof value editing similar to MAX plugin
- Updates to UI panels: Persistent IDs for DOF, Switch/Branch, and auto assignment options for current/collection/scene to set those properties (as plugin operators.) Displays (Switch:Branch) in both UI panel list and object name to quickly identify branches.
Attempt to strengthen handling of UV maps in join operations, particularly use names to avoid stale reference
Filter box now permits filtering by DOF or switch number. For a switch, appending ":" will show all branches for the preceeding switch number. You can still search by name.

Creates filter_items() methods for both SwitchList and DofList.
@avan069 avan069 force-pushed the switch-dof-persistence branch from 68c1312 to dbc8bc3 Compare September 25, 2025 07:08
@avan069 avan069 changed the title Persistent Switch/DOF IDs and UI Persistent Switch/DOF IDs and Export Validation Sep 26, 2025
- Implement extensible system for validating a scene at point of export (or whenever)
- export_validation.py - Validation pipeline with ExportValidator performing analysis to detect common issues. Returns ValidationIssue (dataclass) objects containing type classification and list of affected objects for resolution
- validation_dialogs.py - Dialog operators to guide user through contextual resolution options (eg. execute a batch operation, select issue objects and quit, ignore)

Still working on UI and edge cases
- Add common/resolve_ids.py with helpers for resolving DOF and Switch persistent IDs
- Replace direct list index access throughout. Refactors dof_editor.py, dof_input_node.py, util.py, and dof_behaviour.py
- Prevent IndexError and stale data
- Hydrate DOF/switch lists, prioritizing scene-cached data over disk XML
- New preferences to control list reload behavior and warnings.
- Updates all usages to prefer persistent IDs, and improves validation/migration dialogs
- Refactor related operators/helpers

Known:
- Still does not entirely guard against switch/dof xml discrepancies if user reloads - some responsibility on user to reload XMLs with "more"/"improved" information
- UIList (dof/switch panel) still display incorrect item if cached list is incomplete - should rely on PID first and deselect the list
@avan069
Copy link
Author

avan069 commented Sep 28, 2025

Significantly improved consistency of usage and hardened against edge cases. Node system still in-work though, evaluating potential effects there. (Should be minimal for now - just switch/dof # resolutions)

In work: incremental UX improvements, validation modes and associated UI, logging scheme and UI, efficiency.

Note for documentation:

  • Explanation of switch/DOF number/branch and export values, UI features
  • Explanation of switch/dof.xml and basic data handling, changes to switch/dof.xml, switch/DOF migration to PID where required
  • Explanation of validation catch cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant