-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into write-tests
- Loading branch information
Showing
32 changed files
with
813 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System.Collections.Generic; | ||
using Anatawa12.AvatarOptimizer.API; | ||
using UnityEngine; | ||
|
||
namespace Anatawa12.AvatarOptimizer.APIInternal.Externals | ||
{ | ||
/// <summary> | ||
/// Marker interface for fallback ComponentInformation(s) for external library. | ||
/// | ||
/// Thanks to this interface, upstream author can register those component types without causing duplication error | ||
/// and override information by Avatar Optimizer. | ||
/// </summary> | ||
internal interface IExternalMarker | ||
{ | ||
} | ||
|
||
#region Dynamic Bones | ||
|
||
[ComponentInformationWithGUID("f9ac8d30c6a0d9642a11e5be4c440740", 11500000)] | ||
internal class DynamicBoneInformation : ComponentInformation<Component>, IExternalMarker | ||
{ | ||
protected override void CollectDependency(Component component, ComponentDependencyCollector collector) | ||
{ | ||
collector.MarkBehaviour(); | ||
|
||
foreach (var transform in GetAffectedTransforms(component)) | ||
{ | ||
collector.AddDependency(transform, component) | ||
.EvenIfDependantDisabled() | ||
.OnlyIfTargetCanBeEnable(); | ||
collector.AddDependency(transform); | ||
} | ||
|
||
foreach (var collider in (IReadOnlyList<MonoBehaviour>)((dynamic)component).m_Colliders) | ||
{ | ||
// DynamicBone ignores enabled/disabled of Collider Component AFAIK | ||
collector.AddDependency(collider); | ||
} | ||
} | ||
|
||
protected override void CollectMutations(Component component, ComponentMutationsCollector collector) | ||
{ | ||
foreach (var transform in GetAffectedTransforms(component)) | ||
collector.TransformRotation(transform); | ||
} | ||
|
||
private static IEnumerable<Transform> GetAffectedTransforms(dynamic dynamicBone) | ||
{ | ||
var ignores = new HashSet<Transform>(dynamicBone.m_Exclusions); | ||
var queue = new Queue<Transform>(); | ||
Transform root = dynamicBone.m_Root; | ||
queue.Enqueue(root ? root : (Transform)dynamicBone.transform); | ||
|
||
while (queue.Count != 0) | ||
{ | ||
var transform = queue.Dequeue(); | ||
yield return transform; | ||
|
||
foreach (var child in transform.DirectChildrenEnumerable()) | ||
if (!ignores.Contains(child)) | ||
queue.Enqueue(child); | ||
} | ||
} | ||
} | ||
|
||
[ComponentInformationWithGUID("baedd976e12657241bf7ff2d1c685342", 11500000)] | ||
internal class DynamicBoneColliderInformation : ComponentInformation<Component>, IExternalMarker | ||
{ | ||
protected override void CollectDependency(Component component, ComponentDependencyCollector collector) | ||
{ | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Satania's KiseteneEx Components | ||
|
||
[ComponentInformationWithGUID("e78466b6bcd24e5409dca557eb81d45b", 11500000)] // KiseteneComponent | ||
[ComponentInformationWithGUID("7f9c3fe1cfb9d1843a9dc7da26352ce2", 11500000)] // FlyAvatarSetupTool | ||
[ComponentInformationWithGUID("95f6e1368d803614f8a351322ab09bac", 11500000)] // BlendShapeOverrider | ||
internal class SataniaKiseteneExComponents : ComponentInformation<Component>, IExternalMarker | ||
{ | ||
protected override void CollectDependency(Component component, ComponentDependencyCollector collector) | ||
{ | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
|
||
#region VRCQuestTools | ||
|
||
[ComponentInformationWithGUID("f055e14e1beba894ea68aedffde8ada6", 11500000)] // VertexColorRemover | ||
internal class VRCQuestToolsComponents : ComponentInformation<Component>, IExternalMarker | ||
{ | ||
protected override void CollectDependency(Component component, ComponentDependencyCollector collector) | ||
{ | ||
} | ||
} | ||
|
||
#endregion | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.