Skip to content

Commit

Permalink
Merge pull request #736 from anatawa12/imposters-and-test-components
Browse files Browse the repository at this point in the history
Imposters and test components
  • Loading branch information
anatawa12 authored Nov 21, 2023
2 parents c779bc2 + a72b95c commit aff101e
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- Some missing components warnings `#736`
- warning for `ONSPAudioSource`, `VRCImpostorSettings`, and `RectTransform` are fixed

### Security

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ The format is based on [Keep a Changelog].
- bounds can be changed in apply on play if updateWhenOffscreen is true `#697`
- Compatibility with transform moving plugins `#715`
- Remove Mesh in Box was not working well with [FloorAdjuster]
- Some missing components warnings `#736`
- warning for `ONSPAudioSource`, `VRCImpostorSettings`, and `RectTransform` are fixed

[FloorAdjuster]: https://github.com/Narazaka/FloorAdjuster
### Security
Expand Down
4 changes: 3 additions & 1 deletion Editor/APIInternal/ComponentInfos.FinalIK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ namespace Anatawa12.AvatarOptimizer.APIInternal.Externals
[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"

// not listed but allowed with inheritance
[ComponentInformationWithGUID("45281828b4c9247558c7c695124d6877", 11500000)] // "RotationLimitAngle"
internal class FinalIKInformation : ComponentInformation<Component>, IExternalMarker
{
protected override void CollectDependency(Component component, ComponentDependencyCollector collector)
Expand Down
15 changes: 15 additions & 0 deletions Editor/APIInternal/ComponentInfos.VRCSDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Anatawa12.AvatarOptimizer.APIInternal.VRCSDK
[ComponentInformation(typeof(PipelineManager))]
[ComponentInformation(typeof(VRCSpatialAudioSource))]
[ComponentInformation(typeof(VRC_SpatialAudioSource))]
[ComponentInformation(typeof(ONSPAudioSource))]
// nadena.dev.ndmf.VRChat.ContextHolder with reflection
internal class EntrypointComponentInformation : ComponentInformation<Component>
{
Expand Down Expand Up @@ -341,5 +342,19 @@ protected override void CollectDependency(ContactBase component, ComponentDepend
collector.AddDependency(component.rootTransform);
}
}

[ComponentInformation(typeof(VRCImpostorSettings))]
internal class VRCImpostorSettingsInformation : ComponentInformation<VRCImpostorSettings>
{
protected override void CollectDependency(VRCImpostorSettings component, ComponentDependencyCollector collector)
{
foreach (var transform in component.transformsToIgnore)
collector.AddDependency(transform);
foreach (var transform in component.reparentHere)
collector.AddDependency(transform);
foreach (var transform in component.extraChildTransforms)
collector.AddDependency(transform);
}
}
}
#endif
1 change: 1 addition & 0 deletions Editor/APIInternal/ComponentInfos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected override void CollectDependency(Component component, ComponentDependen
}

[ComponentInformation(typeof(Transform))]
[ComponentInformation(typeof(RectTransform))]
internal class TransformInformation : ComponentInformation<Transform>
{
protected override void CollectDependency(Transform component, ComponentDependencyCollector collector)
Expand Down
1 change: 1 addition & 0 deletions Editor/com.anatawa12.avatar-optimizer.editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"nadena.dev.ndmf",
"nadena.dev.ndmf.runtime",
"com.anatawa12.avatar-optimizer.api.editor",
"VRC.SDKBase",
"UniHumanoid",
"VRM",
"VRM10"
Expand Down
111 changes: 111 additions & 0 deletions Test~/ComponentWhitelistTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Anatawa12.AvatarOptimizer.APIInternal;
using NUnit.Framework;
using UnityEngine;
using VRC.SDKBase.Validation;
using BaseAvatarValidation = VRC.SDKBase.Validation.AvatarValidation;

namespace Anatawa12.AvatarOptimizer.Test
{
public class ComponentWhitelistTest
{
public static IEnumerable<string> WhitelistedTypes =>
BaseAvatarValidation.ComponentTypeWhiteListCommon
.Concat(BaseAvatarValidation.ComponentTypeWhiteListSdk3);

[Test]
public void TestNameList()
{
Assert.That(WhitelistedTypes, Is.EquivalentTo(KnownWhitelist));
}

[TestCaseSource(nameof(KnownTypes))]
public void TestEachType(Type type)
{
Assert.That(ComponentInfoRegistry.TryGetInformation(type, out _), Is.True);
}

public static IEnumerable<Type> KnownTypes()
{
return ValidationUtils.WhitelistedTypes("avatar-sdk3", WhitelistedTypes)
.Where(x => typeof(Component).IsAssignableFrom(x));
}

private static string[] KnownWhitelist =
{
// common whitelist
"DynamicBone",
"DynamicBoneCollider",
"RootMotion.FinalIK.IKExecutionOrder",
"RootMotion.FinalIK.VRIK",
"RootMotion.FinalIK.FullBodyBipedIK",
"RootMotion.FinalIK.LimbIK",
"RootMotion.FinalIK.AimIK",
"RootMotion.FinalIK.BipedIK",
"RootMotion.FinalIK.GrounderIK",
"RootMotion.FinalIK.GrounderFBBIK",
"RootMotion.FinalIK.GrounderVRIK",
"RootMotion.FinalIK.GrounderQuadruped",
"RootMotion.FinalIK.TwistRelaxer",
"RootMotion.FinalIK.ShoulderRotator",
"RootMotion.FinalIK.FBBIKArmBending",
"RootMotion.FinalIK.FBBIKHeadEffector",
"RootMotion.FinalIK.FABRIK",
"RootMotion.FinalIK.FABRIKChain",
"RootMotion.FinalIK.FABRIKRoot",
"RootMotion.FinalIK.CCDIK",
"RootMotion.FinalIK.RotationLimit",
"RootMotion.FinalIK.RotationLimitHinge",
"RootMotion.FinalIK.RotationLimitPolygonal",
"RootMotion.FinalIK.RotationLimitSpline",
"UnityEngine.Cloth",
"UnityEngine.Light",
"UnityEngine.BoxCollider",
"UnityEngine.SphereCollider",
"UnityEngine.CapsuleCollider",
"UnityEngine.Rigidbody",
"UnityEngine.Joint",
"UnityEngine.Animations.AimConstraint",
"UnityEngine.Animations.LookAtConstraint",
"UnityEngine.Animations.ParentConstraint",
"UnityEngine.Animations.PositionConstraint",
"UnityEngine.Animations.RotationConstraint",
"UnityEngine.Animations.ScaleConstraint",
"UnityEngine.Camera",
"UnityEngine.AudioSource",
"ONSPAudioSource",
"VRC.Core.PipelineSaver",
"VRC.Core.PipelineManager",
"UnityEngine.Transform",
"UnityEngine.Animator",
"UnityEngine.SkinnedMeshRenderer",
"LimbIK", // VRCSDK's LimbIK
"LoadingAvatarTextureAnimation",
"UnityEngine.MeshFilter",
"UnityEngine.MeshRenderer",
"UnityEngine.Animation",
"UnityEngine.ParticleSystem",
"UnityEngine.ParticleSystemRenderer",
"UnityEngine.TrailRenderer",
"UnityEngine.FlareLayer",
"UnityEngine.GUILayer",
"UnityEngine.LineRenderer",
"RealisticEyeMovements.EyeAndHeadAnimator",
"RealisticEyeMovements.LookTargetController",

// SDK3 whitelist
"VRC.SDK3.Avatars.Components.VRCSpatialAudioSource",
"VRC.SDK3.VRCTestMarker",
"VRC.SDK3.Avatars.Components.VRCAvatarDescriptor",
"VRC.SDK3.Avatars.Components.VRCStation",
"VRC.SDK3.Avatars.Components.VRCImpostorSettings",
"VRC.SDK3.Avatars.Components.VRCImpostorEnvironment",
"VRC.SDK3.Dynamics.PhysBone.Components.VRCPhysBone",
"VRC.SDK3.Dynamics.PhysBone.Components.VRCPhysBoneCollider",
"VRC.SDK3.Dynamics.Contact.Components.VRCContactSender",
"VRC.SDK3.Dynamics.Contact.Components.VRCContactReceiver",
};
}
}
3 changes: 3 additions & 0 deletions Test~/ComponentWhitelistTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Test~/com.anatawa12.avatar-optimizer.test.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"com.anatawa12.avatar-optimizer.internal.prefab-safe-set",
"com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor",
"com.anatawa12.avatar-optimizer.internal.error-reporter.editor",
"com.anatawa12.avatar-optimizer.api.editor",
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"nadena.dev.ndmf"
Expand Down

0 comments on commit aff101e

Please sign in to comment.