// did bezier CP move from last set state?
 protected static bool ControlPointMoved(BezierCPComponent cp)
 {
     if (!cp)
     {
         throw new System.ArgumentException("Null ref. exception. Check to see if reference is missing in BezierCPComponent Script...");
     }
     return(!EqualPoint(cp.transform.localPosition, cp.Lp));
 }
        // For Bezier Control Point movement
        protected override void OnUpdate()
        {
            foreach (var entity in GetEntities <CPFilter>())
            {
                BezierCPComponent cp = entity.cp;
                if (!cp.tangentInfo.tangent)
                {
                    continue;
                }

                // if this transform moves then update neighbors
                if (ControlPointMoved(cp))
                {
                    Vector3 lp = cp.transform.parent.TransformPoint(cp.Lp);
                    Vector3 v  = cp.transform.position - lp;
                    BezierCPComponent.TangentInfo ti = cp.tangentInfo;
                    ti.adjcp0.transform.position += v;
                    ti.adjcp0.Lp = ti.adjcp0.transform.localPosition;
                    ti.adjcp1.transform.position += v;
                    ti.adjcp1.Lp = ti.adjcp1.transform.localPosition;
                    cp.Lp        = cp.transform.localPosition;
                }
                // if neighbor 0 moves then update neighbor 1 position
                else if (ControlPointMoved(cp.tangentInfo.adjcp0))
                {
                    Transform A0 = cp.tangentInfo.adjcp0.transform;
                    Transform C  = cp.transform;
                    Transform A1 = cp.tangentInfo.adjcp1.transform;

                    if (cp.tangentInfo.lockDirection)
                    {
                        Vector3 v = A0.position - C.position;
                        if (!cp.tangentInfo.lockDirectionSet)
                        {
                            cp.tangentInfo.lockDir          = v.normalized;
                            cp.tangentInfo.lockDirectionSet = true;
                        }
                        float d = Vector3.Dot(v, cp.tangentInfo.lockDir);
                        A0.position = C.position + d * cp.tangentInfo.lockDir;
                    }
                    else
                    {
                        Vector3 v = C.position - A0.position;
                        float   d = (C.position - A1.position).magnitude;
                        v.Normalize();
                        A1.position = cp.transform.position + d * v;
                        cp.tangentInfo.lockDirectionSet = false;
                    }

                    cp.tangentInfo.adjcp1.Lp = cp.tangentInfo.adjcp1.transform.localPosition;
                    cp.tangentInfo.adjcp0.Lp = cp.tangentInfo.adjcp0.transform.localPosition;
                }
                // opposite of above
                else if (ControlPointMoved(cp.tangentInfo.adjcp1))
                {
                    Transform A0 = cp.tangentInfo.adjcp0.transform;
                    Transform C  = cp.transform;
                    Transform A1 = cp.tangentInfo.adjcp1.transform;

                    if (cp.tangentInfo.lockDirection)
                    {
                        Vector3 v = A1.position - C.position;
                        if (!cp.tangentInfo.lockDirectionSet)
                        {
                            cp.tangentInfo.lockDir          = v.normalized;
                            cp.tangentInfo.lockDirectionSet = true;
                        }
                        float d = Vector3.Dot(v, cp.tangentInfo.lockDir);
                        A1.position = C.position + d * cp.tangentInfo.lockDir;
                    }
                    else
                    {
                        Vector3 v = C.position - A1.transform.position;
                        float   d = (C.position - A0.position).magnitude;
                        v.Normalize();
                        A0.position = C.position + d * v;
                    }

                    cp.tangentInfo.adjcp1.Lp = A1.localPosition;
                    cp.tangentInfo.adjcp0.Lp = A0.localPosition;
                }
            }
        }