FullBodyIKCtrl.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using RootMotion.FinalIK;
  5. using UnityEngine;
  6. public class FullBodyIKCtrl : MonoBehaviour
  7. {
  8. public TBody TgtBody
  9. {
  10. get
  11. {
  12. return this.m_TgtBody;
  13. }
  14. }
  15. public Maid TgtChara
  16. {
  17. get
  18. {
  19. return this.m_TgtBody.maid;
  20. }
  21. }
  22. public Transform IKTgtRoot
  23. {
  24. get
  25. {
  26. return this.m_IKTgtRoot;
  27. }
  28. }
  29. public FullBodyBipedIK FullbodyIK
  30. {
  31. get
  32. {
  33. return this.m_FullbodyIK;
  34. }
  35. }
  36. public IKEffector BodyEffector
  37. {
  38. get
  39. {
  40. return this.m_FullbodyIK.solver.bodyEffector;
  41. }
  42. }
  43. public BodyCtrlData BodyCtrlData
  44. {
  45. get
  46. {
  47. return this.m_BodyCtrlData;
  48. }
  49. }
  50. public Transform BodyTarget { get; private set; }
  51. public bool IsUpdateEnd { get; private set; }
  52. public Dictionary<string, IKCtrlData> strIKDataPair
  53. {
  54. get
  55. {
  56. return this.m_StrIKDataPair;
  57. }
  58. }
  59. public bool IsIKExec
  60. {
  61. get
  62. {
  63. return this.m_StrIKDataPair.Any((KeyValuePair<string, IKCtrlData> ik) => ik.Value.IsIKExec) && this.IKActive;
  64. }
  65. }
  66. public bool IsSelfIKAttach
  67. {
  68. get
  69. {
  70. return this.m_StrIKDataPair.Any((KeyValuePair<string, IKCtrlData> ik) => ik.Value.IsSelfIKAttach) && this.IKActive;
  71. }
  72. }
  73. public void Init()
  74. {
  75. this.m_TgtBody = base.GetComponent<TBody>();
  76. if (!this.m_IKTgtRoot)
  77. {
  78. this.m_IKTgtRoot = new GameObject("IK Target Root").transform;
  79. this.m_IKTgtRoot.SetParent(this.m_TgtBody.m_trBones, false);
  80. }
  81. if (!this.TgtChara.boMAN)
  82. {
  83. this.m_STRoot = this.m_TgtBody.m_trBones.Find("ST_Root");
  84. }
  85. if (this.m_FullbodyIK)
  86. {
  87. UnityEngine.Object.DestroyImmediate(this.m_FullbodyIK);
  88. }
  89. this.m_FullbodyIK = this.m_IKTgtRoot.gameObject.AddComponent<FullBodyBipedIK>();
  90. if (this.m_Mouth)
  91. {
  92. UnityEngine.Object.DestroyImmediate(this.m_Mouth);
  93. }
  94. this.m_Mouth = new GameObject("Mouth").transform;
  95. this.m_Mouth.SetParent(this.TgtBody.trsHead, false);
  96. this.m_Mouth.localEulerAngles = new Vector3(-90f, 90f, 0f);
  97. if (!this.TgtChara.boMAN)
  98. {
  99. if (this.m_NippleL)
  100. {
  101. UnityEngine.Object.DestroyImmediate(this.m_NippleL);
  102. }
  103. if (this.m_NippleR)
  104. {
  105. UnityEngine.Object.DestroyImmediate(this.m_NippleR);
  106. }
  107. this.m_NippleL = new GameObject("Nipple_L").transform;
  108. this.m_NippleL.SetParent(CMT.SearchObjName(this.TgtBody.m_trBones, "Mune_L_sub", true), false);
  109. this.m_NippleR = new GameObject("Nipple_R").transform;
  110. this.m_NippleR.SetParent(CMT.SearchObjName(this.TgtBody.m_trBones, "Mune_R_sub", true), false);
  111. }
  112. this.m_NameFlagObjpair.Clear();
  113. this.m_IKBoneDic = FullBodyIKCtrl.GetAllIKBoneDic(this.TgtChara);
  114. this.m_FullbodyIK.references.root = this.m_TgtBody.m_trBones;
  115. this.m_FullbodyIK.references.pelvis = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Root);
  116. if (!this.TgtChara.boMAN)
  117. {
  118. this.m_FullbodyIK.references.spine = new Transform[]
  119. {
  120. this.m_IKBoneDic[FullBodyIKCtrl.IKBoneType.Spine0],
  121. this.m_IKBoneDic[FullBodyIKCtrl.IKBoneType.Spine3]
  122. };
  123. }
  124. else
  125. {
  126. this.m_FullbodyIK.references.spine = new Transform[]
  127. {
  128. this.m_IKBoneDic[FullBodyIKCtrl.IKBoneType.Spine0],
  129. this.m_IKBoneDic[FullBodyIKCtrl.IKBoneType.Spine2]
  130. };
  131. }
  132. this.m_FullbodyIK.references.head = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Head);
  133. this.m_FullbodyIK.references.leftUpperArm = this.GetIKBone(FullBodyIKCtrl.IKBoneType.UpperArm_L);
  134. this.m_FullbodyIK.references.leftForearm = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Forearm_L);
  135. this.m_FullbodyIK.references.leftHand = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Hand_L);
  136. this.m_FullbodyIK.references.rightUpperArm = this.GetIKBone(FullBodyIKCtrl.IKBoneType.UpperArm_R);
  137. this.m_FullbodyIK.references.rightForearm = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Forearm_R);
  138. this.m_FullbodyIK.references.rightHand = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Hand_R);
  139. this.m_FullbodyIK.references.leftThigh = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Thigh_L);
  140. this.m_FullbodyIK.references.leftCalf = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Calf_L);
  141. this.m_FullbodyIK.references.leftFoot = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Foot_L);
  142. this.m_FullbodyIK.references.rightThigh = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Thigh_R);
  143. this.m_FullbodyIK.references.rightCalf = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Calf_R);
  144. this.m_FullbodyIK.references.rightFoot = this.GetIKBone(FullBodyIKCtrl.IKBoneType.Foot_R);
  145. this.m_FullbodyIK.solver.SetToReferences(this.m_FullbodyIK.references, null);
  146. this.m_FullbodyIK.fixTransforms = false;
  147. foreach (IKEffector ikeffector in this.m_FullbodyIK.solver.effectors)
  148. {
  149. ikeffector.positionWeight = 0f;
  150. ikeffector.rotationWeight = 0f;
  151. }
  152. foreach (FBIKChain fbikchain in this.m_FullbodyIK.solver.chain)
  153. {
  154. fbikchain.bendConstraint.weight = 0f;
  155. }
  156. this.m_BodyCtrlData = this.SafeAddBodyCtrlData("体全体");
  157. this.FullbodyIK.solver.GetChain(FullBodyBipedChain.LeftLeg).pull = 0f;
  158. this.FullbodyIK.solver.GetChain(FullBodyBipedChain.RightLeg).pull = 0f;
  159. this.AddLimbIKData(FullBodyIKCtrl.IKBoneType.Hand_L, FullBodyIKCtrl.IKBoneType.Forearm_L, FullBodyIKCtrl.IKBoneType.UpperArm_L, FullBodyBipedEffector.LeftHand, FullBodyBipedEffector.LeftShoulder, true);
  160. this.AddLimbIKData(FullBodyIKCtrl.IKBoneType.Hand_R, FullBodyIKCtrl.IKBoneType.Forearm_R, FullBodyIKCtrl.IKBoneType.UpperArm_R, FullBodyBipedEffector.RightHand, FullBodyBipedEffector.RightShoulder, true);
  161. this.AddLimbIKData(FullBodyIKCtrl.IKBoneType.Foot_L, FullBodyIKCtrl.IKBoneType.Calf_L, FullBodyIKCtrl.IKBoneType.Thigh_L, FullBodyBipedEffector.LeftFoot, FullBodyBipedEffector.LeftThigh, false);
  162. this.AddLimbIKData(FullBodyIKCtrl.IKBoneType.Foot_R, FullBodyIKCtrl.IKBoneType.Calf_R, FullBodyIKCtrl.IKBoneType.Thigh_R, FullBodyBipedEffector.RightFoot, FullBodyBipedEffector.RightThigh, false);
  163. if (!this.BodyTarget)
  164. {
  165. Transform transform = this.m_IKTgtRoot.Find(this.BodyEffector.bone.name);
  166. if (!transform)
  167. {
  168. transform = new GameObject(this.BodyEffector.bone.name).transform;
  169. }
  170. transform.SetParent(this.m_IKTgtRoot, false);
  171. this.BodyTarget = new GameObject("IKTarget").transform;
  172. this.BodyTarget.SetParent(transform, false);
  173. }
  174. this.BodyEffector.target = this.BodyTarget;
  175. this.BodyEffector.effectChildNodes = false;
  176. this.m_FullbodyIK.enabled = false;
  177. }
  178. private BodyCtrlData SafeAddBodyCtrlData(string key_str)
  179. {
  180. BodyCtrlData bodyCtrlData = new BodyCtrlData(this);
  181. if (this.m_StrIKDataPair.ContainsKey(key_str))
  182. {
  183. this.m_StrIKDataPair[key_str] = bodyCtrlData;
  184. }
  185. else
  186. {
  187. this.m_StrIKDataPair.Add(key_str, bodyCtrlData);
  188. }
  189. this.m_BodyCtrlData = bodyCtrlData;
  190. return (BodyCtrlData)this.m_StrIKDataPair[key_str];
  191. }
  192. private LimbIKData[] AddLimbIKData(FullBodyIKCtrl.IKBoneType hand_foot, FullBodyIKCtrl.IKBoneType elbow_knee, FullBodyIKCtrl.IKBoneType shoulder_thigh, FullBodyBipedEffector handfoot_effector, FullBodyBipedEffector shoulderthigh_effector, bool use_old = false)
  193. {
  194. IKSolverFullBodyBiped solver = this.FullbodyIK.solver;
  195. IKMappingLimb limbMapping = solver.GetLimbMapping(handfoot_effector);
  196. FBIKChain chain = solver.GetChain(handfoot_effector);
  197. ShoulderThighIKData shoulderThighIKData = new ShoulderThighIKData(solver.GetEffector(shoulderthigh_effector), chain, limbMapping, this, this.GetIKBone(shoulder_thigh));
  198. this.m_StrIKDataPair[FullBodyIKCtrl.IKBoneTypeStrDic[shoulder_thigh]] = shoulderThighIKData;
  199. ElbowKneeIKData elbowKneeIKData = new ElbowKneeIKData(chain, limbMapping, this, this.GetIKBone(elbow_knee));
  200. this.m_StrIKDataPair[FullBodyIKCtrl.IKBoneTypeStrDic[elbow_knee]] = elbowKneeIKData;
  201. HandFootIKData handFootIKData = new HandFootIKData(solver.GetEffector(handfoot_effector), chain, limbMapping, this, this.GetIKBone(hand_foot), use_old);
  202. this.m_StrIKDataPair[FullBodyIKCtrl.IKBoneTypeStrDic[hand_foot]] = handFootIKData;
  203. shoulderThighIKData.SetChainData(handFootIKData, elbowKneeIKData);
  204. elbowKneeIKData.SetChainData(handFootIKData, shoulderThighIKData);
  205. handFootIKData.SetChainData(elbowKneeIKData, shoulderThighIKData);
  206. return new LimbIKData[]
  207. {
  208. shoulderThighIKData,
  209. elbowKneeIKData,
  210. handFootIKData
  211. };
  212. }
  213. private void Update()
  214. {
  215. this.IsUpdateEnd = false;
  216. if (this.IKActive)
  217. {
  218. this.BodyCtrlData.CharaPosReset();
  219. }
  220. }
  221. private void OnDestroy()
  222. {
  223. if (this.m_IKTgtRoot)
  224. {
  225. UnityEngine.Object.Destroy(this.m_IKTgtRoot);
  226. }
  227. }
  228. public void IKUpdate()
  229. {
  230. if (!this.m_IsPelvisPull)
  231. {
  232. this.BodyEffector.positionWeight = 1f;
  233. }
  234. else
  235. {
  236. this.BodyEffector.positionWeight = 0f;
  237. }
  238. this.BodyTarget.position = this.BodyEffector.bone.position;
  239. this.IsUpdateLate = false;
  240. foreach (IKCtrlData ikctrlData in this.m_StrIKDataPair.Values)
  241. {
  242. ikctrlData.TagetTransCpy();
  243. }
  244. this.BodyCtrlData.ApplyIKSetting();
  245. if (this.IsUpdateLate)
  246. {
  247. return;
  248. }
  249. if (this.BodyCtrlData.IsIKExec)
  250. {
  251. this.BodyCtrlData.Update();
  252. }
  253. foreach (IKCtrlData ikctrlData2 in this.m_StrIKDataPair.Values)
  254. {
  255. if (!(ikctrlData2 is BodyCtrlData))
  256. {
  257. ikctrlData2.ApplyIKSetting();
  258. }
  259. }
  260. if (!this.IsUpdateLate)
  261. {
  262. if (this.IsIKExec || this.AllForceIK)
  263. {
  264. this.SolverUpdate();
  265. }
  266. else
  267. {
  268. foreach (IKCtrlData ikctrlData3 in this.m_StrIKDataPair.Values)
  269. {
  270. ikctrlData3.SaveLastBonePosRot();
  271. }
  272. }
  273. }
  274. }
  275. public void AttachPointTransCpy(Transform trans, string slot_name, string attach_name, bool scale_cpy = false)
  276. {
  277. int slotNo = this.TgtBody.GetSlotNo(slot_name);
  278. if (this.TgtBody.goSlot[slotNo].morph == null)
  279. {
  280. return;
  281. }
  282. Vector3 position;
  283. Quaternion rotation;
  284. Vector3 localScale;
  285. this.TgtBody.goSlot[slotNo].morph.GetAttachPoint(attach_name, out position, out rotation, out localScale, false);
  286. trans.position = position;
  287. trans.rotation = rotation;
  288. if (scale_cpy)
  289. {
  290. trans.localScale = localScale;
  291. }
  292. }
  293. public void SolverUpdate()
  294. {
  295. this.IsUpdateEnd = true;
  296. Action postSolverUpdate = this.PostSolverUpdate;
  297. this.PostSolverUpdate = null;
  298. if (this.IKActive)
  299. {
  300. bool flag = false;
  301. foreach (IKCtrlData ikctrlData in this.m_StrIKDataPair.Values)
  302. {
  303. if (!(ikctrlData is BodyCtrlData))
  304. {
  305. if (ikctrlData.IsIKExec && !ikctrlData.OldIkExec)
  306. {
  307. flag = true;
  308. break;
  309. }
  310. }
  311. }
  312. if (flag)
  313. {
  314. Vector3 localPosition = this.m_FullbodyIK.references.spine[1].localPosition;
  315. this.m_FullbodyIK.solver.Update();
  316. this.m_FullbodyIK.references.spine[1].localPosition = localPosition;
  317. foreach (IKCtrlData ikctrlData2 in this.m_StrIKDataPair.Values)
  318. {
  319. if (!(ikctrlData2 is BodyCtrlData))
  320. {
  321. if (ikctrlData2.IsIKExec)
  322. {
  323. ikctrlData2.Update();
  324. }
  325. }
  326. }
  327. }
  328. }
  329. foreach (IKCtrlData ikctrlData3 in this.m_StrIKDataPair.Values)
  330. {
  331. ikctrlData3.LateUpdate();
  332. }
  333. if (this.IKActive && postSolverUpdate != null)
  334. {
  335. postSolverUpdate();
  336. }
  337. }
  338. public void LateIKUpdate()
  339. {
  340. this.IKUpdate();
  341. this.TgtBody.AutoTwist();
  342. for (int i = 0; i < this.TgtBody.goSlot.Count; i++)
  343. {
  344. if (this.TgtBody.goSlot[i].obj != null)
  345. {
  346. this.TgtBody.goSlot[i].CopyTrans();
  347. }
  348. this.TgtBody.goSlot[i].Update();
  349. }
  350. }
  351. public Transform GetIKBone(FullBodyIKCtrl.IKBoneType boneType)
  352. {
  353. return (!this.m_IKBoneDic.ContainsKey(boneType)) ? null : this.m_IKBoneDic[boneType];
  354. }
  355. public Transform[] GetChainBonesToInit(FullBodyIKCtrl.IKBoneType boneType)
  356. {
  357. Transform[] result = new Transform[0];
  358. switch (boneType)
  359. {
  360. case FullBodyIKCtrl.IKBoneType.UpperArm_R:
  361. case FullBodyIKCtrl.IKBoneType.Forearm_R:
  362. case FullBodyIKCtrl.IKBoneType.Hand_R:
  363. result = new Transform[]
  364. {
  365. this.GetIKBone(FullBodyIKCtrl.IKBoneType.UpperArm_R),
  366. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Forearm_R),
  367. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Hand_R)
  368. };
  369. break;
  370. case FullBodyIKCtrl.IKBoneType.UpperArm_L:
  371. case FullBodyIKCtrl.IKBoneType.Forearm_L:
  372. case FullBodyIKCtrl.IKBoneType.Hand_L:
  373. result = new Transform[]
  374. {
  375. this.GetIKBone(FullBodyIKCtrl.IKBoneType.UpperArm_L),
  376. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Forearm_L),
  377. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Hand_L)
  378. };
  379. break;
  380. case FullBodyIKCtrl.IKBoneType.Thigh_R:
  381. case FullBodyIKCtrl.IKBoneType.Calf_R:
  382. case FullBodyIKCtrl.IKBoneType.Foot_R:
  383. result = new Transform[]
  384. {
  385. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Thigh_R),
  386. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Calf_R),
  387. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Foot_R)
  388. };
  389. break;
  390. case FullBodyIKCtrl.IKBoneType.Thigh_L:
  391. case FullBodyIKCtrl.IKBoneType.Calf_L:
  392. case FullBodyIKCtrl.IKBoneType.Foot_L:
  393. result = new Transform[]
  394. {
  395. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Thigh_L),
  396. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Calf_L),
  397. this.GetIKBone(FullBodyIKCtrl.IKBoneType.Foot_L)
  398. };
  399. break;
  400. }
  401. return result;
  402. }
  403. public IKCtrlData GetIKData(string tag_name, bool flagcheck = false)
  404. {
  405. return this.GetIKData(tag_name);
  406. }
  407. public IKCtrlData GetIKData(string tag_name)
  408. {
  409. if (this.m_StrIKDataPair.ContainsKey(tag_name))
  410. {
  411. return this.m_StrIKDataPair[tag_name];
  412. }
  413. return null;
  414. }
  415. public T GetIKData<T>(string tag_name) where T : IKCtrlData
  416. {
  417. IKCtrlData ikdata = this.GetIKData(tag_name);
  418. if (ikdata != null && ikdata is T)
  419. {
  420. return ikdata as T;
  421. }
  422. return (T)((object)null);
  423. }
  424. public IKCtrlData GetIKData(FullBodyIKCtrl.IKBoneType bone_type)
  425. {
  426. if (FullBodyIKCtrl.IKBoneTypeStrDic.ContainsKey(bone_type))
  427. {
  428. return this.GetIKData(FullBodyIKCtrl.IKBoneTypeStrDic[bone_type]);
  429. }
  430. return null;
  431. }
  432. public T GetIKData<T>(FullBodyIKCtrl.IKBoneType bone_type) where T : IKCtrlData
  433. {
  434. IKCtrlData ikdata = this.GetIKData(bone_type);
  435. if (ikdata != null && ikdata is T)
  436. {
  437. return ikdata as T;
  438. }
  439. return (T)((object)null);
  440. }
  441. public Transform GetSTFlagObj(string name)
  442. {
  443. if (this.m_NameFlagObjpair.ContainsKey(name))
  444. {
  445. return this.m_NameFlagObjpair[name];
  446. }
  447. Transform transform = this.m_STRoot.Find(name);
  448. if (!transform)
  449. {
  450. transform = this.TgtBody.GetBone(name);
  451. if (!transform)
  452. {
  453. Debug.LogErrorFormat("{0}は存在しません", new object[]
  454. {
  455. name
  456. });
  457. return null;
  458. }
  459. }
  460. this.m_NameFlagObjpair.Add(name, transform);
  461. return transform;
  462. }
  463. public bool IsCharaIKAttach(Maid chara)
  464. {
  465. if (!this.IKActive || !this.IsIKExec)
  466. {
  467. return false;
  468. }
  469. foreach (IKCtrlData ikctrlData in this.strIKDataPair.Values)
  470. {
  471. if (ikctrlData.IsIKTargetChara(chara))
  472. {
  473. return true;
  474. }
  475. }
  476. return false;
  477. }
  478. public bool IsTargetIKAttachSelf(bool check_ikend = true)
  479. {
  480. if (!this.IKActive || !this.IsIKExec)
  481. {
  482. return false;
  483. }
  484. using (Dictionary<string, IKCtrlData>.ValueCollection.Enumerator enumerator = this.strIKDataPair.Values.GetEnumerator())
  485. {
  486. while (enumerator.MoveNext())
  487. {
  488. IKCtrlData ik_data = enumerator.Current;
  489. Func<IKCtrlData.IKAttachType, bool> func = delegate(IKCtrlData.IKAttachType attach_type)
  490. {
  491. IKCtrlData.IKSettingData iksettingData = ik_data.GetIKSettingData(attach_type);
  492. foreach (IKCtrlData.IKExecTiming exec_timing in (IKCtrlData.IKExecTiming[])Enum.GetValues(typeof(IKCtrlData.IKExecTiming)))
  493. {
  494. IKCtrlData.IKTargetData targetData = ik_data.GetTargetData(attach_type, exec_timing);
  495. if (targetData.TgtChara)
  496. {
  497. bool flag;
  498. if (check_ikend)
  499. {
  500. flag = (targetData.TgtChara.IKCtrl.IsCharaIKAttach(this.TgtChara) && !targetData.TgtChara.IKCtrl.IsUpdateEnd && !targetData.TgtChara.IKCtrl.IsUpdateLate);
  501. }
  502. else
  503. {
  504. flag = targetData.TgtChara.IKCtrl.IsCharaIKAttach(this.TgtChara);
  505. }
  506. if (flag)
  507. {
  508. return true;
  509. }
  510. }
  511. }
  512. return false;
  513. };
  514. if (func(IKCtrlData.IKAttachType.NewPoint) || func(IKCtrlData.IKAttachType.Rotate))
  515. {
  516. return true;
  517. }
  518. }
  519. }
  520. return false;
  521. }
  522. public void SetPelvisPull(bool pull_on)
  523. {
  524. this.m_IsPelvisPull = pull_on;
  525. }
  526. public static Dictionary<FullBodyIKCtrl.IKBoneType, Transform> GetAllIKBoneDic(Maid chara)
  527. {
  528. if (chara == null)
  529. {
  530. return null;
  531. }
  532. NDebug.Assert(chara.body0 != null, "[body0] it does not end load.");
  533. string text = (!chara.boMAN) ? "Bip01" : "ManBip";
  534. Dictionary<FullBodyIKCtrl.IKBoneType, Transform> dictionary = new Dictionary<FullBodyIKCtrl.IKBoneType, Transform>();
  535. dictionary.Add(FullBodyIKCtrl.IKBoneType.TopFixed, chara.body0.GetBone(text).parent);
  536. dictionary.Add(FullBodyIKCtrl.IKBoneType.Root, chara.body0.GetBone(text));
  537. dictionary.Add(FullBodyIKCtrl.IKBoneType.Pelvis, chara.body0.GetBone(text + " Pelvis"));
  538. dictionary.Add(FullBodyIKCtrl.IKBoneType.Spine0, chara.body0.GetBone(text + " Spine"));
  539. if (!chara.boMAN)
  540. {
  541. dictionary.Add(FullBodyIKCtrl.IKBoneType.Spine1, chara.body0.GetBone(text + " Spine0a"));
  542. dictionary.Add(FullBodyIKCtrl.IKBoneType.Spine2, chara.body0.GetBone(text + " Spine1"));
  543. dictionary.Add(FullBodyIKCtrl.IKBoneType.Spine3, chara.body0.GetBone(text + " Spine1a"));
  544. }
  545. else
  546. {
  547. dictionary.Add(FullBodyIKCtrl.IKBoneType.Spine1, chara.body0.GetBone(text + " Spine1"));
  548. dictionary.Add(FullBodyIKCtrl.IKBoneType.Spine2, chara.body0.GetBone(text + " Spine2"));
  549. }
  550. dictionary.Add(FullBodyIKCtrl.IKBoneType.Head, chara.body0.GetBone(text + " Head"));
  551. dictionary.Add(FullBodyIKCtrl.IKBoneType.Neck, chara.body0.GetBone(text + " Neck"));
  552. dictionary.Add(FullBodyIKCtrl.IKBoneType.UpperArm_R, chara.body0.GetBone(text + " R UpperArm"));
  553. dictionary.Add(FullBodyIKCtrl.IKBoneType.Forearm_R, chara.body0.GetBone(text + " R Forearm"));
  554. dictionary.Add(FullBodyIKCtrl.IKBoneType.Hand_R, chara.body0.GetBone(text + " R Hand"));
  555. dictionary.Add(FullBodyIKCtrl.IKBoneType.UpperArm_L, chara.body0.GetBone(text + " L UpperArm"));
  556. dictionary.Add(FullBodyIKCtrl.IKBoneType.Forearm_L, chara.body0.GetBone(text + " L Forearm"));
  557. dictionary.Add(FullBodyIKCtrl.IKBoneType.Hand_L, chara.body0.GetBone(text + " L Hand"));
  558. dictionary.Add(FullBodyIKCtrl.IKBoneType.Thigh_R, chara.body0.GetBone(text + " R Thigh"));
  559. dictionary.Add(FullBodyIKCtrl.IKBoneType.Calf_R, chara.body0.GetBone(text + " R Calf"));
  560. dictionary.Add(FullBodyIKCtrl.IKBoneType.Foot_R, chara.body0.GetBone(text + " R Foot"));
  561. dictionary.Add(FullBodyIKCtrl.IKBoneType.Thigh_L, chara.body0.GetBone(text + " L Thigh"));
  562. dictionary.Add(FullBodyIKCtrl.IKBoneType.Calf_L, chara.body0.GetBone(text + " L Calf"));
  563. dictionary.Add(FullBodyIKCtrl.IKBoneType.Foot_L, chara.body0.GetBone(text + " L Foot"));
  564. return dictionary;
  565. }
  566. public const float PULL_MIN_VALUE = 0.1f;
  567. public static readonly Dictionary<FullBodyIKCtrl.IKBoneType, string> IKBoneTypeStrDic = new Dictionary<FullBodyIKCtrl.IKBoneType, string>
  568. {
  569. {
  570. FullBodyIKCtrl.IKBoneType.Root,
  571. "体全体"
  572. },
  573. {
  574. FullBodyIKCtrl.IKBoneType.Hand_R,
  575. "右手"
  576. },
  577. {
  578. FullBodyIKCtrl.IKBoneType.Forearm_R,
  579. "右肘"
  580. },
  581. {
  582. FullBodyIKCtrl.IKBoneType.UpperArm_R,
  583. "右肩"
  584. },
  585. {
  586. FullBodyIKCtrl.IKBoneType.Hand_L,
  587. "左手"
  588. },
  589. {
  590. FullBodyIKCtrl.IKBoneType.Forearm_L,
  591. "左肘"
  592. },
  593. {
  594. FullBodyIKCtrl.IKBoneType.UpperArm_L,
  595. "左肩"
  596. },
  597. {
  598. FullBodyIKCtrl.IKBoneType.Foot_R,
  599. "右足"
  600. },
  601. {
  602. FullBodyIKCtrl.IKBoneType.Calf_R,
  603. "右膝"
  604. },
  605. {
  606. FullBodyIKCtrl.IKBoneType.Thigh_R,
  607. "右腿"
  608. },
  609. {
  610. FullBodyIKCtrl.IKBoneType.Foot_L,
  611. "左足"
  612. },
  613. {
  614. FullBodyIKCtrl.IKBoneType.Calf_L,
  615. "左膝"
  616. },
  617. {
  618. FullBodyIKCtrl.IKBoneType.Thigh_L,
  619. "左腿"
  620. }
  621. };
  622. [SerializeField]
  623. private TBody m_TgtBody;
  624. [SerializeField]
  625. private Transform m_IKTgtRoot;
  626. [SerializeField]
  627. private Transform m_STRoot;
  628. [SerializeField]
  629. private FullBodyBipedIK m_FullbodyIK;
  630. private Dictionary<FullBodyIKCtrl.IKBoneType, Transform> m_IKBoneDic = new Dictionary<FullBodyIKCtrl.IKBoneType, Transform>();
  631. [SerializeField]
  632. private BodyCtrlData m_BodyCtrlData;
  633. private Transform m_NippleL;
  634. private Transform m_NippleR;
  635. private Transform m_Mouth;
  636. private Dictionary<string, IKCtrlData> m_StrIKDataPair = new Dictionary<string, IKCtrlData>();
  637. private Dictionary<string, Transform> m_NameFlagObjpair = new Dictionary<string, Transform>();
  638. public bool IKActive = true;
  639. [HideInInspector]
  640. public bool IsUpdateLate;
  641. public Action PostSolverUpdate;
  642. public bool AllForceIK;
  643. public float BlendTime = 0.5f;
  644. private bool m_IsPelvisPull;
  645. public enum IKBoneType
  646. {
  647. TopFixed,
  648. Root,
  649. Spine0,
  650. Spine1,
  651. Spine2,
  652. Spine3,
  653. Neck,
  654. Head,
  655. Clavicle_R,
  656. UpperArm_R,
  657. Forearm_R,
  658. Hand_R,
  659. Clavicle_L,
  660. UpperArm_L,
  661. Forearm_L,
  662. Hand_L,
  663. Pelvis,
  664. Thigh_R,
  665. Calf_R,
  666. Foot_R,
  667. Thigh_L,
  668. Calf_L,
  669. Foot_L
  670. }
  671. }