LimbIKData.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Linq;
  3. using RootMotion.FinalIK;
  4. using UnityEngine;
  5. public abstract class LimbIKData : IKCtrlData
  6. {
  7. public LimbIKData(FullBodyIKCtrl ik_ctrl, FBIKChain chain, IKMappingLimb ik_mapping, Transform tgt_bone, bool use_old = false) : base(ik_ctrl, tgt_bone, use_old, false)
  8. {
  9. this.Chain = chain;
  10. this.IKMapping = ik_mapping;
  11. this.m_ChainBones = (from node in this.Chain.nodes
  12. select node.transform).ToArray<Transform>();
  13. }
  14. public override bool NeedFullbodySolverUpdate
  15. {
  16. get
  17. {
  18. return base.IsIKExec && !base.OldIkExec && this.m_IsPullBody;
  19. }
  20. }
  21. public override void SetPullState(bool pull_on)
  22. {
  23. this.m_IsPullBody = pull_on;
  24. if (this.m_OrijinPull < 0f)
  25. {
  26. this.m_OrijinPull = this.Chain.pull;
  27. }
  28. if (pull_on)
  29. {
  30. this.Chain.pull = this.m_OrijinPull;
  31. }
  32. else
  33. {
  34. this.Chain.pull = 0.1f;
  35. }
  36. }
  37. public override void TagetTransCpy()
  38. {
  39. base.TagetTransCpy();
  40. if (this.m_IsUpperBody)
  41. {
  42. this.IKMapping.weight = 0f;
  43. }
  44. }
  45. public override void ApplyIKSetting()
  46. {
  47. base.ApplyIKSetting();
  48. if (this.m_IsUpperBody)
  49. {
  50. this.IKMapping.weight = Mathf.Max(this.IKMapping.weight, Mathf.Max(base.PositionWeight, base.RotationWeight));
  51. }
  52. }
  53. public readonly FBIKChain Chain;
  54. public readonly IKMappingLimb IKMapping;
  55. protected bool m_IsUpperBody;
  56. protected float m_OrijinPull = -1f;
  57. protected bool m_IsPullBody = true;
  58. }