mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-14 06:19:47 -05:00
add default transform states
This commit is contained in:
parent
63eb58d6b7
commit
b537a4a3ea
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
using UniVRM10.FastSpringBones.Blittables;
|
||||
using UniVRM10.FastSpringBones.System;
|
||||
|
|
@ -15,6 +17,7 @@ namespace UniVRM10
|
|||
private readonly IVrm10Constraint[] m_constraints;
|
||||
private readonly Transform m_head;
|
||||
private readonly FastSpringBoneService m_fastSpringBoneService;
|
||||
private readonly Dictionary<Transform, (Vector3 position, Quaternion rotation)> m_defaultTransformStates;
|
||||
|
||||
private FastSpringBoneBuffer m_fastSpringBoneBuffer;
|
||||
|
||||
|
|
@ -47,6 +50,18 @@ namespace UniVRM10
|
|||
// for UnitTest
|
||||
return;
|
||||
}
|
||||
|
||||
var instance = target.GetComponent<RuntimeGltfInstance>();
|
||||
if (instance != null)
|
||||
{
|
||||
// ランタイムインポートならここに到達してほぼゼロコストになる
|
||||
m_defaultTransformStates = instance.Nodes.ToDictionary(tf=> tf, tf=>(tf.position, tf.rotation));
|
||||
}
|
||||
else
|
||||
{
|
||||
// エディタでプレハブ配置してる奴ならこっちに到達して収集する
|
||||
m_defaultTransformStates = target.GetComponentsInChildren<Transform>().ToDictionary(tf=> tf, tf=>(tf.position, tf.rotation));
|
||||
}
|
||||
|
||||
m_fastSpringBoneService = FastSpringBoneService.Instance;
|
||||
m_fastSpringBoneBuffer = CreateFastSpringBoneBuffer(m_target.SpringBone);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user