-
-
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 pull request #735 from anatawa12/finalik
minimum Finalik support
- Loading branch information
Showing
7 changed files
with
120 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections.Generic; | ||
using Anatawa12.AvatarOptimizer.API; | ||
using UnityEngine; | ||
|
||
namespace Anatawa12.AvatarOptimizer.APIInternal.Externals | ||
{ | ||
[ComponentInformationWithGUID("f9ac8d30c6a0d9642a11e5be4c440740", 11500000)] | ||
internal class DynamicBoneInformation : ComponentInformation<Component>, IExternalMarker | ||
{ | ||
protected override void CollectDependency(Component component, ComponentDependencyCollector collector) | ||
{ | ||
collector.MarkHeavyBehaviour(); | ||
|
||
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) | ||
{ | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,51 @@ | ||
using Anatawa12.AvatarOptimizer.API; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Anatawa12.AvatarOptimizer.APIInternal.Externals | ||
{ | ||
// Currently implements ComponentInfo with low information so I assume all references are dependency and | ||
// All transforms will be rotated. | ||
|
||
[ComponentInformationWithGUID("36737232c1e1646399fa0c8cbc087280", 11500000)] // "IKExecutionOrder" | ||
[ComponentInformationWithGUID("bfac4fa329d1f4f23814af71a247c14b", 11500000)] // "VRIK", | ||
[ComponentInformationWithGUID("a70e525c82ce9413fa4d940ad7fcf1db", 11500000)] // "FullBodyBipedIK" | ||
[ComponentInformationWithGUID("4db3c450680fd4c809d5ad90a2f24e5f", 11500000)] // "LimbIK" | ||
[ComponentInformationWithGUID("5013856973b27429d937d256dc082f2e", 11500000)] // "AimIK" | ||
[ComponentInformationWithGUID("6d406d8b892f54ccaa5b0ef4de59944a", 11500000)] // "BipedIK" | ||
[ComponentInformationWithGUID("65ace204533ef4c24ac80f11ef8ee8ea", 11500000)] // "GrounderIK" | ||
[ComponentInformationWithGUID("6c72e1df647af4c0098866e944a04b01", 11500000)] // "GrounderFBBIK" | ||
[ComponentInformationWithGUID("b7bc22c0304fa3d4086a2e8e451894ef", 11500000)] // "GrounderVRIK" | ||
[ComponentInformationWithGUID("9823e47edf1dd40c29dfe0ba019f33a6", 11500000)] // "GrounderQuadruped" | ||
[ComponentInformationWithGUID("e561d2b0d3d2241fd9bc4929a8f64b7f", 11500000)] // "TwistRelaxer" | ||
[ComponentInformationWithGUID("a48af8ef2fd147446af3c65186a1cd9e", 11500000)] // "ShoulderRotator" | ||
[ComponentInformationWithGUID("e6c4fa4d3ae33fb44b29d48945f7a129", 11500000)] // "FBBIKArmBending" | ||
[ComponentInformationWithGUID("ebbd066464934494f896947690872ad4", 11500000)] // "FBBIKHeadEffector" | ||
[ComponentInformationWithGUID("52af154b35b9e48af96507346dc649ba", 11500000)] // "FABRIK" | ||
[ComponentInformationWithGUID("52af154b35b9e48af96507346dc649ba", 11500000)] // "FABRIK" | ||
[ComponentInformationWithGUID("c9a2b10b17d604bb2a4d1bff880fc61a", 11500000)] // "FABRIKChain" | ||
[ComponentInformationWithGUID("6fb82f19cc3ce412892b525300de1141", 11500000)] // "FABRIKRoot" | ||
[ComponentInformationWithGUID("98b9a1a9e9a934b23a7db351dd9ec69e", 11500000)] // "CCDIK" | ||
[ComponentInformationWithGUID("197a3a7b95f0e4ac48f171363db95b5b", 11500000)] // "RotationLimit" | ||
[ComponentInformationWithGUID("484718f2c4ab849829491782b508958a", 11500000)] // "RotationLimitHinge" | ||
[ComponentInformationWithGUID("dae00b1bdc58d499396776ce508a5078", 11500000)] // "RotationLimitPolygonal" | ||
[ComponentInformationWithGUID("2ccb80eac3b2b4909a63c818e38ae6b8", 11500000)] // "RotationLimitSpline" | ||
internal class FinalIKInformation : ComponentInformation<Component>, IExternalMarker | ||
{ | ||
protected override void CollectDependency(Component component, ComponentDependencyCollector collector) | ||
{ | ||
using (var serialized = new SerializedObject(component)) | ||
foreach (var property in serialized.ObjectReferenceProperties()) | ||
if (property.objectReferenceValue is Component c) | ||
collector.AddDependency(c); | ||
} | ||
|
||
protected override void CollectMutations(Component component, ComponentMutationsCollector collector) | ||
{ | ||
using (var serialized = new SerializedObject(component)) | ||
foreach (var property in serialized.ObjectReferenceProperties()) | ||
if (property.objectReferenceValue is Transform t) | ||
collector.TransformRotation(t); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.