IKCtrlData.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. using System;
  2. using UnityEngine;
  3. public abstract class IKCtrlData
  4. {
  5. public IKCtrlData(FullBodyIKCtrl ik_ctrl, Transform tgt_bone, bool use_old = false, bool attach_ik = false)
  6. {
  7. this.MyIKCtrl = ik_ctrl;
  8. this.UseOldIK = use_old;
  9. this.m_TargetBone = tgt_bone;
  10. this.m_AttachPointIK = attach_ik;
  11. string text = (!this.MyIKCtrl.TgtChara.boMAN) ? "Bip01" : "ManBip";
  12. string name = this.m_TargetBone.name;
  13. Transform transform = this.MyIKCtrl.IKTgtRoot.Find(name);
  14. if (!transform)
  15. {
  16. transform = new GameObject(name).transform;
  17. transform.transform.SetParent(this.MyIKCtrl.IKTgtRoot, false);
  18. GameObject gameObject = new GameObject("IKTarget");
  19. gameObject.transform.SetParent(transform.transform, false);
  20. this.m_IKTarget = gameObject.transform;
  21. }
  22. else
  23. {
  24. this.m_IKTarget = transform.Find("IKTarget");
  25. }
  26. this.m_BoneTgtPair = new IKCtrlData.BoneTgtPair(this.TargetBone, this.m_IKTarget);
  27. this.IkCmoInit();
  28. this.m_PointIKData.IKCtrl = ik_ctrl;
  29. this.m_RotateIKData.IKCtrl = ik_ctrl;
  30. }
  31. public IKCtrlData.IKSettingData PointIK
  32. {
  33. get
  34. {
  35. return this.m_PointIKData;
  36. }
  37. }
  38. public IKCtrlData.IKSettingData RotateIK
  39. {
  40. get
  41. {
  42. return this.m_RotateIKData;
  43. }
  44. }
  45. public TBody.IKCMO IKCmo
  46. {
  47. get
  48. {
  49. return this.m_IKCmo;
  50. }
  51. }
  52. public bool ForceIK
  53. {
  54. get
  55. {
  56. return this.m_ForceIK;
  57. }
  58. set
  59. {
  60. this.m_ForceIK = (this.m_ForceIKEnable && value);
  61. }
  62. }
  63. public IKCtrlData.PosRotPair BlendPosRot
  64. {
  65. get
  66. {
  67. return this.m_BlendPosRot;
  68. }
  69. }
  70. public bool IsIKExec
  71. {
  72. get
  73. {
  74. return this.m_PointIKData.IsIKExec || this.m_RotateIKData.IsIKExec || this.ForceIK;
  75. }
  76. }
  77. public bool IsIKExecTruth
  78. {
  79. get
  80. {
  81. return this.GetIKExecTruth(IKCtrlData.IKAttachType.NewPoint) || this.GetIKExecTruth(IKCtrlData.IKAttachType.Rotate);
  82. }
  83. }
  84. public bool IsWeightOver0
  85. {
  86. get
  87. {
  88. return this.PositionWeight * this.m_PosWeightBase > 0f || this.RotationWeight * this.m_RotWeightBase > 0f;
  89. }
  90. }
  91. public bool OldIkExec
  92. {
  93. get
  94. {
  95. return this.m_PointIKData.IsIKExec && this.m_PointIKData.IsOldIK;
  96. }
  97. }
  98. public bool AttachPointIK
  99. {
  100. get
  101. {
  102. return this.m_AttachPointIK;
  103. }
  104. }
  105. public Transform IKTarget
  106. {
  107. get
  108. {
  109. return this.m_IKTarget;
  110. }
  111. }
  112. public IKCtrlData.Vec3Enable OffsetEnable
  113. {
  114. get
  115. {
  116. return this.m_OffsetEnable;
  117. }
  118. }
  119. public virtual Transform TargetBone
  120. {
  121. get
  122. {
  123. return this.m_TargetBone;
  124. }
  125. }
  126. public bool IsSelfIKAttach { get; protected set; }
  127. public Transform[] ChainBones
  128. {
  129. get
  130. {
  131. return this.m_ChainBones;
  132. }
  133. }
  134. public abstract float PositionWeight { get; set; }
  135. public abstract float RotationWeight { get; set; }
  136. public static bool operator true(IKCtrlData data)
  137. {
  138. return data != null;
  139. }
  140. public static bool operator false(IKCtrlData data)
  141. {
  142. return data == null;
  143. }
  144. public static bool operator !(IKCtrlData data)
  145. {
  146. return data == null;
  147. }
  148. private void IkCmoInit()
  149. {
  150. if (!this.UseOldIK)
  151. {
  152. return;
  153. }
  154. this.IKCmo.Init(this.TargetBone.parent.parent, this.TargetBone.parent, this.TargetBone, this.MyIKCtrl.TgtBody);
  155. }
  156. public void SetFlagTarget(IKCtrlData.IKAttachType attach_type, string name)
  157. {
  158. if (this.MyIKCtrl.TgtChara.boMAN)
  159. {
  160. this.GetFlagData(attach_type).Target = this.MyIKCtrl.TgtBody.GetBone(name);
  161. }
  162. else
  163. {
  164. this.GetFlagData(attach_type).Target = this.MyIKCtrl.GetSTFlagObj(name);
  165. }
  166. }
  167. public void SetIKSetting(IKCtrlData.IKAttachType attachType, IKCtrlData.IKExecTiming timing, Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Vector3 f_vecOffset, bool do_animation = false)
  168. {
  169. this.SetIKSetting(attachType, timing, tgt_maid, slot_no, attach_name, axis_bone, null, f_vecOffset, do_animation);
  170. }
  171. public void SetIKSetting(IKCtrlData.IKAttachType attachType, IKCtrlData.IKExecTiming timing, Maid tgt_maid, Transform target, Vector3 f_vecOffset, bool do_animation = false)
  172. {
  173. this.SetIKSetting(attachType, timing, tgt_maid, -1, string.Empty, null, target, f_vecOffset, do_animation);
  174. }
  175. public void SetIKSetting(IKCtrlData.IKAttachType attachType, IKCtrlData.IKExecTiming timing, Transform target, Vector3 f_vecOffset, bool do_animation = false)
  176. {
  177. this.SetIKSetting(attachType, timing, null, -1, string.Empty, null, target, f_vecOffset, do_animation);
  178. }
  179. public void SetIKSetting(IKCtrlData.IKAttachType attachType, IKCtrlData.IKExecTiming timing, Maid tgt_maid, string bone_name, Transform target, Vector3 f_vecOffset, bool do_animation = false)
  180. {
  181. this.SetIKSetting(attachType, timing, tgt_maid, -1, bone_name, null, target, f_vecOffset, do_animation);
  182. }
  183. public virtual void SetIKSetting(IKCtrlData.IKAttachType attachType, IKCtrlData.IKExecTiming timing, Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Transform target, Vector3 f_vecOffset, bool do_animation = false)
  184. {
  185. this.GetIKSettingData(attachType).ChangeIKType(attachType);
  186. if (this.GetIKSettingData(attachType).MyType != attachType)
  187. {
  188. return;
  189. }
  190. this.MyIKCtrl.IKActive = true;
  191. this.BlendPosRot.Copy(this.m_lastIKPosRot);
  192. this.m_AnimPosRotOffset.Reset();
  193. this.m_FirstPosRotOffset.Reset();
  194. this.m_FirstTgtPosRot.Reset();
  195. if (!target && !string.IsNullOrEmpty(attach_name))
  196. {
  197. this.IsSelfIKAttach |= (tgt_maid == this.MyIKCtrl.TgtChara);
  198. }
  199. this.GetIKSettingData(attachType).SetIKSetting(timing, tgt_maid, slot_no, attach_name, axis_bone, target, f_vecOffset, do_animation);
  200. this.GetFlagData(attachType).IsFlagChange();
  201. }
  202. public virtual void SetPullState(bool pull_on)
  203. {
  204. }
  205. public virtual void TagetTransCpy()
  206. {
  207. this.m_BoneTgtPair.Copy();
  208. float num = 0f;
  209. this.RotationWeight = num;
  210. this.PositionWeight = num;
  211. }
  212. public virtual void ApplyIKSetting()
  213. {
  214. if (this.ForceIK)
  215. {
  216. this.GetIKSettingData(IKCtrlData.IKAttachType.NewPoint).ChangeIKType(IKCtrlData.IKAttachType.NewPoint);
  217. }
  218. if (!this.MyIKCtrl.IsUpdateEnd)
  219. {
  220. this.m_EachOtherIK = false;
  221. this.ForceIK |= this.MyIKCtrl.AllForceIK;
  222. }
  223. this.ApplyIKSetting(this.GetIKSettingData(IKCtrlData.IKAttachType.NewPoint));
  224. this.ApplyIKSetting(this.GetIKSettingData(IKCtrlData.IKAttachType.Rotate));
  225. }
  226. private void ApplyIKSetting(IKCtrlData.IKSettingData data)
  227. {
  228. if (this.MyIKCtrl.IsUpdateLate)
  229. {
  230. return;
  231. }
  232. if (data.curTargetData.TgtChara && data.curTargetData.TgtChara != this.MyIKCtrl.TgtChara)
  233. {
  234. IKCtrlData ikdata = data.curTargetData.TgtChara.IKCtrl.GetIKData(data.curTargetData.Tgt_AttachName);
  235. if (ikdata != null && ikdata.IsIKExec)
  236. {
  237. IKCtrlData.IKSettingData iksettingData = ikdata.GetIKSettingData(data.MyType);
  238. this.m_EachOtherIK = this.IsEachBoneIK(iksettingData);
  239. }
  240. if (!data.curTargetData.TgtChara.body0.LateUpdateEnd && !this.MyIKCtrl.TgtBody.LateUpdateEnd)
  241. {
  242. this.MyIKCtrl.IsUpdateLate = true;
  243. if (data.curTargetData.TgtChara.IKCtrl.IsIKExec)
  244. {
  245. FullBodyIKCtrl ikctrl = data.curTargetData.TgtChara.IKCtrl;
  246. ikctrl.PostSolverUpdate = (Action)Delegate.Combine(ikctrl.PostSolverUpdate, new Action(this.MyIKCtrl.LateIKUpdate));
  247. }
  248. else
  249. {
  250. TBody body = data.curTargetData.TgtChara.body0;
  251. body.OnLateUpdateEnd = (Action)Delegate.Combine(body.OnLateUpdateEnd, new Action(this.MyIKCtrl.LateIKUpdate));
  252. }
  253. return;
  254. }
  255. }
  256. if (data.BlendType != IKCtrlData.IKBlendType.Not_Blend && data.BlendTime <= 0f)
  257. {
  258. data.BlendReset(false);
  259. }
  260. data.DoSetOffset = false;
  261. data.IsIKExec = true;
  262. Vector3 position = this.TargetBone.position;
  263. Quaternion rotation = this.TargetBone.rotation;
  264. if (this.GetFlagData(data.MyType).IsEnable)
  265. {
  266. if (!this.GetFlagData(data.MyType).BlendCtrlSelf)
  267. {
  268. IKCtrlData.IKExecTiming curExecTiming = data.changeFlagData.curExecTiming;
  269. this.MultiTgtDataToPosRot(data, IKCtrlData.IKExecTiming.Normal, curExecTiming, ref position, ref rotation);
  270. data.DoSetOffset = true;
  271. data.IsIKExec = true;
  272. }
  273. else
  274. {
  275. IKCtrlData.IKExecTiming lastExecTiming = data.changeFlagData.lastExecTiming;
  276. if (this.GetFlagData(data.MyType).IsFlagChange())
  277. {
  278. IKCtrlData.IKTargetData tgtData = data.GetTgtData(lastExecTiming);
  279. data.BlendReset(true);
  280. data.curTargetData.SetLastTarget(tgtData.Tgt_AttachName, tgtData.TgtChara, tgtData.Target, tgtData.TgtOffset);
  281. data.CheckBlendType(true);
  282. if (data.MyType == IKCtrlData.IKAttachType.Rotate)
  283. {
  284. this.BlendPosRot.rot = this.m_lastIKPosRot.rot;
  285. }
  286. else
  287. {
  288. this.BlendPosRot.pos = this.m_lastIKPosRot.pos;
  289. }
  290. this.SetIKPosRot(data, ref position, ref rotation, false, IKCtrlData.IKExecTiming.Normal);
  291. }
  292. else
  293. {
  294. this.SetIKPosRot(data, ref position, ref rotation, false, IKCtrlData.IKExecTiming.Normal);
  295. }
  296. }
  297. }
  298. else
  299. {
  300. this.SetIKPosRot(data, ref position, ref rotation, false, IKCtrlData.IKExecTiming.Normal);
  301. }
  302. if (data.IsIKExec)
  303. {
  304. if (data.FirstFrame && !data.BlendNow)
  305. {
  306. if (data.IsPointAttach)
  307. {
  308. this.m_FirstTgtPosRot.pos = position;
  309. }
  310. else
  311. {
  312. this.m_FirstTgtPosRot.rot = rotation;
  313. }
  314. }
  315. this.SetTargetTransform(data, position, rotation);
  316. if (this.m_EachOtherIK && !data.curTargetData.TgtChara.IKCtrl.IsUpdateEnd)
  317. {
  318. if (data.IsPointAttach)
  319. {
  320. this.PositionWeight *= 0.5f;
  321. }
  322. else
  323. {
  324. this.RotationWeight *= 0.5f;
  325. }
  326. }
  327. if (data.DoAnimation && !data.BlendNow)
  328. {
  329. if (!data.DoSetPosRot)
  330. {
  331. Transform targetBone = this.TargetBone;
  332. if (data.IsPointAttach)
  333. {
  334. if (!data.FirstFrame)
  335. {
  336. this.IKTarget.position += targetBone.position - this.m_FirstTgtPosRot.pos - this.m_FirstPosRotOffset.pos;
  337. }
  338. else
  339. {
  340. this.m_FirstPosRotOffset.pos = targetBone.position - this.m_FirstTgtPosRot.pos;
  341. }
  342. }
  343. else if (!data.FirstFrame)
  344. {
  345. this.IKTarget.rotation *= targetBone.rotation * Quaternion.Inverse(this.m_FirstTgtPosRot.rot) * Quaternion.Inverse(this.m_FirstPosRotOffset.rot);
  346. }
  347. else
  348. {
  349. this.m_FirstPosRotOffset.rot = targetBone.rotation * Quaternion.Inverse(this.m_FirstTgtPosRot.rot);
  350. }
  351. }
  352. }
  353. else
  354. {
  355. this.m_AnimPosRotOffset.Reset();
  356. }
  357. if (!data.BlendNow)
  358. {
  359. data.FirstFrame = false;
  360. }
  361. if (data.curTargetData.IsTgtAxis)
  362. {
  363. KasaiUtility.DrawAxis(position, rotation, 0.125f);
  364. }
  365. if (!data.DoSetPosRot && data.BlendType != IKCtrlData.IKBlendType.Not_Blend)
  366. {
  367. data.ElapsedTime += Time.deltaTime;
  368. if (data.ElapsedTime >= data.BlendTime)
  369. {
  370. data.BlendReset(false);
  371. }
  372. }
  373. data.DoSetPosRot = true;
  374. }
  375. }
  376. private void SetIKPosRot(IKCtrlData.IKSettingData setting_data, ref Vector3 pos, ref Quaternion rot, bool include_offset = false, IKCtrlData.IKExecTiming flag_type = IKCtrlData.IKExecTiming.Normal)
  377. {
  378. this.SetIKPosRot(setting_data, setting_data.GetTgtData(flag_type), ref pos, ref rot, include_offset);
  379. }
  380. private void SetIKPosRot(IKCtrlData.IKSettingData setting_data, IKCtrlData.IKTargetData tgt_data, ref Vector3 pos, ref Quaternion rot, bool include_offset = false)
  381. {
  382. if (tgt_data.Target != null)
  383. {
  384. pos = tgt_data.Target.position;
  385. rot = tgt_data.Target.rotation;
  386. }
  387. else if (tgt_data.Tgt_AttachName != string.Empty)
  388. {
  389. if (this.MyIKCtrl.TgtBody.goSlot[tgt_data.Tgt_AttachSlot].morph != null)
  390. {
  391. if (tgt_data.TgtChara != null && tgt_data.TgtChara.body0 != null)
  392. {
  393. tgt_data.TgtChara.body0.SkinMeshUpdateOnce();
  394. Vector3 vector;
  395. tgt_data.TgtChara.body0.goSlot[tgt_data.Tgt_AttachSlot].morph.GetAttachPoint(tgt_data.Tgt_AttachName, out pos, out rot, out vector, false);
  396. if (setting_data.MyType == IKCtrlData.IKAttachType.NewPoint && tgt_data.AxisTgt)
  397. {
  398. rot = tgt_data.AxisTgt.rotation;
  399. }
  400. }
  401. else
  402. {
  403. setting_data.IsIKExec = false;
  404. tgt_data.Tgt_AttachName = string.Empty;
  405. }
  406. }
  407. }
  408. else if (this.ForceIK)
  409. {
  410. pos = this.m_IKTarget.position;
  411. rot = this.m_IKTarget.rotation;
  412. }
  413. else if (setting_data.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
  414. {
  415. pos = this.BlendPosRot.pos;
  416. rot = this.BlendPosRot.rot;
  417. }
  418. else
  419. {
  420. setting_data.IsIKExec = false;
  421. }
  422. if (setting_data.IsIKExec && include_offset)
  423. {
  424. if (setting_data.IsPointAttach)
  425. {
  426. Vector3 start = pos;
  427. switch (this.posOffsetType)
  428. {
  429. case IKCtrlData.PosOffsetType.OffsetTarget:
  430. pos += rot * tgt_data.TgtOffset;
  431. break;
  432. case IKCtrlData.PosOffsetType.OffsetWorld:
  433. pos += tgt_data.TgtOffset;
  434. break;
  435. case IKCtrlData.PosOffsetType.OffsetBone:
  436. pos -= this.TargetBone.rotation * tgt_data.TgtOffset;
  437. break;
  438. }
  439. Debug.DrawLine(start, pos, Color.white);
  440. }
  441. else
  442. {
  443. rot *= Quaternion.Euler(tgt_data.TgtOffset);
  444. }
  445. }
  446. }
  447. protected bool IsEachBoneIK(IKCtrlData.IKSettingData data)
  448. {
  449. return data.IsIKExec && data.curTargetData.Target == this.TargetBone;
  450. }
  451. private void MultiTgtDataToPosRot(IKCtrlData.IKSettingData data, IKCtrlData.IKExecTiming from, IKCtrlData.IKExecTiming to, ref Vector3 pos, ref Quaternion rot)
  452. {
  453. IKCtrlData.IKTargetData tgtData = data.GetTgtData(from);
  454. IKCtrlData.IKTargetData tgtData2 = data.GetTgtData(to);
  455. Vector3 a = pos;
  456. Quaternion a2 = rot;
  457. this.SetIKPosRot(data, tgtData, ref a, ref a2, true);
  458. Vector3 b = pos;
  459. Quaternion b2 = rot;
  460. this.SetIKPosRot(data, tgtData2, ref b, ref b2, true);
  461. float blendValue = this.GetFlagData(data.MyType).GetBlendValue(from, to);
  462. if (data.IsPointAttach)
  463. {
  464. if (!tgtData.ExistTgt)
  465. {
  466. this.m_PosWeightBase = ((!tgtData2.ExistTgt) ? 0f : blendValue);
  467. }
  468. else
  469. {
  470. this.m_PosWeightBase = 1f;
  471. }
  472. pos = Vector3.Lerp(a, b, blendValue);
  473. }
  474. else
  475. {
  476. if (!tgtData.ExistTgt)
  477. {
  478. this.m_RotWeightBase = ((!tgtData2.ExistTgt) ? 0f : blendValue);
  479. }
  480. else
  481. {
  482. this.m_RotWeightBase = 1f;
  483. }
  484. rot = Quaternion.Lerp(a2, b2, blendValue);
  485. }
  486. }
  487. protected virtual void SetTargetTransform(IKCtrlData.IKSettingData data, Vector3 pos, Quaternion rot)
  488. {
  489. IKCtrlData.IKTargetData curTargetData = data.curTargetData;
  490. switch (data.MyType)
  491. {
  492. case IKCtrlData.IKAttachType.Point:
  493. pos += this.m_AnimPosRotOffset.pos;
  494. Debug.DrawLine(pos, pos + rot * Vector3.forward * 0.2f, Color.cyan);
  495. if (!data.DoSetOffset)
  496. {
  497. this.IkCmoPorc(pos, data.curTargetData.TgtOffset);
  498. }
  499. else
  500. {
  501. this.IkCmoPorc(pos, Vector3.zero);
  502. }
  503. break;
  504. case IKCtrlData.IKAttachType.Rotate:
  505. rot *= this.m_AnimPosRotOffset.rot;
  506. if (!data.DoSetOffset)
  507. {
  508. rot *= Quaternion.Euler(data.curTargetData.TgtOffset);
  509. }
  510. rot = Quaternion.Euler(this.GetIKEnable(data.MyType).GetEnable(this.TargetBone.eulerAngles, rot.eulerAngles, false));
  511. this.m_IKTarget.rotation = rot;
  512. if (data.BlendType == IKCtrlData.IKBlendType.IK_To_IK)
  513. {
  514. this.m_IKTarget.rotation = Quaternion.Lerp(this.BlendPosRot.rot, this.m_IKTarget.rotation, data.BlendWeight);
  515. this.RotationWeight = this.m_RotWeightBase;
  516. }
  517. else if (data.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
  518. {
  519. this.RotationWeight = this.m_RotWeightBase * (1f - data.BlendWeight);
  520. }
  521. else
  522. {
  523. this.RotationWeight = this.m_RotWeightBase * data.BlendWeight;
  524. }
  525. break;
  526. case IKCtrlData.IKAttachType.NewPoint:
  527. pos += this.m_AnimPosRotOffset.pos;
  528. if (!data.DoSetOffset)
  529. {
  530. Vector3 start = pos;
  531. switch (this.posOffsetType)
  532. {
  533. case IKCtrlData.PosOffsetType.OffsetTarget:
  534. pos += rot * curTargetData.TgtOffset;
  535. break;
  536. case IKCtrlData.PosOffsetType.OffsetWorld:
  537. pos += curTargetData.TgtOffset;
  538. break;
  539. case IKCtrlData.PosOffsetType.OffsetBone:
  540. pos -= this.TargetBone.rotation * curTargetData.TgtOffset;
  541. break;
  542. }
  543. Debug.DrawLine(start, pos, Color.white);
  544. }
  545. pos = this.GetIKEnable(data.MyType).GetEnable(this.TargetBone.position, pos, false);
  546. this.m_IKTarget.position = pos;
  547. if (data.BlendType == IKCtrlData.IKBlendType.IK_To_IK)
  548. {
  549. this.m_IKTarget.position = Vector3.Lerp(this.BlendPosRot.pos, this.m_IKTarget.position, data.BlendWeight);
  550. this.PositionWeight = this.m_PosWeightBase;
  551. }
  552. else if (data.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
  553. {
  554. this.PositionWeight = this.m_PosWeightBase * (1f - data.BlendWeight);
  555. }
  556. else
  557. {
  558. this.PositionWeight = this.m_PosWeightBase * data.BlendWeight;
  559. }
  560. break;
  561. }
  562. data.DoSetOffset = true;
  563. }
  564. private void IkCmoPorc(Vector3 tgt, Vector3 vechand_offset)
  565. {
  566. if (!this.UseOldIK)
  567. {
  568. return;
  569. }
  570. for (int i = 0; i < 3; i++)
  571. {
  572. this.IKCmo.Porc(this.TargetBone.parent.parent, this.TargetBone.parent, this.TargetBone, tgt, vechand_offset, this);
  573. }
  574. }
  575. public virtual void Update()
  576. {
  577. }
  578. public virtual void LateUpdate()
  579. {
  580. this.SaveLastBonePosRot();
  581. this.GetIKSettingData(IKCtrlData.IKAttachType.NewPoint).DoSetPosRot = (this.GetIKSettingData(IKCtrlData.IKAttachType.Rotate).DoSetPosRot = false);
  582. }
  583. public virtual void SaveLastBonePosRot()
  584. {
  585. this.m_lastIKPosRot.Copy(this.m_TargetBone);
  586. }
  587. public virtual void Detach(IKCtrlData.IKAttachType attachType)
  588. {
  589. this.ForceIK = false;
  590. this.m_BoneTgtPair.PosOffset = Vector3.zero;
  591. this.IsSelfIKAttach = false;
  592. this.BlendPosRot.Copy(this.m_lastIKPosRot);
  593. this.GetFlagData(attachType).Reset();
  594. this.GetIKSettingData(attachType).Detach();
  595. }
  596. public IKCtrlData.IKSettingData GetIKSettingData(IKCtrlData.IKAttachType attach_type)
  597. {
  598. if (attach_type == IKCtrlData.IKAttachType.Rotate)
  599. {
  600. return this.m_RotateIKData;
  601. }
  602. return this.m_PointIKData;
  603. }
  604. public IKCtrlData.ChangeFlagData GetFlagData(IKCtrlData.IKAttachType attach_type)
  605. {
  606. return this.GetIKSettingData(attach_type).changeFlagData;
  607. }
  608. public IKCtrlData.IKTargetData GetTargetData(IKCtrlData.IKAttachType attach_type)
  609. {
  610. return this.GetIKSettingData(attach_type).curTargetData;
  611. }
  612. public IKCtrlData.IKTargetData GetTargetData(IKCtrlData.IKAttachType attach_type, IKCtrlData.IKExecTiming exec_timing)
  613. {
  614. return this.GetIKSettingData(attach_type).GetTgtData(exec_timing);
  615. }
  616. private bool IsIKTargetChara(IKCtrlData.IKAttachType attach_type, Maid chara)
  617. {
  618. IKCtrlData.IKSettingData iksettingData = this.GetIKSettingData(attach_type);
  619. foreach (IKCtrlData.IKExecTiming timing in (IKCtrlData.IKExecTiming[])Enum.GetValues(typeof(IKCtrlData.IKExecTiming)))
  620. {
  621. IKCtrlData.IKTargetData tgtData = iksettingData.GetTgtData(timing);
  622. if (tgtData.TgtChara == chara)
  623. {
  624. return true;
  625. }
  626. }
  627. return false;
  628. }
  629. public bool IsIKTargetChara(Maid chara)
  630. {
  631. return this.IsIKTargetChara(IKCtrlData.IKAttachType.NewPoint, chara) || this.IsIKTargetChara(IKCtrlData.IKAttachType.Rotate, chara);
  632. }
  633. public IKCtrlData.Vec3Enable GetIKEnable(IKCtrlData.IKAttachType attach_type)
  634. {
  635. return this.GetIKSettingData(attach_type).offsetEnable;
  636. }
  637. public bool GetIKExecTruth(IKCtrlData.IKAttachType attach_type)
  638. {
  639. IKCtrlData.IKSettingData iksettingData = (attach_type != IKCtrlData.IKAttachType.Rotate) ? this.PointIK : this.RotateIK;
  640. float num = (attach_type != IKCtrlData.IKAttachType.Rotate) ? this.PositionWeight : this.RotationWeight;
  641. bool flag = iksettingData.IsIKExec && num > 0f;
  642. if (iksettingData.changeFlagData.IsEnable)
  643. {
  644. flag &= (iksettingData.changeFlagData.GetFlagValue() > 0f);
  645. }
  646. return flag;
  647. }
  648. [SerializeField]
  649. [Header("位置IK")]
  650. private IKCtrlData.IKSettingData m_PointIKData = new IKCtrlData.IKSettingData(IKCtrlData.IKAttachType.NewPoint);
  651. [SerializeField]
  652. [Header("回転IK")]
  653. private IKCtrlData.IKSettingData m_RotateIKData = new IKCtrlData.IKSettingData(IKCtrlData.IKAttachType.Rotate);
  654. private TBody.IKCMO m_IKCmo = new TBody.IKCMO();
  655. private IKCtrlData.PosRotPair m_BlendPosRot = new IKCtrlData.PosRotPair();
  656. [SerializeField]
  657. [Space]
  658. private IKCtrlData.PosRotPair m_AnimPosRotOffset = new IKCtrlData.PosRotPair();
  659. private IKCtrlData.PosRotPair m_FirstPosRotOffset = new IKCtrlData.PosRotPair();
  660. [SerializeField]
  661. private bool m_AttachPointIK;
  662. [SerializeField]
  663. private Transform m_TargetBone;
  664. [SerializeField]
  665. private Transform m_IKTarget;
  666. [SerializeField]
  667. private bool m_DrawLine = true;
  668. private IKCtrlData.BoneTgtPair m_BoneTgtPair;
  669. protected IKCtrlData.PosRotPair m_FirstTgtPosRot = new IKCtrlData.PosRotPair();
  670. protected IKCtrlData.PosRotPair m_lastIKPosRot = new IKCtrlData.PosRotPair();
  671. [SerializeField]
  672. [Range(0f, 1f)]
  673. protected float m_PosWeightBase = 1f;
  674. [SerializeField]
  675. [Range(0f, 1f)]
  676. protected float m_RotWeightBase = 1f;
  677. [SerializeField]
  678. protected bool m_ForceIK;
  679. protected bool m_ForceIKEnable;
  680. protected bool m_EachOtherIK;
  681. protected IKCtrlData.Vec3Enable m_OffsetEnable = new IKCtrlData.Vec3Enable();
  682. [Space]
  683. public IKCtrlData.PosOffsetType posOffsetType;
  684. public readonly FullBodyIKCtrl MyIKCtrl;
  685. public readonly bool UseOldIK;
  686. protected Transform[] m_ChainBones;
  687. public enum IKAttachType
  688. {
  689. Point,
  690. Rotate,
  691. NewPoint
  692. }
  693. public enum IKBlendType
  694. {
  695. Detach_To_IK,
  696. IK_To_IK,
  697. IK_To_Detach,
  698. Not_Blend
  699. }
  700. public enum PosOffsetType
  701. {
  702. OffsetTarget,
  703. OffsetWorld,
  704. OffsetBone
  705. }
  706. public enum IKExecTiming
  707. {
  708. Normal,
  709. FlagPositive,
  710. FlagNegative = -1
  711. }
  712. [Serializable]
  713. public class Vec3Enable
  714. {
  715. public bool AnyDisable
  716. {
  717. get
  718. {
  719. return !this.EnableX || !this.EnableY || !this.EnableZ;
  720. }
  721. }
  722. public Vector3 GetEnable(Vector3 pos, bool inverse = false)
  723. {
  724. if (this.EnableX == inverse)
  725. {
  726. pos.x = 0f;
  727. }
  728. if (this.EnableY == inverse)
  729. {
  730. pos.y = 0f;
  731. }
  732. if (this.EnableZ == inverse)
  733. {
  734. pos.z = 0f;
  735. }
  736. return pos;
  737. }
  738. public Vector3 GetEnable(Vector3 from, Vector3 to, bool inverse = false)
  739. {
  740. if (this.EnableX == inverse)
  741. {
  742. to.x = from.x;
  743. }
  744. if (this.EnableY == inverse)
  745. {
  746. to.y = from.y;
  747. }
  748. if (this.EnableZ == inverse)
  749. {
  750. to.z = from.z;
  751. }
  752. return to;
  753. }
  754. public void Recet()
  755. {
  756. this.EnableX = (this.EnableY = (this.EnableZ = true));
  757. }
  758. public void Copy(IKCtrlData.Vec3Enable cpy)
  759. {
  760. this.EnableX = cpy.EnableX;
  761. this.EnableY = cpy.EnableY;
  762. this.EnableZ = cpy.EnableZ;
  763. }
  764. public string OffEnableToStr()
  765. {
  766. if (!this.AnyDisable)
  767. {
  768. return string.Empty;
  769. }
  770. string text = " disable=";
  771. if (!this.EnableX)
  772. {
  773. text += "x";
  774. }
  775. if (!this.EnableY)
  776. {
  777. if (!this.EnableX)
  778. {
  779. text += ",";
  780. }
  781. text += "y";
  782. }
  783. if (!this.EnableZ)
  784. {
  785. if (!this.EnableX || !this.EnableY)
  786. {
  787. text += ",";
  788. }
  789. text += "z";
  790. }
  791. return text;
  792. }
  793. public bool EnableX = true;
  794. public bool EnableY = true;
  795. public bool EnableZ = true;
  796. }
  797. [Serializable]
  798. public class PosRotPair
  799. {
  800. public void Reset()
  801. {
  802. this.pos = Vector3.zero;
  803. this.rot = new Quaternion(0f, 0f, 0f, 1f);
  804. }
  805. public void Copy(IKCtrlData.PosRotPair pair)
  806. {
  807. this.pos = pair.pos;
  808. this.rot = pair.rot;
  809. }
  810. public void Copy(Transform transform)
  811. {
  812. this.pos = transform.position;
  813. this.rot = transform.rotation;
  814. }
  815. public void DrawAxis()
  816. {
  817. KasaiUtility.DrawAxis(this.pos, this.rot, 0.0625f);
  818. }
  819. public Vector3 pos = Vector3.zero;
  820. public Quaternion rot = new Quaternion(0f, 0f, 0f, 1f);
  821. }
  822. public class BoneTgtPair
  823. {
  824. public BoneTgtPair(Transform bone, Transform target)
  825. {
  826. this.Bone = bone;
  827. this.Target = target;
  828. }
  829. public void Copy()
  830. {
  831. this.Target.position = this.Bone.position + this.PosOffset;
  832. this.Target.rotation = this.Bone.rotation;
  833. }
  834. public readonly Transform Bone;
  835. public readonly Transform Target;
  836. public Vector3 PosOffset = Vector3.zero;
  837. }
  838. [Serializable]
  839. public class ChangeFlagData
  840. {
  841. public bool IsEnable
  842. {
  843. get
  844. {
  845. return this.Target != null;
  846. }
  847. }
  848. public IKCtrlData.IKExecTiming lastExecTiming { get; private set; }
  849. public IKCtrlData.IKExecTiming curExecTiming
  850. {
  851. get
  852. {
  853. if (this.GetFlagValue() > 0f)
  854. {
  855. return IKCtrlData.IKExecTiming.FlagPositive;
  856. }
  857. if (this.GetFlagValue() < 0f)
  858. {
  859. return IKCtrlData.IKExecTiming.FlagNegative;
  860. }
  861. return IKCtrlData.IKExecTiming.Normal;
  862. }
  863. }
  864. public float GetFlagValue()
  865. {
  866. if (!this.Target)
  867. {
  868. return 0f;
  869. }
  870. return Vector3.Dot(this.Target.localPosition, this.Axis) / this.OnValue;
  871. }
  872. public float GetBlendValue(IKCtrlData.IKExecTiming from, IKCtrlData.IKExecTiming to)
  873. {
  874. if (from == to)
  875. {
  876. return 1f;
  877. }
  878. return Mathf.InverseLerp((float)from, (float)to, this.GetFlagValue());
  879. }
  880. public bool IsFlagChange()
  881. {
  882. if (!this.Target)
  883. {
  884. return false;
  885. }
  886. IKCtrlData.IKExecTiming lastExecTiming = this.lastExecTiming;
  887. this.lastExecTiming = this.curExecTiming;
  888. return lastExecTiming != this.lastExecTiming;
  889. }
  890. public void Reset()
  891. {
  892. this.Target = null;
  893. this.lastExecTiming = IKCtrlData.IKExecTiming.Normal;
  894. this.BlendCtrlSelf = false;
  895. }
  896. public Transform Target;
  897. public Vector3 Axis = Vector3.forward;
  898. public float OnValue = 0.1f;
  899. [HideInInspector]
  900. public bool BlendCtrlSelf;
  901. }
  902. [Serializable]
  903. public class IKTargetData
  904. {
  905. public IKTargetData(bool is_for_point)
  906. {
  907. this.IsForPointTarget = is_for_point;
  908. }
  909. public string lastAttachName
  910. {
  911. get
  912. {
  913. return this.m_LastAttachName;
  914. }
  915. }
  916. public Transform lastTarget
  917. {
  918. get
  919. {
  920. return this.m_LastTarget;
  921. }
  922. }
  923. public Maid lastTgtChara
  924. {
  925. get
  926. {
  927. return this.m_LastTgtChara;
  928. }
  929. }
  930. public Vector3 lastOffset
  931. {
  932. get
  933. {
  934. return this.m_LastOffset;
  935. }
  936. }
  937. public bool ExistTgt
  938. {
  939. get
  940. {
  941. return this.Target != null || !string.IsNullOrEmpty(this.Tgt_AttachName);
  942. }
  943. }
  944. public bool IsEachOtherIK(bool check_update = false)
  945. {
  946. return this.TgtChara && this.TgtChara.IKCtrl.IsIKExec && this.TgtChara.IKCtrl.IsUpdateEnd == check_update;
  947. }
  948. public void SaveLastTarget()
  949. {
  950. this.m_LastAttachName = this.Tgt_AttachName;
  951. this.m_LastTgtChara = this.TgtChara;
  952. this.m_LastTarget = this.Target;
  953. this.m_LastOffset = this.TgtOffset;
  954. }
  955. public void SetLastTarget(string attach_name, Maid maid, Transform target, Vector3 offset)
  956. {
  957. this.m_LastAttachName = attach_name;
  958. this.m_LastTgtChara = maid;
  959. this.m_LastTarget = target;
  960. this.m_LastOffset = offset;
  961. }
  962. public void SetIKSetting(Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Transform target, Vector3 f_vecOffset)
  963. {
  964. this.SetLastTarget(this.Tgt_AttachName, this.TgtChara, this.Target, this.TgtOffset);
  965. this.TgtChara = tgt_maid;
  966. this.Tgt_AttachSlot = slot_no;
  967. this.Tgt_AttachName = attach_name;
  968. this.Target = target;
  969. this.AxisTgt = axis_bone;
  970. if (this.IsForPointTarget)
  971. {
  972. this.TgtOffset = f_vecOffset;
  973. }
  974. else
  975. {
  976. this.TgtOffset = KasaiUtility.AngleRimmit360(f_vecOffset);
  977. }
  978. this.IsIKExec = true;
  979. }
  980. public void Detach()
  981. {
  982. this.SetLastTarget(this.Tgt_AttachName, this.TgtChara, this.Target, this.TgtOffset);
  983. this.TgtChara = null;
  984. this.Tgt_AttachSlot = -1;
  985. this.Tgt_AttachName = string.Empty;
  986. this.Target = null;
  987. this.AxisTgt = null;
  988. this.TgtOffset = Vector3.zero;
  989. }
  990. private string m_LastAttachName = string.Empty;
  991. private Transform m_LastTarget;
  992. private Maid m_LastTgtChara;
  993. private Vector3 m_LastOffset = Vector3.zero;
  994. public Transform Target;
  995. public Vector3 TgtOffset;
  996. public int Tgt_AttachSlot = -1;
  997. public string Tgt_AttachName = string.Empty;
  998. public Maid TgtChara;
  999. public bool IsTgtAxis;
  1000. public bool IsIKExec;
  1001. public Transform AxisTgt;
  1002. public readonly bool IsForPointTarget;
  1003. }
  1004. [Serializable]
  1005. public class IKSettingData
  1006. {
  1007. public IKSettingData(IKCtrlData.IKAttachType type)
  1008. {
  1009. this.MyType = type;
  1010. this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
  1011. this.m_NormalTgtData = new IKCtrlData.IKTargetData(this.IsPointAttach);
  1012. this.m_FlagPositiveTgtData = new IKCtrlData.IKTargetData(this.IsPointAttach);
  1013. this.m_FlagNegativeTgtData = new IKCtrlData.IKTargetData(this.IsPointAttach);
  1014. }
  1015. public IKCtrlData.Vec3Enable offsetEnable
  1016. {
  1017. get
  1018. {
  1019. return this.m_OffsetEnable;
  1020. }
  1021. }
  1022. public IKCtrlData.ChangeFlagData changeFlagData
  1023. {
  1024. get
  1025. {
  1026. return this.m_ChangeFlagData;
  1027. }
  1028. }
  1029. public IKCtrlData.IKTargetData curTargetData
  1030. {
  1031. get
  1032. {
  1033. IKCtrlData.IKExecTiming curExecTiming = this.changeFlagData.curExecTiming;
  1034. if (curExecTiming == IKCtrlData.IKExecTiming.FlagPositive)
  1035. {
  1036. return this.m_FlagPositiveTgtData;
  1037. }
  1038. if (curExecTiming != IKCtrlData.IKExecTiming.FlagNegative)
  1039. {
  1040. return this.m_NormalTgtData;
  1041. }
  1042. return this.m_FlagNegativeTgtData;
  1043. }
  1044. }
  1045. public float BlendTime
  1046. {
  1047. get
  1048. {
  1049. return (!this.IKCtrl) ? -1f : this.IKCtrl.BlendTime;
  1050. }
  1051. }
  1052. public IKCtrlData.IKAttachType MyType { get; private set; }
  1053. public IKCtrlData.IKBlendType BlendType { get; private set; }
  1054. public bool DoIKBlend
  1055. {
  1056. get
  1057. {
  1058. return this.m_DoIKBlend && this.BlendTime > 0f;
  1059. }
  1060. }
  1061. public bool IsPointAttach
  1062. {
  1063. get
  1064. {
  1065. return this.MyType != IKCtrlData.IKAttachType.Rotate;
  1066. }
  1067. }
  1068. public bool NeedBlend
  1069. {
  1070. get
  1071. {
  1072. return this.BlendTime > 0f && this.BlendType != IKCtrlData.IKBlendType.Not_Blend;
  1073. }
  1074. }
  1075. public float BlendWeight
  1076. {
  1077. get
  1078. {
  1079. return (!this.NeedBlend || !this.DoIKBlend) ? 1f : Mathf.Clamp01(this.ElapsedTime / this.BlendTime);
  1080. }
  1081. }
  1082. public bool BlendNow
  1083. {
  1084. get
  1085. {
  1086. return this.NeedBlend && this.ElapsedTime < this.BlendTime;
  1087. }
  1088. }
  1089. public bool IsOldIK
  1090. {
  1091. get
  1092. {
  1093. return this.MyType == IKCtrlData.IKAttachType.Point;
  1094. }
  1095. }
  1096. public void ChangeIKType(IKCtrlData.IKAttachType type)
  1097. {
  1098. if (this.MyType == IKCtrlData.IKAttachType.Rotate)
  1099. {
  1100. return;
  1101. }
  1102. this.MyType = type;
  1103. }
  1104. public void CheckBlendType(bool check_time = true)
  1105. {
  1106. this.BlendType = IKCtrlData.IKBlendType.IK_To_IK;
  1107. this.m_DoIKBlend = true;
  1108. float num = Vector3.Distance(this.curTargetData.lastOffset, this.curTargetData.TgtOffset);
  1109. if (this.curTargetData.lastTarget)
  1110. {
  1111. if (!this.curTargetData.Target && string.IsNullOrEmpty(this.curTargetData.Tgt_AttachName))
  1112. {
  1113. this.BlendType = IKCtrlData.IKBlendType.IK_To_Detach;
  1114. }
  1115. else if (this.curTargetData.Target)
  1116. {
  1117. this.m_DoIKBlend = (this.curTargetData.lastTarget != this.curTargetData.Target || num > 0.01f);
  1118. }
  1119. }
  1120. else if (!string.IsNullOrEmpty(this.curTargetData.lastAttachName))
  1121. {
  1122. if (string.IsNullOrEmpty(this.curTargetData.Tgt_AttachName) && !this.curTargetData.Target)
  1123. {
  1124. this.BlendType = IKCtrlData.IKBlendType.IK_To_Detach;
  1125. }
  1126. else if (!this.curTargetData.Target)
  1127. {
  1128. this.m_DoIKBlend = (this.curTargetData.lastAttachName != this.curTargetData.Tgt_AttachName || this.curTargetData.lastTgtChara != this.curTargetData.TgtChara || num > 0.01f);
  1129. }
  1130. }
  1131. else
  1132. {
  1133. this.BlendType = IKCtrlData.IKBlendType.Detach_To_IK;
  1134. if (!this.curTargetData.Target && string.IsNullOrEmpty(this.curTargetData.Tgt_AttachName))
  1135. {
  1136. this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
  1137. this.m_DoIKBlend = false;
  1138. }
  1139. }
  1140. }
  1141. public void BlendReset(bool elpsed_only = false)
  1142. {
  1143. this.ElapsedTime = 0f;
  1144. if (!elpsed_only)
  1145. {
  1146. this.m_DoIKBlend = false;
  1147. this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
  1148. }
  1149. }
  1150. public IKCtrlData.IKTargetData GetTgtData(IKCtrlData.IKExecTiming timing)
  1151. {
  1152. if (timing == IKCtrlData.IKExecTiming.FlagPositive)
  1153. {
  1154. return this.m_FlagPositiveTgtData;
  1155. }
  1156. if (timing != IKCtrlData.IKExecTiming.FlagNegative)
  1157. {
  1158. return this.m_NormalTgtData;
  1159. }
  1160. return this.m_FlagNegativeTgtData;
  1161. }
  1162. public void SetIKSetting(IKCtrlData.IKExecTiming timing, Maid tgt_chara, int slot_no, string attach_name, Transform axis_bone, Transform target, Vector3 f_vecOffset, bool do_animation)
  1163. {
  1164. this.BlendReset(false);
  1165. this.DoAnimation = do_animation;
  1166. this.IsIKExec = true;
  1167. this.FirstFrame = true;
  1168. this.GetTgtData(timing).SetIKSetting(tgt_chara, slot_no, attach_name, axis_bone, target, f_vecOffset);
  1169. this.CheckBlendType(true);
  1170. this.m_ChangeFlagData.IsFlagChange();
  1171. }
  1172. public void Detach()
  1173. {
  1174. this.BlendReset(false);
  1175. this.m_NormalTgtData.Detach();
  1176. this.m_FlagPositiveTgtData.Detach();
  1177. this.m_FlagNegativeTgtData.Detach();
  1178. this.CheckBlendType(true);
  1179. this.m_ChangeFlagData.Reset();
  1180. this.DoSetOffset = false;
  1181. this.DoSetPosRot = false;
  1182. this.DoAnimation = false;
  1183. this.IsIKExec = false;
  1184. this.FirstFrame = false;
  1185. }
  1186. [SerializeField]
  1187. [Header("通常時のターゲットデータ")]
  1188. private IKCtrlData.IKTargetData m_NormalTgtData;
  1189. [SerializeField]
  1190. [Header("フラグ値が0以上のときのターゲットデータ")]
  1191. private IKCtrlData.IKTargetData m_FlagPositiveTgtData;
  1192. [SerializeField]
  1193. [Header("フラグ値が0以下のときのターゲットデータ")]
  1194. private IKCtrlData.IKTargetData m_FlagNegativeTgtData;
  1195. [SerializeField]
  1196. [Space]
  1197. private IKCtrlData.Vec3Enable m_OffsetEnable = new IKCtrlData.Vec3Enable();
  1198. [SerializeField]
  1199. private IKCtrlData.ChangeFlagData m_ChangeFlagData = new IKCtrlData.ChangeFlagData();
  1200. private bool m_DoIKBlend;
  1201. public bool IsIKExec;
  1202. public float ElapsedTime;
  1203. [HideInInspector]
  1204. public bool FirstFrame;
  1205. public bool DoAnimation;
  1206. [HideInInspector]
  1207. public bool DoSetPosRot;
  1208. [HideInInspector]
  1209. public bool DoSetOffset;
  1210. [HideInInspector]
  1211. public FullBodyIKCtrl IKCtrl;
  1212. }
  1213. }