Skip to content

Commit

Permalink
Merge pull request #1367 from anatawa12/exclusions-may-removed-in-pro…
Browse files Browse the repository at this point in the history
…cess-of-avatar-optimizer

fix: Errors if objects removed by some component is listed on exclusions of Trace and Optimize
  • Loading branch information
anatawa12 authored Dec 8, 2024
2 parents 5df9b79 + a4ae0f3 commit e1ecba5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog].
### Fixed
- Errors with models with UV at very edge `#1363`
- Errors if exactly same AnimatorController is specified for multiple playable layers `#1366`
- Errors if objects removed by some component is listed on exclusions of Trace and Optimize `#1367`

### Security

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog].
### Fixed
- Errors with models with UV at very edge `#1363`
- Errors if exactly same AnimatorController is specified for multiple playable layers `#1366`
- Errors if objects removed by some component is listed on exclusions of Trace and Optimize `#1367`

### Security

Expand Down
12 changes: 7 additions & 5 deletions Editor/Processors/TraceAndOptimize/FindUnusedObjectsProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void MarkRecursively()
internal readonly struct FindUnusedObjectsProcessor
{
private readonly BuildContext _context;
private readonly HashSet<GameObject> _exclusions;
private readonly HashSet<GameObject?> _exclusions;
private readonly bool _preserveEndBone;
private readonly bool _noConfigureMergeBone;
private readonly bool _noActivenessAnimation;
Expand Down Expand Up @@ -248,8 +248,9 @@ private void Mark(GCComponentInfoHolder componentInfos)
var markContext = new MarkObjectContext(componentInfos, _context.AvatarRootTransform, GetDependantMap);

foreach (var gameObject in _exclusions)
foreach (var component in gameObject.GetComponents<Component>())
markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal);
if (gameObject != null)
foreach (var component in gameObject.GetComponents<Component>())
markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal);

markContext.MarkRecursively();
}
Expand Down Expand Up @@ -308,8 +309,9 @@ private void MarkDependant(GCComponentInfoHolder componentInfos)
var markContext = new MarkObjectContext(componentInfos, _context.AvatarRootTransform, GetDependantMap);

foreach (var gameObject in _exclusions)
foreach (var component in gameObject.GetComponents<Component>())
markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal);
if (gameObject != null)
foreach (var component in gameObject.GetComponents<Component>())
markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal);

markContext.MarkRecursively();
}
Expand Down
4 changes: 2 additions & 2 deletions Internal/TraceAndOptimizeBase/TraceAndOptimizeProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class TraceAndOptimizeState
public bool MmdWorldCompatibility = true;

public bool PreserveEndBone;
public HashSet<GameObject> Exclusions = new HashSet<GameObject>();
public HashSet<GameObject?> Exclusions = new();
public bool GCDebug;
public bool NoConfigureMergeBone;
public bool NoActivenessAnimation;
Expand Down Expand Up @@ -56,7 +56,7 @@ internal void Initialize(TraceAndOptimize config)

PreserveEndBone = config.preserveEndBone;

Exclusions = new HashSet<GameObject>(config.debugOptions.exclusions);
Exclusions = new HashSet<GameObject?>(config.debugOptions.exclusions);
GCDebug = config.debugOptions.gcDebug;
NoConfigureMergeBone = config.debugOptions.noConfigureMergeBone;
NoActivenessAnimation = config.debugOptions.noActivenessAnimation;
Expand Down
2 changes: 1 addition & 1 deletion Runtime/TraceAndOptimize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal TraceAndOptimize()
internal struct DebugOptions
{
[Tooltip("Exclude some GameObjects from Trace and Optimize")]
public GameObject[] exclusions;
public GameObject?[] exclusions;
[Tooltip("Add GC Debug Components instead of setting GC components")]
[ToggleLeft]
public bool gcDebug;
Expand Down

0 comments on commit e1ecba5

Please sign in to comment.