mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 20:25:07 +08:00
parent
55e363c1b2
commit
5bc9211f80
@ -145,6 +145,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
new VisibleHeadAccessoryProcessor(avatarGameObject.GetComponent<VRCAvatarDescriptor>()).Process();
|
new VisibleHeadAccessoryProcessor(avatarGameObject.GetComponent<VRCAvatarDescriptor>()).Process();
|
||||||
new MergeAnimatorProcessor().OnPreprocessAvatar(avatarGameObject);
|
new MergeAnimatorProcessor().OnPreprocessAvatar(avatarGameObject);
|
||||||
new BlendshapeSyncAnimationProcessor().OnPreprocessAvatar(avatarGameObject);
|
new BlendshapeSyncAnimationProcessor().OnPreprocessAvatar(avatarGameObject);
|
||||||
|
PhysboneBlockerPass.Process(avatarGameObject);
|
||||||
|
|
||||||
AfterProcessing?.Invoke(avatarGameObject);
|
AfterProcessing?.Invoke(avatarGameObject);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 bd_
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace nadena.dev.modular_avatar.core.editor
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(ModularAvatarPBBlocker))]
|
||||||
|
[CanEditMultipleObjects]
|
||||||
|
internal class PBBlockerEditor : MAEditorBase
|
||||||
|
{
|
||||||
|
protected override void OnInnerInspectorGUI()
|
||||||
|
{
|
||||||
|
EditorGUILayout.HelpBox(Localization.S("pb_blocker.help"), MessageType.Info);
|
||||||
|
|
||||||
|
Localization.ShowLanguageUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ebb82fd864d647a893f9a5c1dee80703
|
||||||
|
timeCreated: 1669750103
|
@ -50,5 +50,6 @@
|
|||||||
"boneproxy.err.NotInAvatar": "You must specify an object that is in the avatar",
|
"boneproxy.err.NotInAvatar": "You must specify an object that is in the avatar",
|
||||||
"boneproxy.attachment": "Attachment mode",
|
"boneproxy.attachment": "Attachment mode",
|
||||||
"boneproxy.attachment.AsChildAtRoot": "As child; at root",
|
"boneproxy.attachment.AsChildAtRoot": "As child; at root",
|
||||||
"boneproxy.attachment.AsChildKeepWorldPosition": "As child; keep position"
|
"boneproxy.attachment.AsChildKeepWorldPosition": "As child; keep position",
|
||||||
|
"pb_blocker.help": "This object will not be affected by PhysBones attached to parents."
|
||||||
}
|
}
|
@ -50,5 +50,6 @@
|
|||||||
"boneproxy.err.NotInAvatar": "アバター内のオブジェクトを指定してください。",
|
"boneproxy.err.NotInAvatar": "アバター内のオブジェクトを指定してください。",
|
||||||
"boneproxy.attachment": "配置モード",
|
"boneproxy.attachment": "配置モード",
|
||||||
"boneproxy.attachment.AsChildAtRoot": "子として・ルートに配置",
|
"boneproxy.attachment.AsChildAtRoot": "子として・ルートに配置",
|
||||||
"boneproxy.attachment.AsChildKeepWorldPosition": "子として・ワールド位置を維持"
|
"boneproxy.attachment.AsChildKeepWorldPosition": "子として・ワールド位置を維持",
|
||||||
|
"pb_blocker.help": "このオブジェクトは親のPhysBoneから影響を受けなくなります。"
|
||||||
}
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 bd_
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using VRC.SDK3.Dynamics.PhysBone.Components;
|
||||||
|
|
||||||
|
namespace nadena.dev.modular_avatar.core.editor
|
||||||
|
{
|
||||||
|
internal class PhysboneBlockerPass
|
||||||
|
{
|
||||||
|
public static void Process(GameObject avatarRoot)
|
||||||
|
{
|
||||||
|
var blockers = avatarRoot.GetComponentsInChildren<ModularAvatarPBBlocker>(true);
|
||||||
|
if (blockers.Length == 0) return;
|
||||||
|
|
||||||
|
var physBones = avatarRoot.GetComponentsInChildren<VRCPhysBone>(true);
|
||||||
|
if (physBones.Length == 0) return;
|
||||||
|
|
||||||
|
Dictionary<Transform, List<Transform>> physBoneRootToIgnores = new Dictionary<Transform, List<Transform>>();
|
||||||
|
|
||||||
|
var avatarTransform = avatarRoot.transform;
|
||||||
|
foreach (var tip in blockers)
|
||||||
|
{
|
||||||
|
var node = tip.transform;
|
||||||
|
// We deliberately skip the node itself to allow for a specific PhysBone to be attached here.
|
||||||
|
while (node != null && node != avatarTransform && node.parent != null)
|
||||||
|
{
|
||||||
|
node = node.parent;
|
||||||
|
if (!physBoneRootToIgnores.TryGetValue(node, out var parent))
|
||||||
|
{
|
||||||
|
parent = new List<Transform>();
|
||||||
|
physBoneRootToIgnores.Add(node, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent.Add(tip.transform);
|
||||||
|
node = node.parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var pb in physBones)
|
||||||
|
{
|
||||||
|
var root = pb.rootTransform != null ? pb.rootTransform : pb.transform;
|
||||||
|
if (physBoneRootToIgnores.TryGetValue(root, out var ignores))
|
||||||
|
{
|
||||||
|
pb.ignoreTransforms.AddRange(ignores);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 375dac2ebd964a6db0f271d0ab93da2f
|
||||||
|
timeCreated: 1669749518
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 bd_
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace nadena.dev.modular_avatar.core
|
||||||
|
{
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
[AddComponentMenu("Modular Avatar/MA PhysBone Blocker")]
|
||||||
|
public class ModularAvatarPBBlocker : AvatarTagComponent
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a5bf908a199a4648845ebe2fd3b5a4bd
|
||||||
|
timeCreated: 1669749485
|
25
docs/docs/reference/physbone-blocker.md
Normal file
25
docs/docs/reference/physbone-blocker.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# PhysBone Blocker
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
This component is planned to be added in 1.1.0, and is not available in the 1.0.x series.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
![PhysBone Blocker](physbone-blocker.png)
|
||||||
|
|
||||||
|
The PhysBone Blocker prevents physbones rooted in parent objects from affecting a child object.
|
||||||
|
It does this by adding this child object to the Ignore list for any PhysBone affecting a parent object.
|
||||||
|
|
||||||
|
## When should I use it?
|
||||||
|
|
||||||
|
When making accessories that someone might want to attach to a PhysBone chain like a tail or an ear,
|
||||||
|
you can attach a PhysBone Blocker to prevent the parent PhysBone chain from affecting the child object.
|
||||||
|
|
||||||
|
Note that you can still attach a PhysBone component to the child object that has the PhysBone Blocker on it.
|
||||||
|
|
||||||
|
## Use with Bone Proxies
|
||||||
|
|
||||||
|
When using the [Bone Proxy component](bone-proxy.md) to attach an object to a pre-existing PhysBone chain,
|
||||||
|
attaching the PhysBone blocker will ensure that your object is rigidly attached to the parent chain.
|
||||||
|
When doing this, it's best to have the PhysBone Blocker on the same object that has the Bone Proxy.
|
BIN
docs/docs/reference/physbone-blocker.png
Normal file
BIN
docs/docs/reference/physbone-blocker.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,24 @@
|
|||||||
|
# PhysBone Blocker
|
||||||
|
|
||||||
|
:::caution 注意
|
||||||
|
|
||||||
|
このコンポーネントは1.1.0で追加される予定であり、1.0.xでは利用できません。
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
![PhysBone Blocker](physbone-blocker.png)
|
||||||
|
|
||||||
|
PhysBone Blockerは、子オブジェクトから親オブジェクトをルートとするPhysBoneの影響を防ぎます。
|
||||||
|
親オブジェクトを影響するPhysBoneコンポーネントのIgnoreリストに子オブジェクトを追加することにより実装しています。
|
||||||
|
|
||||||
|
## いつ使うもの?
|
||||||
|
|
||||||
|
PhysBoneによる揺れ物、例えば耳やしっぽにつけるアクセサリーを作るとき、PhysBone Blockerを付けることで
|
||||||
|
既存の親のPhysBoneの影響を防ぐことができます。
|
||||||
|
|
||||||
|
なお、PhysBone Blockerを付けた子オブジェクトでも、そのオブジェクトそのものにPhysBoneを付けることが可能です。
|
||||||
|
|
||||||
|
## Bone Proxiesとの使用
|
||||||
|
|
||||||
|
[Bone Proxy コンポーネント](bone-proxy.md)を使って、既存のPhysBoneチェーンに装着するとき、
|
||||||
|
PhysBone Blockerも付けるとしっかりと親に固定できます。この時はPhysBone BlockerをBone Proxyと同じオブジェクトに付けることを推奨します。
|
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Loading…
Reference in New Issue
Block a user