IKCtrlData.cs 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  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. Vector3 vector;
  394. tgt_data.TgtChara.body0.goSlot[tgt_data.Tgt_AttachSlot].morph.GetAttachPoint(tgt_data.Tgt_AttachName, out pos, out rot, out vector, false);
  395. if (setting_data.MyType == IKCtrlData.IKAttachType.NewPoint && tgt_data.AxisTgt)
  396. {
  397. rot = tgt_data.AxisTgt.rotation;
  398. }
  399. }
  400. else
  401. {
  402. setting_data.IsIKExec = false;
  403. tgt_data.Tgt_AttachName = string.Empty;
  404. }
  405. }
  406. }
  407. else if (this.ForceIK)
  408. {
  409. pos = this.m_IKTarget.position;
  410. rot = this.m_IKTarget.rotation;
  411. }
  412. else if (setting_data.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
  413. {
  414. pos = this.BlendPosRot.pos;
  415. rot = this.BlendPosRot.rot;
  416. }
  417. else
  418. {
  419. setting_data.IsIKExec = false;
  420. }
  421. if (setting_data.IsIKExec && include_offset)
  422. {
  423. if (setting_data.IsPointAttach)
  424. {
  425. Vector3 start = pos;
  426. switch (this.posOffsetType)
  427. {
  428. case IKCtrlData.PosOffsetType.OffsetTarget:
  429. pos += rot * tgt_data.TgtOffset;
  430. break;
  431. case IKCtrlData.PosOffsetType.OffsetWorld:
  432. pos += tgt_data.TgtOffset;
  433. break;
  434. case IKCtrlData.PosOffsetType.OffsetBone:
  435. pos -= this.TargetBone.rotation * tgt_data.TgtOffset;
  436. break;
  437. }
  438. Debug.DrawLine(start, pos, Color.white);
  439. }
  440. else
  441. {
  442. rot *= Quaternion.Euler(tgt_data.TgtOffset);
  443. }
  444. }
  445. }
  446. protected bool IsEachBoneIK(IKCtrlData.IKSettingData data)
  447. {
  448. return data.IsIKExec && data.curTargetData.Target == this.TargetBone;
  449. }
  450. private void MultiTgtDataToPosRot(IKCtrlData.IKSettingData data, IKCtrlData.IKExecTiming from, IKCtrlData.IKExecTiming to, ref Vector3 pos, ref Quaternion rot)
  451. {
  452. IKCtrlData.IKTargetData tgtData = data.GetTgtData(from);
  453. IKCtrlData.IKTargetData tgtData2 = data.GetTgtData(to);
  454. Vector3 a = pos;
  455. Quaternion a2 = rot;
  456. this.SetIKPosRot(data, tgtData, ref a, ref a2, true);
  457. Vector3 b = pos;
  458. Quaternion b2 = rot;
  459. this.SetIKPosRot(data, tgtData2, ref b, ref b2, true);
  460. float blendValue = this.GetFlagData(data.MyType).GetBlendValue(from, to);
  461. if (data.IsPointAttach)
  462. {
  463. if (!tgtData.ExistTgt)
  464. {
  465. this.m_PosWeightBase = ((!tgtData2.ExistTgt) ? 0f : blendValue);
  466. }
  467. else
  468. {
  469. this.m_PosWeightBase = 1f;
  470. }
  471. pos = Vector3.Lerp(a, b, blendValue);
  472. }
  473. else
  474. {
  475. if (!tgtData.ExistTgt)
  476. {
  477. this.m_RotWeightBase = ((!tgtData2.ExistTgt) ? 0f : blendValue);
  478. }
  479. else
  480. {
  481. this.m_RotWeightBase = 1f;
  482. }
  483. rot = Quaternion.Lerp(a2, b2, blendValue);
  484. }
  485. }
  486. protected virtual void SetTargetTransform(IKCtrlData.IKSettingData data, Vector3 pos, Quaternion rot)
  487. {
  488. IKCtrlData.IKTargetData curTargetData = data.curTargetData;
  489. switch (data.MyType)
  490. {
  491. case IKCtrlData.IKAttachType.Point:
  492. pos += this.m_AnimPosRotOffset.pos;
  493. Debug.DrawLine(pos, pos + rot * Vector3.forward * 0.2f, Color.cyan);
  494. if (!data.DoSetOffset)
  495. {
  496. this.IkCmoPorc(pos, data.curTargetData.TgtOffset);
  497. }
  498. else
  499. {
  500. this.IkCmoPorc(pos, Vector3.zero);
  501. }
  502. break;
  503. case IKCtrlData.IKAttachType.Rotate:
  504. rot *= this.m_AnimPosRotOffset.rot;
  505. if (!data.DoSetOffset)
  506. {
  507. rot *= Quaternion.Euler(data.curTargetData.TgtOffset);
  508. }
  509. rot = Quaternion.Euler(this.GetIKEnable(data.MyType).GetEnable(this.TargetBone.eulerAngles, rot.eulerAngles, false));
  510. this.m_IKTarget.rotation = rot;
  511. if (data.BlendType == IKCtrlData.IKBlendType.IK_To_IK)
  512. {
  513. this.m_IKTarget.rotation = Quaternion.Lerp(this.BlendPosRot.rot, this.m_IKTarget.rotation, data.BlendWeight);
  514. this.RotationWeight = this.m_RotWeightBase;
  515. }
  516. else if (data.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
  517. {
  518. this.RotationWeight = this.m_RotWeightBase * (1f - data.BlendWeight);
  519. }
  520. else
  521. {
  522. this.RotationWeight = this.m_RotWeightBase * data.BlendWeight;
  523. }
  524. break;
  525. case IKCtrlData.IKAttachType.NewPoint:
  526. pos += this.m_AnimPosRotOffset.pos;
  527. if (!data.DoSetOffset)
  528. {
  529. Vector3 start = pos;
  530. switch (this.posOffsetType)
  531. {
  532. case IKCtrlData.PosOffsetType.OffsetTarget:
  533. pos += rot * curTargetData.TgtOffset;
  534. break;
  535. case IKCtrlData.PosOffsetType.OffsetWorld:
  536. pos += curTargetData.TgtOffset;
  537. break;
  538. case IKCtrlData.PosOffsetType.OffsetBone:
  539. pos -= this.TargetBone.rotation * curTargetData.TgtOffset;
  540. break;
  541. }
  542. Debug.DrawLine(start, pos, Color.white);
  543. }
  544. pos = this.GetIKEnable(data.MyType).GetEnable(this.TargetBone.position, pos, false);
  545. this.m_IKTarget.position = pos;
  546. if (data.BlendType == IKCtrlData.IKBlendType.IK_To_IK)
  547. {
  548. this.m_IKTarget.position = Vector3.Lerp(this.BlendPosRot.pos, this.m_IKTarget.position, data.BlendWeight);
  549. this.PositionWeight = this.m_PosWeightBase;
  550. }
  551. else if (data.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
  552. {
  553. this.PositionWeight = this.m_PosWeightBase * (1f - data.BlendWeight);
  554. }
  555. else
  556. {
  557. this.PositionWeight = this.m_PosWeightBase * data.BlendWeight;
  558. }
  559. break;
  560. }
  561. data.DoSetOffset = true;
  562. }
  563. private void IkCmoPorc(Vector3 tgt, Vector3 vechand_offset)
  564. {
  565. if (!this.UseOldIK)
  566. {
  567. return;
  568. }
  569. for (int i = 0; i < 3; i++)
  570. {
  571. this.IKCmo.Porc(this.TargetBone.parent.parent, this.TargetBone.parent, this.TargetBone, tgt, vechand_offset, this);
  572. }
  573. }
  574. public virtual void Update()
  575. {
  576. }
  577. public virtual void LateUpdate()
  578. {
  579. this.SaveLastBonePosRot();
  580. this.GetIKSettingData(IKCtrlData.IKAttachType.NewPoint).DoSetPosRot = (this.GetIKSettingData(IKCtrlData.IKAttachType.Rotate).DoSetPosRot = false);
  581. }
  582. public virtual void SaveLastBonePosRot()
  583. {
  584. this.m_lastIKPosRot.Copy(this.m_TargetBone);
  585. }
  586. public virtual void Detach(IKCtrlData.IKAttachType attachType)
  587. {
  588. this.ForceIK = false;
  589. this.m_BoneTgtPair.PosOffset = Vector3.zero;
  590. this.IsSelfIKAttach = false;
  591. this.BlendPosRot.Copy(this.m_lastIKPosRot);
  592. this.GetFlagData(attachType).Reset();
  593. this.GetIKSettingData(attachType).Detach();
  594. }
  595. public IKCtrlData.IKSettingData GetIKSettingData(IKCtrlData.IKAttachType attach_type)
  596. {
  597. if (attach_type == IKCtrlData.IKAttachType.Rotate)
  598. {
  599. return this.m_RotateIKData;
  600. }
  601. return this.m_PointIKData;
  602. }
  603. public IKCtrlData.ChangeFlagData GetFlagData(IKCtrlData.IKAttachType attach_type)
  604. {
  605. return this.GetIKSettingData(attach_type).changeFlagData;
  606. }
  607. public IKCtrlData.IKTargetData GetTargetData(IKCtrlData.IKAttachType attach_type)
  608. {
  609. return this.GetIKSettingData(attach_type).curTargetData;
  610. }
  611. public IKCtrlData.IKTargetData GetTargetData(IKCtrlData.IKAttachType attach_type, IKCtrlData.IKExecTiming exec_timing)
  612. {
  613. return this.GetIKSettingData(attach_type).GetTgtData(exec_timing);
  614. }
  615. private bool IsIKTargetChara(IKCtrlData.IKAttachType attach_type, Maid chara)
  616. {
  617. IKCtrlData.IKSettingData iksettingData = this.GetIKSettingData(attach_type);
  618. foreach (IKCtrlData.IKExecTiming timing in (IKCtrlData.IKExecTiming[])Enum.GetValues(typeof(IKCtrlData.IKExecTiming)))
  619. {
  620. IKCtrlData.IKTargetData tgtData = iksettingData.GetTgtData(timing);
  621. if (tgtData.TgtChara == chara)
  622. {
  623. return true;
  624. }
  625. }
  626. return false;
  627. }
  628. public bool IsIKTargetChara(Maid chara)
  629. {
  630. return this.IsIKTargetChara(IKCtrlData.IKAttachType.NewPoint, chara) || this.IsIKTargetChara(IKCtrlData.IKAttachType.Rotate, chara);
  631. }
  632. public IKCtrlData.Vec3Enable GetIKEnable(IKCtrlData.IKAttachType attach_type)
  633. {
  634. return this.GetIKSettingData(attach_type).offsetEnable;
  635. }
  636. public bool GetIKExecTruth(IKCtrlData.IKAttachType attach_type)
  637. {
  638. IKCtrlData.IKSettingData iksettingData = (attach_type != IKCtrlData.IKAttachType.Rotate) ? this.PointIK : this.RotateIK;
  639. float num = (attach_type != IKCtrlData.IKAttachType.Rotate) ? this.PositionWeight : this.RotationWeight;
  640. bool flag = iksettingData.IsIKExec && num > 0f;
  641. if (iksettingData.changeFlagData.IsEnable)
  642. {
  643. flag &= (iksettingData.changeFlagData.GetFlagValue() > 0f);
  644. }
  645. return flag;
  646. }
  647. [SerializeField]
  648. [Header("位置IK")]
  649. private IKCtrlData.IKSettingData m_PointIKData = new IKCtrlData.IKSettingData(IKCtrlData.IKAttachType.NewPoint);
  650. [SerializeField]
  651. [Header("回転IK")]
  652. private IKCtrlData.IKSettingData m_RotateIKData = new IKCtrlData.IKSettingData(IKCtrlData.IKAttachType.Rotate);
  653. private TBody.IKCMO m_IKCmo = new TBody.IKCMO();
  654. private IKCtrlData.PosRotPair m_BlendPosRot = new IKCtrlData.PosRotPair();
  655. [SerializeField]
  656. [Space]
  657. private IKCtrlData.PosRotPair m_AnimPosRotOffset = new IKCtrlData.PosRotPair();
  658. private IKCtrlData.PosRotPair m_FirstPosRotOffset = new IKCtrlData.PosRotPair();
  659. [SerializeField]
  660. private bool m_AttachPointIK;
  661. [SerializeField]
  662. private Transform m_TargetBone;
  663. [SerializeField]
  664. private Transform m_IKTarget;
  665. [SerializeField]
  666. private bool m_DrawLine = true;
  667. private IKCtrlData.BoneTgtPair m_BoneTgtPair;
  668. protected IKCtrlData.PosRotPair m_FirstTgtPosRot = new IKCtrlData.PosRotPair();
  669. protected IKCtrlData.PosRotPair m_lastIKPosRot = new IKCtrlData.PosRotPair();
  670. [SerializeField]
  671. [Range(0f, 1f)]
  672. protected float m_PosWeightBase = 1f;
  673. [SerializeField]
  674. [Range(0f, 1f)]
  675. protected float m_RotWeightBase = 1f;
  676. [SerializeField]
  677. protected bool m_ForceIK;
  678. protected bool m_ForceIKEnable;
  679. protected bool m_EachOtherIK;
  680. protected IKCtrlData.Vec3Enable m_OffsetEnable = new IKCtrlData.Vec3Enable();
  681. [Space]
  682. public IKCtrlData.PosOffsetType posOffsetType;
  683. public readonly FullBodyIKCtrl MyIKCtrl;
  684. public readonly bool UseOldIK;
  685. protected Transform[] m_ChainBones;
  686. public enum IKAttachType
  687. {
  688. Point,
  689. Rotate,
  690. NewPoint
  691. }
  692. public enum IKBlendType
  693. {
  694. Detach_To_IK,
  695. IK_To_IK,
  696. IK_To_Detach,
  697. Not_Blend
  698. }
  699. public enum PosOffsetType
  700. {
  701. OffsetTarget,
  702. OffsetWorld,
  703. OffsetBone
  704. }
  705. public enum IKExecTiming
  706. {
  707. Normal,
  708. FlagPositive,
  709. FlagNegative = -1
  710. }
  711. [Serializable]
  712. public class Vec3Enable
  713. {
  714. public bool AnyDisable
  715. {
  716. get
  717. {
  718. return !this.EnableX || !this.EnableY || !this.EnableZ;
  719. }
  720. }
  721. public Vector3 GetEnable(Vector3 pos, bool inverse = false)
  722. {
  723. if (this.EnableX == inverse)
  724. {
  725. pos.x = 0f;
  726. }
  727. if (this.EnableY == inverse)
  728. {
  729. pos.y = 0f;
  730. }
  731. if (this.EnableZ == inverse)
  732. {
  733. pos.z = 0f;
  734. }
  735. return pos;
  736. }
  737. public Vector3 GetEnable(Vector3 from, Vector3 to, bool inverse = false)
  738. {
  739. if (this.EnableX == inverse)
  740. {
  741. to.x = from.x;
  742. }
  743. if (this.EnableY == inverse)
  744. {
  745. to.y = from.y;
  746. }
  747. if (this.EnableZ == inverse)
  748. {
  749. to.z = from.z;
  750. }
  751. return to;
  752. }
  753. public void Recet()
  754. {
  755. this.EnableX = (this.EnableY = (this.EnableZ = true));
  756. }
  757. public void Copy(IKCtrlData.Vec3Enable cpy)
  758. {
  759. this.EnableX = cpy.EnableX;
  760. this.EnableY = cpy.EnableY;
  761. this.EnableZ = cpy.EnableZ;
  762. }
  763. public string OffEnableToStr()
  764. {
  765. if (!this.AnyDisable)
  766. {
  767. return string.Empty;
  768. }
  769. string text = " disable=";
  770. if (!this.EnableX)
  771. {
  772. text += "x";
  773. }
  774. if (!this.EnableY)
  775. {
  776. if (!this.EnableX)
  777. {
  778. text += ",";
  779. }
  780. text += "y";
  781. }
  782. if (!this.EnableZ)
  783. {
  784. if (!this.EnableX || !this.EnableY)
  785. {
  786. text += ",";
  787. }
  788. text += "z";
  789. }
  790. return text;
  791. }
  792. public bool EnableX = true;
  793. public bool EnableY = true;
  794. public bool EnableZ = true;
  795. }
  796. [Serializable]
  797. public class PosRotPair
  798. {
  799. public void Reset()
  800. {
  801. this.pos = Vector3.zero;
  802. this.rot = new Quaternion(0f, 0f, 0f, 1f);
  803. }
  804. public void Copy(IKCtrlData.PosRotPair pair)
  805. {
  806. this.pos = pair.pos;
  807. this.rot = pair.rot;
  808. }
  809. public void Copy(Transform transform)
  810. {
  811. this.pos = transform.position;
  812. this.rot = transform.rotation;
  813. }
  814. public void DrawAxis()
  815. {
  816. KasaiUtility.DrawAxis(this.pos, this.rot, 0.0625f);
  817. }
  818. public Vector3 pos = Vector3.zero;
  819. public Quaternion rot = new Quaternion(0f, 0f, 0f, 1f);
  820. }
  821. public class BoneTgtPair
  822. {
  823. public BoneTgtPair(Transform bone, Transform target)
  824. {
  825. this.Bone = bone;
  826. this.Target = target;
  827. }
  828. public void Copy()
  829. {
  830. this.Target.position = this.Bone.position + this.PosOffset;
  831. this.Target.rotation = this.Bone.rotation;
  832. }
  833. public readonly Transform Bone;
  834. public readonly Transform Target;
  835. public Vector3 PosOffset = Vector3.zero;
  836. }
  837. [Serializable]
  838. public class ChangeFlagData
  839. {
  840. public bool IsEnable
  841. {
  842. get
  843. {
  844. return this.Target != null;
  845. }
  846. }
  847. public IKCtrlData.IKExecTiming lastExecTiming { get; private set; }
  848. public IKCtrlData.IKExecTiming curExecTiming
  849. {
  850. get
  851. {
  852. if (this.GetFlagValue() > 0f)
  853. {
  854. return IKCtrlData.IKExecTiming.FlagPositive;
  855. }
  856. if (this.GetFlagValue() < 0f)
  857. {
  858. return IKCtrlData.IKExecTiming.FlagNegative;
  859. }
  860. return IKCtrlData.IKExecTiming.Normal;
  861. }
  862. }
  863. public float GetFlagValue()
  864. {
  865. if (!this.Target)
  866. {
  867. return 0f;
  868. }
  869. return Vector3.Dot(this.Target.localPosition, this.Axis) / this.OnValue;
  870. }
  871. public float GetBlendValue(IKCtrlData.IKExecTiming from, IKCtrlData.IKExecTiming to)
  872. {
  873. if (from == to)
  874. {
  875. return 1f;
  876. }
  877. return Mathf.InverseLerp((float)from, (float)to, this.GetFlagValue());
  878. }
  879. public bool IsFlagChange()
  880. {
  881. if (!this.Target)
  882. {
  883. return false;
  884. }
  885. IKCtrlData.IKExecTiming lastExecTiming = this.lastExecTiming;
  886. this.lastExecTiming = this.curExecTiming;
  887. return lastExecTiming != this.lastExecTiming;
  888. }
  889. public void Reset()
  890. {
  891. this.Target = null;
  892. this.lastExecTiming = IKCtrlData.IKExecTiming.Normal;
  893. this.BlendCtrlSelf = false;
  894. }
  895. public Transform Target;
  896. public Vector3 Axis = Vector3.forward;
  897. public float OnValue = 0.1f;
  898. [HideInInspector]
  899. public bool BlendCtrlSelf;
  900. }
  901. [Serializable]
  902. public class IKTargetData
  903. {
  904. public IKTargetData(bool is_for_point)
  905. {
  906. this.IsForPointTarget = is_for_point;
  907. }
  908. public string lastAttachName
  909. {
  910. get
  911. {
  912. return this.m_LastAttachName;
  913. }
  914. }
  915. public Transform lastTarget
  916. {
  917. get
  918. {
  919. return this.m_LastTarget;
  920. }
  921. }
  922. public Maid lastTgtChara
  923. {
  924. get
  925. {
  926. return this.m_LastTgtChara;
  927. }
  928. }
  929. public Vector3 lastOffset
  930. {
  931. get
  932. {
  933. return this.m_LastOffset;
  934. }
  935. }
  936. public bool ExistTgt
  937. {
  938. get
  939. {
  940. return this.Target != null || !string.IsNullOrEmpty(this.Tgt_AttachName);
  941. }
  942. }
  943. public bool IsEachOtherIK(bool check_update = false)
  944. {
  945. return this.TgtChara && this.TgtChara.IKCtrl.IsIKExec && this.TgtChara.IKCtrl.IsUpdateEnd == check_update;
  946. }
  947. public void SaveLastTarget()
  948. {
  949. this.m_LastAttachName = this.Tgt_AttachName;
  950. this.m_LastTgtChara = this.TgtChara;
  951. this.m_LastTarget = this.Target;
  952. this.m_LastOffset = this.TgtOffset;
  953. }
  954. public void SetLastTarget(string attach_name, Maid maid, Transform target, Vector3 offset)
  955. {
  956. this.m_LastAttachName = attach_name;
  957. this.m_LastTgtChara = maid;
  958. this.m_LastTarget = target;
  959. this.m_LastOffset = offset;
  960. }
  961. public void SetIKSetting(Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Transform target, Vector3 f_vecOffset)
  962. {
  963. this.SetLastTarget(this.Tgt_AttachName, this.TgtChara, this.Target, this.TgtOffset);
  964. this.TgtChara = tgt_maid;
  965. this.Tgt_AttachSlot = slot_no;
  966. this.Tgt_AttachName = attach_name;
  967. this.Target = target;
  968. this.AxisTgt = axis_bone;
  969. if (this.IsForPointTarget)
  970. {
  971. this.TgtOffset = f_vecOffset;
  972. }
  973. else
  974. {
  975. this.TgtOffset = KasaiUtility.AngleRimmit360(f_vecOffset);
  976. }
  977. this.IsIKExec = true;
  978. }
  979. public void Detach()
  980. {
  981. this.SetLastTarget(this.Tgt_AttachName, this.TgtChara, this.Target, this.TgtOffset);
  982. this.TgtChara = null;
  983. this.Tgt_AttachSlot = -1;
  984. this.Tgt_AttachName = string.Empty;
  985. this.Target = null;
  986. this.AxisTgt = null;
  987. this.TgtOffset = Vector3.zero;
  988. }
  989. private string m_LastAttachName = string.Empty;
  990. private Transform m_LastTarget;
  991. private Maid m_LastTgtChara;
  992. private Vector3 m_LastOffset = Vector3.zero;
  993. public Transform Target;
  994. public Vector3 TgtOffset;
  995. public int Tgt_AttachSlot = -1;
  996. public string Tgt_AttachName = string.Empty;
  997. public Maid TgtChara;
  998. public bool IsTgtAxis;
  999. public bool IsIKExec;
  1000. public Transform AxisTgt;
  1001. public readonly bool IsForPointTarget;
  1002. }
  1003. [Serializable]
  1004. public class IKSettingData
  1005. {
  1006. public IKSettingData(IKCtrlData.IKAttachType type)
  1007. {
  1008. this.MyType = type;
  1009. this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
  1010. this.m_NormalTgtData = new IKCtrlData.IKTargetData(this.IsPointAttach);
  1011. this.m_FlagPositiveTgtData = new IKCtrlData.IKTargetData(this.IsPointAttach);
  1012. this.m_FlagNegativeTgtData = new IKCtrlData.IKTargetData(this.IsPointAttach);
  1013. }
  1014. public IKCtrlData.Vec3Enable offsetEnable
  1015. {
  1016. get
  1017. {
  1018. return this.m_OffsetEnable;
  1019. }
  1020. }
  1021. public IKCtrlData.ChangeFlagData changeFlagData
  1022. {
  1023. get
  1024. {
  1025. return this.m_ChangeFlagData;
  1026. }
  1027. }
  1028. public IKCtrlData.IKTargetData curTargetData
  1029. {
  1030. get
  1031. {
  1032. IKCtrlData.IKExecTiming curExecTiming = this.changeFlagData.curExecTiming;
  1033. if (curExecTiming == IKCtrlData.IKExecTiming.FlagPositive)
  1034. {
  1035. return this.m_FlagPositiveTgtData;
  1036. }
  1037. if (curExecTiming != IKCtrlData.IKExecTiming.FlagNegative)
  1038. {
  1039. return this.m_NormalTgtData;
  1040. }
  1041. return this.m_FlagNegativeTgtData;
  1042. }
  1043. }
  1044. public float BlendTime
  1045. {
  1046. get
  1047. {
  1048. return (!this.IKCtrl) ? -1f : this.IKCtrl.BlendTime;
  1049. }
  1050. }
  1051. public IKCtrlData.IKAttachType MyType { get; private set; }
  1052. public IKCtrlData.IKBlendType BlendType { get; private set; }
  1053. public bool DoIKBlend
  1054. {
  1055. get
  1056. {
  1057. return this.m_DoIKBlend && this.BlendTime > 0f;
  1058. }
  1059. }
  1060. public bool IsPointAttach
  1061. {
  1062. get
  1063. {
  1064. return this.MyType != IKCtrlData.IKAttachType.Rotate;
  1065. }
  1066. }
  1067. public bool NeedBlend
  1068. {
  1069. get
  1070. {
  1071. return this.BlendTime > 0f && this.BlendType != IKCtrlData.IKBlendType.Not_Blend;
  1072. }
  1073. }
  1074. public float BlendWeight
  1075. {
  1076. get
  1077. {
  1078. return (!this.NeedBlend || !this.DoIKBlend) ? 1f : Mathf.Clamp01(this.ElapsedTime / this.BlendTime);
  1079. }
  1080. }
  1081. public bool BlendNow
  1082. {
  1083. get
  1084. {
  1085. return this.NeedBlend && this.ElapsedTime < this.BlendTime;
  1086. }
  1087. }
  1088. public bool IsOldIK
  1089. {
  1090. get
  1091. {
  1092. return this.MyType == IKCtrlData.IKAttachType.Point;
  1093. }
  1094. }
  1095. public void ChangeIKType(IKCtrlData.IKAttachType type)
  1096. {
  1097. if (this.MyType == IKCtrlData.IKAttachType.Rotate)
  1098. {
  1099. return;
  1100. }
  1101. this.MyType = type;
  1102. }
  1103. public void CheckBlendType(bool check_time = true)
  1104. {
  1105. this.BlendType = IKCtrlData.IKBlendType.IK_To_IK;
  1106. this.m_DoIKBlend = true;
  1107. float num = Vector3.Distance(this.curTargetData.lastOffset, this.curTargetData.TgtOffset);
  1108. if (this.curTargetData.lastTarget)
  1109. {
  1110. if (!this.curTargetData.Target && string.IsNullOrEmpty(this.curTargetData.Tgt_AttachName))
  1111. {
  1112. this.BlendType = IKCtrlData.IKBlendType.IK_To_Detach;
  1113. }
  1114. else if (this.curTargetData.Target)
  1115. {
  1116. this.m_DoIKBlend = (this.curTargetData.lastTarget != this.curTargetData.Target || num > 0.01f);
  1117. }
  1118. }
  1119. else if (!string.IsNullOrEmpty(this.curTargetData.lastAttachName))
  1120. {
  1121. if (string.IsNullOrEmpty(this.curTargetData.Tgt_AttachName) && !this.curTargetData.Target)
  1122. {
  1123. this.BlendType = IKCtrlData.IKBlendType.IK_To_Detach;
  1124. }
  1125. else if (!this.curTargetData.Target)
  1126. {
  1127. this.m_DoIKBlend = (this.curTargetData.lastAttachName != this.curTargetData.Tgt_AttachName || this.curTargetData.lastTgtChara != this.curTargetData.TgtChara || num > 0.01f);
  1128. }
  1129. }
  1130. else
  1131. {
  1132. this.BlendType = IKCtrlData.IKBlendType.Detach_To_IK;
  1133. if (!this.curTargetData.Target && string.IsNullOrEmpty(this.curTargetData.Tgt_AttachName))
  1134. {
  1135. this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
  1136. this.m_DoIKBlend = false;
  1137. }
  1138. }
  1139. }
  1140. public void BlendReset(bool elpsed_only = false)
  1141. {
  1142. this.ElapsedTime = 0f;
  1143. if (!elpsed_only)
  1144. {
  1145. this.m_DoIKBlend = false;
  1146. this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
  1147. }
  1148. }
  1149. public IKCtrlData.IKTargetData GetTgtData(IKCtrlData.IKExecTiming timing)
  1150. {
  1151. if (timing == IKCtrlData.IKExecTiming.FlagPositive)
  1152. {
  1153. return this.m_FlagPositiveTgtData;
  1154. }
  1155. if (timing != IKCtrlData.IKExecTiming.FlagNegative)
  1156. {
  1157. return this.m_NormalTgtData;
  1158. }
  1159. return this.m_FlagNegativeTgtData;
  1160. }
  1161. 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)
  1162. {
  1163. this.BlendReset(false);
  1164. this.DoAnimation = do_animation;
  1165. this.IsIKExec = true;
  1166. this.FirstFrame = true;
  1167. this.GetTgtData(timing).SetIKSetting(tgt_chara, slot_no, attach_name, axis_bone, target, f_vecOffset);
  1168. this.CheckBlendType(true);
  1169. this.m_ChangeFlagData.IsFlagChange();
  1170. }
  1171. public void Detach()
  1172. {
  1173. this.BlendReset(false);
  1174. this.m_NormalTgtData.Detach();
  1175. this.m_FlagPositiveTgtData.Detach();
  1176. this.m_FlagNegativeTgtData.Detach();
  1177. this.CheckBlendType(true);
  1178. this.m_ChangeFlagData.Reset();
  1179. this.DoSetOffset = false;
  1180. this.DoSetPosRot = false;
  1181. this.DoAnimation = false;
  1182. this.IsIKExec = false;
  1183. this.FirstFrame = false;
  1184. }
  1185. [SerializeField]
  1186. [Header("通常時のターゲットデータ")]
  1187. private IKCtrlData.IKTargetData m_NormalTgtData;
  1188. [SerializeField]
  1189. [Header("フラグ値が0以上のときのターゲットデータ")]
  1190. private IKCtrlData.IKTargetData m_FlagPositiveTgtData;
  1191. [SerializeField]
  1192. [Header("フラグ値が0以下のときのターゲットデータ")]
  1193. private IKCtrlData.IKTargetData m_FlagNegativeTgtData;
  1194. [SerializeField]
  1195. [Space]
  1196. private IKCtrlData.Vec3Enable m_OffsetEnable = new IKCtrlData.Vec3Enable();
  1197. [SerializeField]
  1198. private IKCtrlData.ChangeFlagData m_ChangeFlagData = new IKCtrlData.ChangeFlagData();
  1199. private bool m_DoIKBlend;
  1200. public bool IsIKExec;
  1201. public float ElapsedTime;
  1202. [HideInInspector]
  1203. public bool FirstFrame;
  1204. public bool DoAnimation;
  1205. [HideInInspector]
  1206. public bool DoSetPosRot;
  1207. [HideInInspector]
  1208. public bool DoSetOffset;
  1209. [HideInInspector]
  1210. public FullBodyIKCtrl IKCtrl;
  1211. }
  1212. }