Skip to content

fix: mixed filament manual_pattern dependency resolution and delete/merge remap#366

Merged
LuckZAE merged 1 commit into
Snapmaker:feature_mix_filament_smfrom
zhangzhend0ng:feature_mix_filament
May 25, 2026
Merged

fix: mixed filament manual_pattern dependency resolution and delete/merge remap#366
LuckZAE merged 1 commit into
Snapmaker:feature_mix_filament_smfrom
zhangzhend0ng:feature_mix_filament

Conversation

@zhangzhend0ng
Copy link
Copy Markdown
Collaborator

Summary

Fix dependency resolution and ID remapping for mixed filaments during
physical filament deletion and merge operations, with manual_pattern
properly integrated into the dependency chain.

Changes

Dependency resolution priority

  • Unified resolve order: manual_pattern → gradient → component_a/b
  • When manual_pattern is non-empty, skip gradient and pair checks
    (pattern already resolves every token, avoiding false positives)

strtoul safety

  • Add errno-based overflow detection to all strtoul calls

Token bounds checking

  • physical_filament_from_token now validates symbolic "1"/"2" tokens
    against physical filament count

Deletion logic (remove_physical_filament)

  • Traverse manual_pattern tokens to detect entries that depend on the
    deleted physical filament
  • Adjust pattern tokens of surviving entries (decrement those above
    the deleted ID), including bracket notation [12]→[11] and
    comma-separated groups 34,78→23,67
  • Strip stale gradient_component_ids when manual_pattern survives

ID remap (build_filament_id_remap)

  • New deleted_mixed_idx parameter: deleted mixed virtual IDs now
    correctly remap to 0 (NONE) instead of being shifted onto survivors
  • New mixed_filament_depends_on_physical helper for pattern-aware
    dependency detection
  • Merge path correctly zeros out dependents via remap injection

UI fixes

  • Delete filament button now delegates to the unified delete_filament
  • Show/hide delete button and enable/disable add button correctly
    track physical filament count changes
  • Trigger ID remap and UI refresh on mixed filament delete

Tests

  • 50+ new regression tests covering serialization, lifecycle, resolve,
    delete (bracket/group/gradient boundaries), merge, and gradient
    encode/decode

…emap

- manual_pattern now participates in dependency resolution with priority:
  manual_pattern → gradient → pair
- Add errno-based overflow detection for strtoul calls
- Add bounds checking for symbolic tokens "1"/"2" in physical_filament_from_token
- remove_physical_filament now detects and removes entries that depend on
  the deleted physical filament via manual_pattern tokens
- Deleted mixed filament virtual IDs are correctly remapped to 0 (NONE),
  preventing paint from being reassigned to a surviving mixed filament
- build_filament_id_remap accepts deleted_mixed_idx parameter;
  merge path correctly handles dependent mixed entries via remap injection
- UI: properly show/hide delete button and enable/disable add button
  when physical filament count changes
- Add 50+ regression tests covering serialization, resolve, delete,
  merge, gradient, bracket notation, and group boundary scenarios
@LuckZAE LuckZAE merged commit e4abe96 into Snapmaker:feature_mix_filament_sm May 25, 2026
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.

2 participants