Skip to content

Commit

Permalink
Merge pull request #857 from anatawa12/fix-constraint-broken-with-aut…
Browse files Browse the repository at this point in the history
…o-activeness

fix: nested constraint may be broken
  • Loading branch information
anatawa12 authored Jan 27, 2024
2 parents 87db35b + 845fcf1 commit b885831
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- Nested Constraint can be broken with Trace and Optimize `#857`

### Security

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog].
- Added workaround for `Array index (n) is out of bounds (size=m)` error
- Humanoid Bones may be removed by Trace and Optimize `#831`
- Add `license`, `documentationUrl`, and `changelogUrl` to package.json `#851`
- Nested Constraint can be broken with Trace and Optimize `#857`

### Security

Expand Down
10 changes: 9 additions & 1 deletion Editor/APIInternal/ComponentInfos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,15 @@ protected override void CollectDependency(T component, ComponentDependencyCollec
.EvenIfDependantDisabled();
for (var i = 0; i < component.sourceCount; i++)
collector.AddDependency(component.GetSource(i).sourceTransform);
collector.MarkHeavyBehaviour();
var isNestedConstraint =
component.GetComponentsInChildren<IConstraint>() != null &&
component.GetComponentsInParent<IConstraint>() != null;
// for nested constraint, our optimizer may breaks the constraint
// https://github.com/anatawa12/AvatarOptimizer/issues/856
if (isNestedConstraint)
collector.MarkBehaviour();
else
collector.MarkHeavyBehaviour();
}
}

Expand Down

0 comments on commit b885831

Please sign in to comment.