mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-14 06:50:19 -05:00
Merge branch 'master' into fix/strictry_empty
This commit is contained in:
@@ -56,12 +56,12 @@ namespace UniGLTF
|
||||
});
|
||||
|
||||
Profiler.BeginSample("MeshUploader.BuildBlendShapeAsync");
|
||||
if (blendShape.Positions.Count > 0)
|
||||
if (positions.Length > 0)
|
||||
{
|
||||
if (blendShape.Positions.Count == mesh.vertexCount)
|
||||
if (positions.Length == mesh.vertexCount)
|
||||
{
|
||||
mesh.AddBlendShapeFrame(blendShape.Name, FrameWeight,
|
||||
blendShape.Positions.ToArray(),
|
||||
positions,
|
||||
normals.Length == mesh.vertexCount && normals.Length == positions.Length ? normals : null,
|
||||
null
|
||||
);
|
||||
|
||||
@@ -139,7 +139,18 @@ namespace UniVRM10
|
||||
{
|
||||
// importer 内で InitializeAsync が呼び出し済み
|
||||
}
|
||||
return new Vrm10Runtime(this, useControlRig, m_springBoneRuntime);
|
||||
|
||||
var runtime = GetComponent<RuntimeGltfInstance>();
|
||||
|
||||
// Vrm10Runtimeが使う初期姿勢を固定する。SpringBone や Constraint の初期姿勢になる。
|
||||
var initPose = runtime != null
|
||||
// RuntimeGltfInstance があるとき => RuntimeLoad => 初期姿勢は glTF の node に由来する
|
||||
? runtime.InitialTransformStates.ToDictionary((kv) => kv.Key, (kv) => kv.Value)
|
||||
// RuntimeGltfInstance が無いとき => Scene 配置の prefab など。シーンの現状を代用する。既に T-Pose でないかもしれない。
|
||||
: GetComponentsInChildren<Transform>().ToDictionary(x => x, x => new TransformState(x))
|
||||
;
|
||||
|
||||
return new Vrm10Runtime(this, useControlRig, m_springBoneRuntime, initPose);
|
||||
}
|
||||
|
||||
public Vrm10Runtime Runtime
|
||||
|
||||
@@ -49,25 +49,21 @@ namespace UniVRM10
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<Transform, TransformState> _initPose;
|
||||
IReadOnlyDictionary<Transform, TransformState> _initPose;
|
||||
|
||||
public Vrm10Runtime(Vrm10Instance instance, bool useControlRig, IVrm10SpringBoneRuntime springBoneRuntime)
|
||||
public Vrm10Runtime(Vrm10Instance instance, bool useControlRig, IVrm10SpringBoneRuntime springBoneRuntime,
|
||||
IReadOnlyDictionary<Transform, TransformState> initPose)
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
UniGLTFLogger.Warning($"{nameof(Vrm10Runtime)} expects runtime behaviour.");
|
||||
}
|
||||
if (instance == null)
|
||||
{
|
||||
m_instance = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_instance != instance)
|
||||
_initPose = initPose;
|
||||
m_instance = instance;
|
||||
if (m_instance == null)
|
||||
{
|
||||
m_instance = instance;
|
||||
var runtime = m_instance.GetComponent<RuntimeGltfInstance>();
|
||||
_initPose = runtime.InitialTransformStates.ToDictionary((kv) => kv.Key, (kv) => kv.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!instance.TryGetBoneTransform(HumanBodyBones.Head, out m_head))
|
||||
|
||||
Reference in New Issue
Block a user