|
@@ -26,6 +26,10 @@ public abstract class IKCtrlData
|
|
|
}
|
|
|
this.m_BoneTgtPair = new IKCtrlData.BoneTgtPair(this.TargetBone, this.m_IKTarget);
|
|
|
this.IkCmoInit();
|
|
|
+ this.m_PointIK.IKCtrl = ik_ctrl;
|
|
|
+ this.m_NextPointIK.IKCtrl = ik_ctrl;
|
|
|
+ this.m_RotateIK.IKCtrl = ik_ctrl;
|
|
|
+ this.m_NextRotateIK.IKCtrl = ik_ctrl;
|
|
|
}
|
|
|
|
|
|
public bool ForceIK
|
|
@@ -96,6 +100,14 @@ public abstract class IKCtrlData
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public bool IsIKExecTruth
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return this.IsIKExec && (this.PositionWeight > 0f || this.RotationWeight > 0f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public bool OldIkExec
|
|
|
{
|
|
|
get
|
|
@@ -315,13 +327,29 @@ public abstract class IKCtrlData
|
|
|
Quaternion b2 = quaternion;
|
|
|
this.SetIKPosRot(ikparam3, ref b, ref b2, true);
|
|
|
float num = this.GetFlagData(data.MyType).Value01();
|
|
|
- data.IsIKExec = (num != 0f);
|
|
|
+ data.IsIKExec = true;
|
|
|
if (data.IsPointAttach)
|
|
|
{
|
|
|
+ if (!ikparam2.ExistTgt)
|
|
|
+ {
|
|
|
+ this.m_PosWeightBase = num;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ this.m_PosWeightBase = 1f;
|
|
|
+ }
|
|
|
vector = Vector3.Lerp(a, b, num);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ if (!ikparam2.ExistTgt)
|
|
|
+ {
|
|
|
+ this.m_RotWeightBase = num;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ this.m_RotWeightBase = 1f;
|
|
|
+ }
|
|
|
quaternion = Quaternion.Lerp(a2, b2, num);
|
|
|
}
|
|
|
}
|
|
@@ -332,8 +360,8 @@ public abstract class IKCtrlData
|
|
|
IKCtrlData.IKParam ikparam5 = this.GetIKParam(data.MyType, true, isFlagOn);
|
|
|
ikparam4.BlendRecet(true);
|
|
|
ikparam5.BlendRecet(true);
|
|
|
- ikparam5.SetLastTarget(ikparam4.Tgt_AttachName, ikparam4.TgtMaid, ikparam4.Target);
|
|
|
- ikparam5.CheckBlendType(false);
|
|
|
+ ikparam5.SetLastTarget(ikparam4.Tgt_AttachName, ikparam4.TgtMaid, ikparam4.Target, ikparam4.TgtOffset);
|
|
|
+ ikparam5.CheckBlendType(true);
|
|
|
if (ikparam5.MyType == IKCtrlData.IKAttachType.Rotate)
|
|
|
{
|
|
|
this.BlendPosRot.rot = this.m_lastIKPosRot.rot;
|
|
@@ -342,10 +370,6 @@ public abstract class IKCtrlData
|
|
|
{
|
|
|
this.BlendPosRot.pos = this.m_lastIKPosRot.pos;
|
|
|
}
|
|
|
- if (ikparam5.BlendType == IKCtrlData.IKBlendType.IK_To_Detach && ikparam5.BlendTime <= 0f)
|
|
|
- {
|
|
|
- ikparam5.BlendTime = ikparam4.BlendTime;
|
|
|
- }
|
|
|
this.SetIKPosRot(data, ref vector, ref quaternion, false);
|
|
|
}
|
|
|
else
|
|
@@ -420,7 +444,7 @@ public abstract class IKCtrlData
|
|
|
{
|
|
|
KasaiUtility.DrawAxis(vector, quaternion, 0.125f);
|
|
|
}
|
|
|
- if (data.BlendNow && !data.DoSetPosRot)
|
|
|
+ if (!data.DoSetPosRot)
|
|
|
{
|
|
|
data.ElapsedTime += Time.deltaTime;
|
|
|
}
|
|
@@ -459,15 +483,15 @@ public abstract class IKCtrlData
|
|
|
if (data.BlendType == IKCtrlData.IKBlendType.IK_To_IK)
|
|
|
{
|
|
|
this.m_IKTarget.rotation = Quaternion.Lerp(this.BlendPosRot.rot, this.m_IKTarget.rotation, data.BlendWeight);
|
|
|
- this.RotationWeight = this.m_IKWeight;
|
|
|
+ this.RotationWeight = this.m_RotWeightBase;
|
|
|
}
|
|
|
else if (data.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
|
|
|
{
|
|
|
- this.RotationWeight = this.m_IKWeight * (1f - data.BlendWeight);
|
|
|
+ this.RotationWeight = this.m_RotWeightBase * (1f - data.BlendWeight);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- this.RotationWeight = this.m_IKWeight * data.BlendWeight;
|
|
|
+ this.RotationWeight = this.m_RotWeightBase * data.BlendWeight;
|
|
|
}
|
|
|
break;
|
|
|
case IKCtrlData.IKAttachType.NewPoint:
|
|
@@ -493,15 +517,15 @@ public abstract class IKCtrlData
|
|
|
if (data.BlendType == IKCtrlData.IKBlendType.IK_To_IK)
|
|
|
{
|
|
|
this.m_IKTarget.position = Vector3.Lerp(this.BlendPosRot.pos, this.m_IKTarget.position, data.BlendWeight);
|
|
|
- this.PositionWeight = this.m_IKWeight;
|
|
|
+ this.PositionWeight = this.m_PosWeightBase;
|
|
|
}
|
|
|
else if (data.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
|
|
|
{
|
|
|
- this.PositionWeight = this.m_IKWeight * (1f - data.BlendWeight);
|
|
|
+ this.PositionWeight = this.m_PosWeightBase * (1f - data.BlendWeight);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- this.PositionWeight = this.m_IKWeight * data.BlendWeight;
|
|
|
+ this.PositionWeight = this.m_PosWeightBase * data.BlendWeight;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -563,24 +587,24 @@ public abstract class IKCtrlData
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_another, Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Vector3 f_vecOffset, bool do_animation = false, float blend_time = 0f)
|
|
|
+ public void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_another, Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Vector3 f_vecOffset, bool do_animation = false)
|
|
|
{
|
|
|
- this.SetIKSetting(attachType, is_another, tgt_maid, slot_no, attach_name, axis_bone, null, f_vecOffset, do_animation, blend_time);
|
|
|
+ this.SetIKSetting(attachType, is_another, tgt_maid, slot_no, attach_name, axis_bone, null, f_vecOffset, do_animation);
|
|
|
}
|
|
|
|
|
|
- public void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_another, Maid tgt_maid, Transform target, Vector3 f_vecOffset, bool do_animation = false, float blend_time = 0f)
|
|
|
+ public void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_another, Maid tgt_maid, Transform target, Vector3 f_vecOffset, bool do_animation = false)
|
|
|
{
|
|
|
- this.SetIKSetting(attachType, is_another, tgt_maid, -1, string.Empty, null, target, f_vecOffset, do_animation, blend_time);
|
|
|
+ this.SetIKSetting(attachType, is_another, tgt_maid, -1, string.Empty, null, target, f_vecOffset, do_animation);
|
|
|
}
|
|
|
|
|
|
- public void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_another, Transform target, Vector3 f_vecOffset, bool do_animation = false, float blend_time = 0f)
|
|
|
+ public void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_another, Transform target, Vector3 f_vecOffset, bool do_animation = false)
|
|
|
{
|
|
|
- this.SetIKSetting(attachType, is_another, null, -1, string.Empty, null, target, f_vecOffset, do_animation, blend_time);
|
|
|
+ this.SetIKSetting(attachType, is_another, null, -1, string.Empty, null, target, f_vecOffset, do_animation);
|
|
|
}
|
|
|
|
|
|
- public void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_another, Maid tgt_maid, string bone_name, Transform target, Vector3 f_vecOffset, bool do_animation = false, float blend_time = 0f)
|
|
|
+ public void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_another, Maid tgt_maid, string bone_name, Transform target, Vector3 f_vecOffset, bool do_animation = false)
|
|
|
{
|
|
|
- this.SetIKSetting(attachType, is_another, tgt_maid, -1, bone_name, null, target, f_vecOffset, do_animation, blend_time);
|
|
|
+ this.SetIKSetting(attachType, is_another, tgt_maid, -1, bone_name, null, target, f_vecOffset, do_animation);
|
|
|
}
|
|
|
|
|
|
public virtual void Update()
|
|
@@ -606,7 +630,7 @@ public abstract class IKCtrlData
|
|
|
this.ApplyIKSetting(this.RotateIK);
|
|
|
}
|
|
|
|
|
|
- public virtual void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_next, Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Transform target, Vector3 f_vecOffset, bool do_animation = false, float blend_time = 0f)
|
|
|
+ public virtual void SetIKSetting(IKCtrlData.IKAttachType attachType, bool is_next, Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Transform target, Vector3 f_vecOffset, bool do_animation = false)
|
|
|
{
|
|
|
this.GetIKParam(attachType, true, is_next).ChangePointType(attachType);
|
|
|
if (this.GetIKParam(attachType, true, is_next).MyType != attachType)
|
|
@@ -618,11 +642,11 @@ public abstract class IKCtrlData
|
|
|
this.m_PosRotOffset.Recet();
|
|
|
this.m_FirstPosRotOffset.Recet();
|
|
|
this.m_FirstTgtPosRot.Recet();
|
|
|
- this.GetIKParam(attachType, true, is_next).SetIKSetting(tgt_maid, slot_no, attach_name, axis_bone, target, f_vecOffset, do_animation, blend_time);
|
|
|
+ this.GetIKParam(attachType, true, is_next).SetIKSetting(tgt_maid, slot_no, attach_name, axis_bone, target, f_vecOffset, do_animation);
|
|
|
this.GetFlagData(attachType).IsFlagChange();
|
|
|
}
|
|
|
|
|
|
- public virtual void Detach(IKCtrlData.IKAttachType attachType, float blend_time = 0f)
|
|
|
+ public virtual void Detach(IKCtrlData.IKAttachType attachType)
|
|
|
{
|
|
|
this.OffsetBone = false;
|
|
|
this.OffsetWorld = false;
|
|
@@ -630,18 +654,22 @@ public abstract class IKCtrlData
|
|
|
this.m_BoneTgtPair.PosOffset = Vector3.zero;
|
|
|
this.BlendPosRot.Copy(this.m_lastIKPosRot);
|
|
|
this.GetFlagData(attachType).Reset();
|
|
|
- this.GetIKParam(attachType, true, false).Detach(blend_time);
|
|
|
- this.GetIKParam(attachType, true, true).Detach(blend_time);
|
|
|
+ this.GetIKParam(attachType, true, false).Detach();
|
|
|
+ this.GetIKParam(attachType, true, true).Detach();
|
|
|
}
|
|
|
|
|
|
public virtual void LateUpdate()
|
|
|
{
|
|
|
if (this.IsIKExec && this.m_DrawLine && !this.MyIKCtrl.IsUpdateLate)
|
|
|
{
|
|
|
- KasaiUtility.DrawObjAxis(this.TargetBone, 0.0625f);
|
|
|
- if (!this.OldIkExec)
|
|
|
+ if (this.PositionWeight > 0f || this.RotationWeight > 0f)
|
|
|
+ {
|
|
|
+ KasaiUtility.DrawObjAxis(this.TargetBone, 0.0625f);
|
|
|
+ }
|
|
|
+ if (!this.OldIkExec && (this.PositionWeight > 0f || this.RotationWeight > 0f))
|
|
|
{
|
|
|
Color color = (!this.PointIK.IsIKExec) ? Color.cyan : Color.yellow;
|
|
|
+ color.a = ((!this.PointIK.IsIKExec) ? this.RotationWeight : this.PositionWeight);
|
|
|
for (int i = 0; i < this.ChainBones.Length - 1; i++)
|
|
|
{
|
|
|
Debug.DrawLine(this.ChainBones[i].position, this.ChainBones[i + 1].position, color);
|
|
@@ -711,7 +739,11 @@ public abstract class IKCtrlData
|
|
|
|
|
|
[SerializeField]
|
|
|
[Range(0f, 1f)]
|
|
|
- protected float m_IKWeight = 1f;
|
|
|
+ protected float m_PosWeightBase = 1f;
|
|
|
+
|
|
|
+ [SerializeField]
|
|
|
+ [Range(0f, 1f)]
|
|
|
+ protected float m_RotWeightBase = 1f;
|
|
|
|
|
|
[SerializeField]
|
|
|
protected bool m_ForceIK;
|
|
@@ -943,11 +975,25 @@ public abstract class IKCtrlData
|
|
|
this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
|
|
|
}
|
|
|
|
|
|
+ public float BlendTime
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return (!this.IKCtrl) ? -1f : this.IKCtrl.BlendTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public IKCtrlData.IKAttachType MyType { get; private set; }
|
|
|
|
|
|
public IKCtrlData.IKBlendType BlendType { get; private set; }
|
|
|
|
|
|
- public bool DoIKBlend { get; private set; }
|
|
|
+ public bool DoIKBlend
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return this.m_DoIKBlend && this.BlendTime > 0f;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public bool IsPointAttach
|
|
|
{
|
|
@@ -1014,7 +1060,8 @@ public abstract class IKCtrlData
|
|
|
public void CheckBlendType(bool check_time = true)
|
|
|
{
|
|
|
this.BlendType = IKCtrlData.IKBlendType.IK_To_IK;
|
|
|
- this.DoIKBlend = true;
|
|
|
+ this.m_DoIKBlend = true;
|
|
|
+ float num = Vector3.Distance(this.m_lastOffset, this.TgtOffset);
|
|
|
if (this.m_lastTarget)
|
|
|
{
|
|
|
if (!this.Target && string.IsNullOrEmpty(this.Tgt_AttachName))
|
|
@@ -1023,7 +1070,7 @@ public abstract class IKCtrlData
|
|
|
}
|
|
|
else if (this.Target)
|
|
|
{
|
|
|
- this.DoIKBlend = (this.m_lastTarget != this.Target);
|
|
|
+ this.m_DoIKBlend = (this.m_lastTarget != this.Target || num > 0.01f);
|
|
|
}
|
|
|
}
|
|
|
else if (!string.IsNullOrEmpty(this.m_lastAttachName))
|
|
@@ -1034,7 +1081,7 @@ public abstract class IKCtrlData
|
|
|
}
|
|
|
else if (!this.Target)
|
|
|
{
|
|
|
- this.DoIKBlend = (this.m_lastAttachName != this.Tgt_AttachName || this.m_lastTgtMaid != this.TgtMaid);
|
|
|
+ this.m_DoIKBlend = (this.m_lastAttachName != this.Tgt_AttachName || this.m_lastTgtMaid != this.TgtMaid || num > 0.01f);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -1043,20 +1090,17 @@ public abstract class IKCtrlData
|
|
|
if (!this.Target && string.IsNullOrEmpty(this.Tgt_AttachName))
|
|
|
{
|
|
|
this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
|
|
|
- this.DoIKBlend = false;
|
|
|
+ this.m_DoIKBlend = false;
|
|
|
}
|
|
|
}
|
|
|
- if (check_time)
|
|
|
- {
|
|
|
- this.DoIKBlend &= (this.BlendTime > 0f);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- public void SetLastTarget(string attach_name, Maid maid, Transform target)
|
|
|
+ public void SetLastTarget(string attach_name, Maid maid, Transform target, Vector3 offset)
|
|
|
{
|
|
|
this.m_lastAttachName = attach_name;
|
|
|
this.m_lastTgtMaid = maid;
|
|
|
this.m_lastTarget = target;
|
|
|
+ this.m_lastOffset = offset;
|
|
|
}
|
|
|
|
|
|
public void BlendRecet(bool elpsed_only = false)
|
|
@@ -1064,15 +1108,14 @@ public abstract class IKCtrlData
|
|
|
this.ElapsedTime = 0f;
|
|
|
if (!elpsed_only)
|
|
|
{
|
|
|
- this.DoIKBlend = false;
|
|
|
- this.BlendTime = -1f;
|
|
|
+ this.m_DoIKBlend = false;
|
|
|
this.BlendType = IKCtrlData.IKBlendType.Not_Blend;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void SetIKSetting(Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Transform target, Vector3 f_vecOffset, bool do_animation, float blend_time)
|
|
|
+ public void SetIKSetting(Maid tgt_maid, int slot_no, string attach_name, Transform axis_bone, Transform target, Vector3 f_vecOffset, bool do_animation)
|
|
|
{
|
|
|
- this.SetLastTarget(this.Tgt_AttachName, this.TgtMaid, this.Target);
|
|
|
+ this.SetLastTarget(this.Tgt_AttachName, this.TgtMaid, this.Target, this.TgtOffset);
|
|
|
this.TgtMaid = tgt_maid;
|
|
|
this.Tgt_AttachSlot = slot_no;
|
|
|
this.Tgt_AttachName = attach_name;
|
|
@@ -1087,18 +1130,16 @@ public abstract class IKCtrlData
|
|
|
this.TgtOffset = KasaiUtility.AngleRimmit360(f_vecOffset);
|
|
|
}
|
|
|
this.BlendRecet(false);
|
|
|
- this.BlendTime = blend_time;
|
|
|
this.CheckBlendType(true);
|
|
|
this.DoAnimation = do_animation;
|
|
|
this.IsIKExec = true;
|
|
|
this.FirstFrame = true;
|
|
|
}
|
|
|
|
|
|
- public void Detach(float blend_time = 0f)
|
|
|
+ public void Detach()
|
|
|
{
|
|
|
this.BlendRecet(false);
|
|
|
- this.BlendTime = blend_time;
|
|
|
- this.SetLastTarget(this.Tgt_AttachName, this.TgtMaid, this.Target);
|
|
|
+ this.SetLastTarget(this.Tgt_AttachName, this.TgtMaid, this.Target, this.TgtOffset);
|
|
|
this.TgtMaid = null;
|
|
|
this.Tgt_AttachSlot = -1;
|
|
|
this.Tgt_AttachName = string.Empty;
|
|
@@ -1119,6 +1160,10 @@ public abstract class IKCtrlData
|
|
|
|
|
|
private Maid m_lastTgtMaid;
|
|
|
|
|
|
+ private Vector3 m_lastOffset = Vector3.zero;
|
|
|
+
|
|
|
+ private bool m_DoIKBlend;
|
|
|
+
|
|
|
public Transform Target;
|
|
|
|
|
|
public Vector3 TgtOffset;
|
|
@@ -1135,8 +1180,6 @@ public abstract class IKCtrlData
|
|
|
|
|
|
public Transform AxisTgt;
|
|
|
|
|
|
- public float BlendTime = -1f;
|
|
|
-
|
|
|
public float ElapsedTime;
|
|
|
|
|
|
[HideInInspector]
|
|
@@ -1150,6 +1193,9 @@ public abstract class IKCtrlData
|
|
|
[HideInInspector]
|
|
|
public bool DoSetOffset;
|
|
|
|
|
|
+ [HideInInspector]
|
|
|
+ public FullBodyIKCtrl IKCtrl;
|
|
|
+
|
|
|
public readonly bool IsNext;
|
|
|
}
|
|
|
}
|