From b75accf9101f8ec40e55c3378de6340d4a8d0845 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 26 Nov 2024 21:56:17 +0900 Subject: [PATCH 01/44] script gray --- .../VRM10SpringBoneColliderEditor.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs index 2ad132ac9..edb2958be 100644 --- a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs @@ -1,6 +1,7 @@ using UnityEditor; using UnityEngine; + namespace UniVRM10 { [CustomEditor(typeof(VRM10SpringBoneCollider))] @@ -9,25 +10,27 @@ namespace UniVRM10 VRM10SpringBoneCollider _target; Vrm10Instance _vrm; + SerializedProperty _script; + private void OnEnable() { _target = (VRM10SpringBoneCollider)target; - if(_target!=null) + if (_target != null) { _vrm = _target.GetComponentInParent(); } + + _script = serializedObject.FindProperty("m_Script"); } public override void OnInspectorGUI() { - // if (VRM10Window.Active == target) - // { - // GUI.backgroundColor = Color.cyan; - // Repaint(); - // } - var property = serializedObject.FindProperty("m_Script"); + using (new EditorGUI.DisabledScope(true)) + { + EditorGUILayout.PropertyField(_script); + } + var component = (VRM10SpringBoneCollider)target; - EditorGUILayout.PropertyField(property, new GUIContent("Script (" + component.GetIdentificationName() + ")")); switch (component.ColliderType) { case VRM10SpringBoneColliderTypes.Plane: @@ -59,7 +62,7 @@ namespace UniVRM10 if (Application.isPlaying) { // UniGLTF.UniGLTFLogger.Log("invaliate"); - if(_vrm!=null) + if (_vrm != null) { _vrm.Runtime.SpringBone.ReconstructSpringBone(); } From 06c1da2e98c83459aa1611fe5bb5dd65044fb2cb Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 26 Nov 2024 21:56:31 +0900 Subject: [PATCH 02/44] VRM10SpringBoneColliderGroupEditor --- .../VRM10SpringBoneColliderGroupEditor.cs | 86 +++++++++++++++++++ ...VRM10SpringBoneColliderGroupEditor.cs.meta | 11 +++ 2 files changed, 97 insertions(+) create mode 100644 Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs create mode 100644 Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs.meta diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs new file mode 100644 index 000000000..c2d02a75e --- /dev/null +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs @@ -0,0 +1,86 @@ +using System; +using System.Linq; +using UnityEditor; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; + + +namespace UniVRM10 +{ + [CustomEditor(typeof(VRM10SpringBoneColliderGroup))] + class VRM10SpringBoneColliderGroupEditor : Editor + { + ListView m_colliders; + + static VRM10SpringBoneCollider s_collider; + + public override VisualElement CreateInspectorGUI() + { + var root = new VisualElement(); + + // root.TrackSerializedObjectValue(serializedObject, OnValueChanged); + + root.Bind(serializedObject); + + { + var s = new PropertyField { bindingPath = "m_Script" }; + s.SetEnabled(false); + root.Add(s); + } + + + root.Add(new PropertyField { bindingPath = nameof(VRM10SpringBoneColliderGroup.Name) }); + + { + m_colliders = new ListView + { + bindingPath = nameof(VRM10SpringBoneColliderGroup.Colliders) + }; + m_colliders.selectionChanged += (e) => + { + var item = (SerializedProperty)e.FirstOrDefault(); + if (item == null) + { + s_collider = null; + } + else + { + s_collider = (VRM10SpringBoneCollider)item.objectReferenceValue; + } + }; + m_colliders.showAddRemoveFooter = true; + m_colliders.showFoldoutHeader = true; + m_colliders.headerTitle = "Colliders"; + root.Add(m_colliders); + } + + return root; + } + + public void OnSceneGUI() + { + HandleUtility.Repaint(); + if (m_colliders == null) + { + return; + } + + if (s_collider is VRM10SpringBoneCollider c) + { + // var t = p.transform; + // Handles.color = Color.green; + // Handles.SphereHandleCap(t.GetInstanceID(), t.position, t.rotation, p.Radius * 2, EventType.Repaint); + + EditorGUI.BeginChangeCheck(); + Handles.matrix = c.transform.localToWorldMatrix; + var newTargetPosition = Handles.PositionHandle(c.Offset, Quaternion.identity); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(c, "collider"); + c.Offset = newTargetPosition; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs.meta b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs.meta new file mode 100644 index 000000000..5e1e59629 --- /dev/null +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0ccae4c83e5d3a6438402cdd307f4ad2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 5f5eaa641b59e265dee4abed535cfe1252922ef3 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 26 Nov 2024 22:24:33 +0900 Subject: [PATCH 03/44] =?UTF-8?q?VRM10SpringBoneColliderEditor=20=E3=81=AB?= =?UTF-8?q?=20PositionHandle=20=E3=81=A8=20"Fit=20head-tail=20capsule"=20?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10SpringBoneColliderEditor.cs | 70 +++++++++++++++++-- .../VRM10SpringBoneColliderGroupEditor.cs | 4 -- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs index edb2958be..73da1d312 100644 --- a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs @@ -11,6 +11,11 @@ namespace UniVRM10 Vrm10Instance _vrm; SerializedProperty _script; + SerializedProperty _colliderType; + SerializedProperty _offset; + SerializedProperty _tail; + + static VRM10SpringBoneCollider s_selected; private void OnEnable() { @@ -21,6 +26,9 @@ namespace UniVRM10 } _script = serializedObject.FindProperty("m_Script"); + _colliderType = serializedObject.FindProperty(nameof(_target.ColliderType)); + _offset = serializedObject.FindProperty(nameof(_target.Offset)); + _tail = serializedObject.FindProperty(nameof(_target.Tail)); } public override void OnInspectorGUI() @@ -30,14 +38,13 @@ namespace UniVRM10 EditorGUILayout.PropertyField(_script); } - var component = (VRM10SpringBoneCollider)target; - switch (component.ColliderType) + switch (_target.ColliderType) { case VRM10SpringBoneColliderTypes.Plane: // radius: x // tail: x // normal: o - DrawPropertiesExcluding(serializedObject, "m_Script", nameof(component.Tail), nameof(component.Radius)); + DrawPropertiesExcluding(serializedObject, "m_Script", nameof(_target.Tail), nameof(_target.Radius)); break; case VRM10SpringBoneColliderTypes.Sphere: @@ -45,7 +52,7 @@ namespace UniVRM10 // radius: o // tail: x // normal: x - DrawPropertiesExcluding(serializedObject, nameof(component.Tail), nameof(component.Normal), "m_Script"); + DrawPropertiesExcluding(serializedObject, nameof(_target.Tail), nameof(_target.Normal), "m_Script"); break; case VRM10SpringBoneColliderTypes.Capsule: @@ -53,10 +60,31 @@ namespace UniVRM10 // radius: o // tail: o // normal: x - DrawPropertiesExcluding(serializedObject, nameof(component.Normal), "m_Script"); + DrawPropertiesExcluding(serializedObject, nameof(_target.Normal), "m_Script"); break; } + EditorGUILayout.BeginHorizontal(); + { + if (GUILayout.Button("Drag handle")) + { + s_selected = _target; + } + + if (_target.transform.childCount > 0) + { + if (GUILayout.Button("Fit head-tail capsule")) + { + _colliderType.enumValueFlag = (int)VRM10SpringBoneColliderTypes.Capsule; + _offset.vector3Value = Vector3.zero; + var tail = _target.transform.GetChild(0); + _tail.vector3Value = _target.transform.worldToLocalMatrix.MultiplyPoint( + tail.position); + } + } + } + EditorGUILayout.EndHorizontal(); + if (serializedObject.ApplyModifiedProperties()) { if (Application.isPlaying) @@ -69,5 +97,37 @@ namespace UniVRM10 } } } + + public void OnSceneGUI() + { + HandleUtility.Repaint(); + + if (s_selected == _target) + { + var c = _target; + Handles.matrix = c.transform.localToWorldMatrix; + if (_target.ColliderType == VRM10SpringBoneColliderTypes.Capsule + || _target.ColliderType == VRM10SpringBoneColliderTypes.CapsuleInside) + { + EditorGUI.BeginChangeCheck(); + var newTargetPosition = Handles.PositionHandle(c.Tail, Quaternion.identity); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(c, "collider"); + c.Tail = newTargetPosition; + } + } + else + { + EditorGUI.BeginChangeCheck(); + var newTargetPosition = Handles.PositionHandle(c.Offset, Quaternion.identity); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(c, "collider"); + c.Offset = newTargetPosition; + } + } + } + } } } \ No newline at end of file diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs index c2d02a75e..d5e0ff876 100644 --- a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderGroupEditor.cs @@ -68,10 +68,6 @@ namespace UniVRM10 if (s_collider is VRM10SpringBoneCollider c) { - // var t = p.transform; - // Handles.color = Color.green; - // Handles.SphereHandleCap(t.GetInstanceID(), t.position, t.rotation, p.Radius * 2, EventType.Repaint); - EditorGUI.BeginChangeCheck(); Handles.matrix = c.transform.localToWorldMatrix; var newTargetPosition = Handles.PositionHandle(c.Offset, Quaternion.identity); From 7e91b1b4d52b219da187d0e23282b0b4f76d3543 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 28 Nov 2024 13:30:25 +0900 Subject: [PATCH 04/44] =?UTF-8?q?gui=20=E3=81=AB=20checkbox=20=E3=81=A4?= =?UTF-8?q?=E3=81=91=E3=82=8F=E3=81=99=E3=82=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM/Editor/Format/VRMExportOptions.cs | 4 ++++ Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs | 1 + 2 files changed, 5 insertions(+) diff --git a/Assets/VRM/Editor/Format/VRMExportOptions.cs b/Assets/VRM/Editor/Format/VRMExportOptions.cs index 1b23da7bc..dfe78e7ea 100644 --- a/Assets/VRM/Editor/Format/VRMExportOptions.cs +++ b/Assets/VRM/Editor/Format/VRMExportOptions.cs @@ -12,6 +12,10 @@ namespace VRM [LangMsg(Languages.en, "Model's normalization (bake to remove roation and scaling from the hierarchy)")] NORMALIZE, + [LangMsg(Languages.ja, "正規化するときににブレンドシェイプによる変形をベイク処理します。")] + [LangMsg(Languages.en, "Bake the blendshape deformations as the base model when normalizing.")] + FREEZE_BLENDSHAPE, + [LangMsg(Languages.ja, "エクスポート時に新しいJsonSerializerを使う")] [LangMsg(Languages.en, "The new version of JsonSerializer for model export")] USE_GENERATED_SERIALIZER, diff --git a/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs b/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs index 9c8901ab3..3df60f240 100644 --- a/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs +++ b/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs @@ -48,6 +48,7 @@ namespace VRM private void OnEnable() { m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.PoseFreeze)), VRMExportOptions.NORMALIZE)); + m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.FreezeMeshUseCurrentBlendShapeWeight)), VRMExportOptions.FREEZE_BLENDSHAPE)); m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.UseSparseAccessor)), VRMExportOptions.BLENDSHAPE_USE_SPARSE)); m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.OnlyBlendshapePosition)), VRMExportOptions.BLENDSHAPE_EXCLUDE_NORMAL_AND_TANGENT)); m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.ReduceBlendshape)), VRMExportOptions.BLENDSHAPE_ONLY_CLIP_USE)); From f155a15c7e1c762b3bd646bd2a4fb504dafda965 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 28 Nov 2024 13:30:49 +0900 Subject: [PATCH 05/44] =?UTF-8?q?0.x=20=E3=81=AF=E3=80=80default=20true?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM/Editor/Format/VRMExportSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRM/Editor/Format/VRMExportSettings.cs b/Assets/VRM/Editor/Format/VRMExportSettings.cs index cc634263a..29b93d57e 100644 --- a/Assets/VRM/Editor/Format/VRMExportSettings.cs +++ b/Assets/VRM/Editor/Format/VRMExportSettings.cs @@ -23,7 +23,7 @@ namespace VRM /// FreezeBlendShape /// [Tooltip("when freeze mesh, blendShpae base use current weight")] - public bool FreezeMeshUseCurrentBlendShapeWeight = false; + public bool FreezeMeshUseCurrentBlendShapeWeight = true; /// /// BlendShapeのシリアライズにSparseAccessorを使う From c75dd199a50adcf9f3add24af8d4810511f52dc0 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 03:24:02 +0900 Subject: [PATCH 06/44] UseJob default true --- .../ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs index 9bfa68d8b..c90d025b7 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using UnityEngine; -using UniVRM10; + namespace UniVRM10.ClothWarp.Components { @@ -17,7 +17,7 @@ namespace UniVRM10.ClothWarp.Components public List Cloths = new(); [SerializeField] - public bool UseJob; + public bool UseJob = true; IVrm10SpringBoneRuntime m_runtime; public IVrm10SpringBoneRuntime CreateSpringBoneRuntime() From ffb1f54bdd20a05abb9a8bb53c074397cca5daab Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 03:24:14 +0900 Subject: [PATCH 07/44] update RotateParticleRuntimeProviderEditor --- .../RotateParticleRuntimeProviderEditor.cs | 81 ++++++++++++------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs index f1c12601a..320595292 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs @@ -1,7 +1,6 @@ -using System.Linq; +using UnityEngine.UIElements; using UnityEditor; -using UnityEngine; -using UniVRM10; +using UnityEditor.UIElements; namespace UniVRM10.ClothWarp.Components @@ -11,58 +10,78 @@ namespace UniVRM10.ClothWarp.Components { const string FROM_VRM10_MENU = "Replace VRM10 Springs to ClothWarp Warps"; - [MenuItem(FROM_VRM10_MENU, true)] - public static bool IsFromVrm10() + ClothWarpRuntimeProvider _target; + Vrm10Instance _vrm; + + void OnEnable() { - var go = Selection.activeGameObject; - if (go == null) + _target = (ClothWarpRuntimeProvider)target; + if (_target != null) { - return false; + _vrm = _target.GetComponent(); } - return go.GetComponent() != null; } - public override void OnInspectorGUI() + public override VisualElement CreateInspectorGUI() { - var provider = target as ClothWarpRuntimeProvider; - if (provider == null) + var root = new VisualElement(); + root.Bind(serializedObject); { - return; + var s = new PropertyField { bindingPath = "m_Script" }; + s.SetEnabled(false); + root.Add(s); } - var instance = provider.GetComponent(); - using (new EditorGUI.DisabledScope(instance == null)) + root.Add(new PropertyField { bindingPath = nameof(_target.Warps) }); + root.Add(new PropertyField { bindingPath = nameof(_target.Cloths) }); + { - if (GUILayout.Button("Replace VRM10 Springs to ClothWarp Warps")) + var setup = new Foldout { text = "Setup" }; + + var from_vrm10 = new Button { text = "Replace VRM10 Springs to ClothWarp Warps" }; + setup.Add(from_vrm10); + from_vrm10.RegisterCallback(e => { Undo.IncrementCurrentGroup(); Undo.SetCurrentGroupName(FROM_VRM10_MENU); var undo = Undo.GetCurrentGroup(); - Undo.RegisterCompleteObjectUndo(instance, "RegisterCompleteObjectUndo"); - ClothWarpRuntimeProvider.FromVrm10(instance, Undo.AddComponent, Undo.DestroyObjectImmediate); - Undo.RegisterFullObjectHierarchyUndo(instance.gameObject, "RegisterFullObjectHierarchyUndo"); + Undo.RegisterCompleteObjectUndo(_vrm, "RegisterCompleteObjectUndo"); + ClothWarpRuntimeProvider.FromVrm10(_vrm, Undo.AddComponent, Undo.DestroyObjectImmediate); + Undo.RegisterFullObjectHierarchyUndo(_vrm.gameObject, "RegisterFullObjectHierarchyUndo"); - Undo.RegisterCompleteObjectUndo(provider, "RegisterCompleteObjectUndo"); - provider.Reset(); + Undo.RegisterCompleteObjectUndo(_target, "RegisterCompleteObjectUndo"); + _target.Reset(); Undo.CollapseUndoOperations(undo); - } - } + }); - using (new EditorGUI.DisabledScope(instance == null || !Application.isPlaying)) - { - if (GUILayout.Button("RestoreInitialTransform")) + var reload = new Button { text = "Reload" }; + setup.Add(reload); + reload.RegisterCallback(e => { - instance.Runtime.SpringBone.RestoreInitialTransform(); - } + _target.Reset(); + }); + + root.Add(setup); } - if (GUILayout.Button("Reset")) { - provider.Reset(); + // runtime: reset button + var runtime = new Foldout { text = "Runtime" }; + root.Add(runtime); + + var button = new Button + { + text = "RestoreInitialTransform", + }; + runtime.Add(button); + button.RegisterCallback((e) => + { + _vrm.Runtime.SpringBone.RestoreInitialTransform(); + }); } - base.OnInspectorGUI(); + return root; } } } \ No newline at end of file From 6018af0a4e15ccf78d861bd19ca2da0813d18cf3 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 03:58:24 +0900 Subject: [PATCH 08/44] fix ClothWarpRoot.OnValidate --- .../ClothWarp/Runtime/Components/ClothWarpRoot.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRoot.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRoot.cs index fa3b708c0..456a8c3a8 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRoot.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRoot.cs @@ -4,7 +4,6 @@ using System.Linq; using UniGLTF.SpringBoneJobs.Blittables; using UnityEngine; using UnityEngine.UIElements; -using UniVRM10; namespace UniVRM10.ClothWarp.Components @@ -100,7 +99,18 @@ namespace UniVRM10.ClothWarp.Components void OnValidate() { - m_particles = GetComponentsInChildren().Skip(1).Select(x => new Particle(x)).ToList(); + var backup = m_particles.ToDictionary(x => x.Transform, x => x); + m_particles = GetComponentsInChildren().Skip(1).Select(x => + { + foreach (var particle in m_particles) + { + if (particle.Transform == x) + { + return particle; + } + } + return new Particle(x); + }).ToList(); m_map.Clear(); for (int i = 0; i < m_particles.Count; ++i) { From 9773b0c915f79a42a868c22fa4948bf077b6d21c Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 03:58:34 +0900 Subject: [PATCH 09/44] rename --- .../Editor/{WarpRootEditor.cs => ClothWarpRootEditor.cs} | 2 +- .../{WarpRootEditor.cs.meta => ClothWarpRootEditor.cs.meta} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/{WarpRootEditor.cs => ClothWarpRootEditor.cs} (99%) rename Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/{WarpRootEditor.cs.meta => ClothWarpRootEditor.cs.meta} (100%) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs similarity index 99% rename from Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs rename to Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs index 44f81cae6..2af75f659 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs @@ -10,7 +10,7 @@ using UniVRM10; namespace UniVRM10.ClothWarp.Components { [CustomEditor(typeof(ClothWarpRoot))] - class WarpRootEditor : Editor + class ClothWarpRootEditor : Editor { private ClothWarpRoot m_target; private Vrm10Instance m_vrm; diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs.meta b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs.meta similarity index 100% rename from Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs.meta rename to Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs.meta From 95d5576cc81c91099d19189708e787041bb6514a Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 11:06:47 +0900 Subject: [PATCH 10/44] fix StrandCollisionJob --- .../ClothSample/ClothWarp/Runtime/Jobs/Collision.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Collision.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Collision.cs index 1f572cd4f..71966a434 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Collision.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Collision.cs @@ -59,8 +59,8 @@ namespace UniVRM10.ClothWarp.Jobs pos += l.GetDelta(c.radius); } } - StrandCollision[particleIndex] = pos; } + StrandCollision[particleIndex] = pos; } } @@ -312,8 +312,8 @@ namespace UniVRM10.ClothWarp.Jobs } else { - NextPosition[particleIndex] = StrandCollision[particleIndex]; + NextPosition[particleIndex] = StrandCollision[particleIndex]; + } } } - } } \ No newline at end of file From d21ac212d9e93966c551ae599042415f703b40bb Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 13:40:01 +0900 Subject: [PATCH 11/44] Replace split to Load and Clear --- .../ClothSample/ClothViewer/ClothViewerUI.cs | 3 +- .../ClothWarp/Editor/ClothWarpRootEditor.cs | 38 +++++----------- .../RotateParticleRuntimeProviderEditor.cs | 44 +++++++++++++++---- .../ClothWarp/Runtime/ClothWarpRuntime.cs | 3 ++ .../Components/ClothWarpRuntimeProvider.cs | 10 +---- .../Runtime/Jobs/ClothWarpJobRuntime.cs | 12 ++++- .../ClothWarp/Runtime/Jobs/Particle.cs | 13 +++--- 7 files changed, 72 insertions(+), 51 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs index 5473dc515..7edcdfcca 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs @@ -402,8 +402,7 @@ namespace UniVRM10.Cloth.Viewer else { ClothWarpRuntimeProvider.FromVrm10(vrm, - go => go.AddComponent(), - o => GameObject.DestroyImmediate(o)); + go => go.AddComponent()); } if (animator.GetBoneTransform(HumanBodyBones.Hips) is var hips) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs index 2af75f659..4b902d18b 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs @@ -27,26 +27,6 @@ namespace UniVRM10.ClothWarp.Components m_vrm = m_target.GetComponentInParent(); } - // public override void OnInspectorGUI() - // { - // var n = EditorUtility.GetDirtyCount(m_target.GetInstanceID()); - // base.OnInspectorGUI(); - // if (n != EditorUtility.GetDirtyCount(m_target.GetInstanceID())) - // { - // if (m_vrm != null) - // { - // if (Application.isPlaying) - // { - // m_vrm.Runtime.SpringBone.SetJointLevel(m_target.transform, m_target.BaseSettings); - // foreach (var p in m_target.Particles) - // { - // m_vrm.Runtime.SpringBone.SetJointLevel(p.Transform, p.GetSettings(m_target.BaseSettings)); - // } - // } - // } - // } - // } - void BindColumn(string title, int width, Func makeVisualELmeent, Func enableFunc, string subpath) where T : BindableElement { m_treeview.columns.Add(new Column @@ -116,15 +96,19 @@ namespace UniVRM10.ClothWarp.Components private void OnValueChanged(SerializedObject so) { - Debug.Log("Name changed: " + so.targetObject.name); - // var nameProperty = so.FindProperty("m_Name"); + if (m_vrm != null) + { + if (Application.isPlaying) + { + m_vrm.Runtime.SpringBone.SetJointLevel(m_target.transform, m_target.BaseSettings); + foreach (var p in m_target.Particles) + { + m_vrm.Runtime.SpringBone.SetJointLevel(p.Transform, p.Settings); + } + } + } - // if (nameProperty.stringValue.Contains(" ")) - // _textField.style.backgroundColor = Color.red; - // else - // _textField.style.backgroundColor = StyleKeyword.Null; m_treeview.RefreshItems(); - // m_treeview.SetRootItems(m_target.m_rootitems); Repaint(); } diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs index 320595292..5b935b7e9 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs @@ -8,8 +8,6 @@ namespace UniVRM10.ClothWarp.Components [CustomEditor(typeof(ClothWarpRuntimeProvider))] public class RotateParticleRuntimeProviderEditor : Editor { - const string FROM_VRM10_MENU = "Replace VRM10 Springs to ClothWarp Warps"; - ClothWarpRuntimeProvider _target; Vrm10Instance _vrm; @@ -37,21 +35,51 @@ namespace UniVRM10.ClothWarp.Components { var setup = new Foldout { text = "Setup" }; - var from_vrm10 = new Button { text = "Replace VRM10 Springs to ClothWarp Warps" }; + var from_vrm10 = new Button { text = "Load VRM10 Springs to ClothWarp Warps" }; setup.Add(from_vrm10); from_vrm10.RegisterCallback(e => { Undo.IncrementCurrentGroup(); - Undo.SetCurrentGroupName(FROM_VRM10_MENU); + Undo.SetCurrentGroupName("Load Vrm-1.0 Springs to ClothWarp Warps"); + var undo = Undo.GetCurrentGroup(); + + // attach ClothWarp from VRM10Instance.Springs + ClothWarpRuntimeProvider.FromVrm10(_vrm, Undo.AddComponent); + Undo.RegisterFullObjectHierarchyUndo(_vrm.gameObject, "RegisterFullObjectHierarchyUndo"); + + // update ClothWarpRuntimeProvider + Undo.RegisterCompleteObjectUndo(_target, "RegisterCompleteObjectUndo"); + _target.Reset(); + + Undo.CollapseUndoOperations(undo); + }); + + var clear_vrm10_springs = new Button { text = "Clear Vrm-1.0 springs" }; + setup.Add(clear_vrm10_springs); + clear_vrm10_springs.RegisterCallback(e => + { + Undo.IncrementCurrentGroup(); + Undo.SetCurrentGroupName("Clear VRM10 Srpings"); var undo = Undo.GetCurrentGroup(); Undo.RegisterCompleteObjectUndo(_vrm, "RegisterCompleteObjectUndo"); - ClothWarpRuntimeProvider.FromVrm10(_vrm, Undo.AddComponent, Undo.DestroyObjectImmediate); + foreach (var spring in _vrm.SpringBone.Springs) + { + if (spring != null) + { + foreach (var joint in spring.Joints) + { + if (joint != null) + { + Undo.DestroyObjectImmediate(joint); + } + } + } + spring.Joints.Clear(); + } + _vrm.SpringBone.Springs.Clear(); Undo.RegisterFullObjectHierarchyUndo(_vrm.gameObject, "RegisterFullObjectHierarchyUndo"); - Undo.RegisterCompleteObjectUndo(_target, "RegisterCompleteObjectUndo"); - _target.Reset(); - Undo.CollapseUndoOperations(undo); }); diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs index 63888a4d6..ed13969c8 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs @@ -11,6 +11,9 @@ using UnityEngine; namespace UniVRM10.ClothWarp { + /// + /// プロトタイプ。非 job + /// public class ClothWarpRuntime : IVrm10SpringBoneRuntime { Vrm10Instance _vrm; diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs index c90d025b7..6c238e2d3 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs @@ -45,8 +45,7 @@ namespace UniVRM10.ClothWarp.Components } public static void FromVrm10(Vrm10Instance instance, - Func addWarp, - Action deleteObject) + Func addWarp) { foreach (var spring in instance.SpringBone.Springs) { @@ -64,7 +63,6 @@ namespace UniVRM10.ClothWarp.Components var warp = root_joint.GetComponent(); if (warp == null) { - // var warp = Undo.AddComponent(root_joint); warp = addWarp(root_joint); var joints = spring.Joints.Where(x => x != null).ToArray(); for (int i = 0; i < joints.Length; ++i) @@ -76,7 +74,7 @@ namespace UniVRM10.ClothWarp.Components gravityDir = joint.m_gravityDir, gravityPower = joint.m_gravityPower, // mod - stiffnessForce = joint.m_stiffnessForce * 6, + stiffnessForce = joint.m_stiffnessForce /* * 6*/, }; if (i == 0) { @@ -97,14 +95,10 @@ namespace UniVRM10.ClothWarp.Components warp.SetSettings(joint.transform, settings); } } - // Undo.DestroyObjectImmediate(joint); - deleteObject(joint); } - spring.Joints.Clear(); warp.ColliderGroups = spring.ColliderGroups.ToList(); } } - instance.SpringBone.Springs.Clear(); } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs index b05e25ce3..23fc6ded3 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs @@ -12,6 +12,9 @@ using UniVRM10; namespace UniVRM10.ClothWarp.Jobs { + /// + /// Job 版 + /// public class ClothWarpJobRuntime : IVrm10SpringBoneRuntime { Vrm10Instance _vrm; @@ -129,7 +132,7 @@ namespace UniVRM10.ClothWarp.Jobs _currentColliders = new(_colliderTransforms.Count, Allocator.Persistent); // - // warps + // warps => particles // _transforms = new(); List info = new(); @@ -334,6 +337,13 @@ namespace UniVRM10.ClothWarp.Jobs }.Schedule(_info.Length, 128, handle); } + // 親子の長さで拘束. TODO: ApplyRotationJob と合体 + handle = new ParentLengthConstraintJob + { + Warps = _warps, + Info = _info, + NextPositions = _nextPositions, + }.Schedule(_warps.Length, 16, handle); // NextPositions から NextRotations を作る handle = new ApplyRotationJob { diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Particle.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Particle.cs index c85550f8a..4836935a5 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Particle.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Particle.cs @@ -77,6 +77,7 @@ namespace UniVRM10.ClothWarp.Jobs public void Execute(int particleIndex) { + const float FACTOR = 6.0f; var particle = Info[particleIndex]; if (particle.TransformType.Movable()) { @@ -85,13 +86,15 @@ namespace UniVRM10.ClothWarp.Jobs var parent = Info[parentIndex]; var parentParentRotation = CurrentTransforms[parent.ParentIndex].Rotation; - var external = (particle.Settings.gravityDir * particle.Settings.gravityPower + Frame.Force) * Frame.DeltaTime; + var velocity = (CurrentPositions[particleIndex] - PrevPositions[particleIndex]) * (1.0f - particle.Settings.dragForce); + var resilience = parentParentRotation * parent.InitLocalRotation * particle.InitLocalPosition * + particle.Settings.stiffnessForce * FACTOR; // 親の回転による子ボーンの移動目標 + var external = particle.Settings.gravityDir * particle.Settings.gravityPower + Frame.Force; var newPosition = CurrentPositions[particleIndex] - + (CurrentPositions[particleIndex] - PrevPositions[particleIndex]) * (1.0f - particle.Settings.dragForce) - + parentParentRotation * parent.InitLocalRotation * particle.InitLocalPosition * - particle.Settings.stiffnessForce * Frame.DeltaTime // 親の回転による子ボーンの移動目標 - + external + + velocity + + resilience * Frame.DeltaTime + + external * Frame.DeltaTime ; NextPositions[particleIndex] = newPosition; From 9f1977d76f3d5fd75e9fcf4b7a6e294997d982d3 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 14:21:06 +0900 Subject: [PATCH 12/44] fix factor. add cloth to hips --- .../ClothSample/ClothViewer/ClothViewer.unity | 320 +++++++++++++++++- .../ClothSample/ClothViewer/ClothViewerUI.cs | 17 +- .../Components/ClothWarpRuntimeProvider.cs | 7 +- .../Runtime/Jobs/ClothWarpJobRuntime.cs | 6 +- .../ClothWarp/Runtime/Jobs/Particle.cs | 3 +- 5 files changed, 339 insertions(+), 14 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewer.unity b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewer.unity index 75d5db057..d6abc2f6b 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewer.unity +++ b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewer.unity @@ -402,7 +402,7 @@ MonoBehaviour: onValueChanged: m_PersistentCalls: m_Calls: [] - m_IsOn: 0 + m_IsOn: 1 --- !u!1 &153452228 GameObject: m_ObjectHideFlags: 0 @@ -686,6 +686,92 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 168425994} m_CullTransparentMesh: 0 +--- !u!1 &172483632 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 172483633} + - component: {fileID: 172483634} + m_Layer: 5 + m_Name: AddClothToHips + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &172483633 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 172483632} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1472853923} + - {fileID: 1724807119} + m_Father: {fileID: 339774397} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 162, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &172483634 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 172483632} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Highlighted + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1472853924} + toggleTransition: 1 + graphic: {fileID: 1236232219} + m_Group: {fileID: 0} + onValueChanged: + m_PersistentCalls: + m_Calls: [] + m_IsOn: 1 --- !u!1 &175751362 GameObject: m_ObjectHideFlags: 0 @@ -1407,6 +1493,7 @@ RectTransform: - {fileID: 1767706907} - {fileID: 947409974} - {fileID: 135168672} + - {fileID: 172483633} - {fileID: 2144476967} - {fileID: 1194499280} - {fileID: 153452229} @@ -5027,6 +5114,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1215781541} m_CullTransparentMesh: 0 +--- !u!1 &1236232217 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1236232218} + - component: {fileID: 1236232220} + - component: {fileID: 1236232219} + m_Layer: 5 + m_Name: Checkmark + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1236232218 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1236232217} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1472853923} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 20, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1236232219 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1236232217} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1236232220 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1236232217} + m_CullTransparentMesh: 0 --- !u!1 &1242458542 GameObject: m_ObjectHideFlags: 0 @@ -6228,6 +6390,82 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_IsOn: 0 +--- !u!1 &1472853922 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1472853923} + - component: {fileID: 1472853925} + - component: {fileID: 1472853924} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1472853923 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1472853922} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1236232218} + m_Father: {fileID: 172483633} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 10, y: -10} + m_SizeDelta: {x: 20, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1472853924 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1472853922} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1472853925 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1472853922} + m_CullTransparentMesh: 0 --- !u!1 &1476033060 GameObject: m_ObjectHideFlags: 0 @@ -6774,6 +7012,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1684483641} m_CullTransparentMesh: 0 +--- !u!1 &1724807118 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1724807119} + - component: {fileID: 1724807121} + - component: {fileID: 1724807120} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1724807119 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1724807118} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 172483633} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 9, y: -0.5} + m_SizeDelta: {x: -28, y: -3} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1724807120 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1724807118} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Add cloth to Hips +--- !u!222 &1724807121 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1724807118} + m_CullTransparentMesh: 0 --- !u!1 &1761414315 GameObject: m_ObjectHideFlags: 0 @@ -7224,6 +7541,7 @@ MonoBehaviour: m_openModel: {fileID: 2009818433} m_showBoxMan: {fileID: 1767706908} m_useJob: {fileID: 135168673} + m_addClothToHips: {fileID: 172483634} m_reconstructSprngBone: {fileID: 2144476968} m_resetSpringBone: {fileID: 1194499281} m_pauseSpringBone: {fileID: 153452230} diff --git a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs index 7edcdfcca..a25670807 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs @@ -21,6 +21,7 @@ namespace UniVRM10.Cloth.Viewer [Header("Cloth")] [SerializeField] Toggle m_useJob = default; + [SerializeField] Toggle m_addClothToHips = default; [SerializeField] Button m_reconstructSprngBone = default; [SerializeField] Button m_resetSpringBone = default; [SerializeField] Toggle m_pauseSpringBone = default; @@ -61,6 +62,7 @@ namespace UniVRM10.Cloth.Viewer m_showBoxMan = map.Get("ShowBoxMan"); m_useJob = map.Get("UseJob"); + m_addClothToHips = map.Get("AddClothToHips"); m_reconstructSprngBone = map.Get