public static BlockExpression RotateLerp(Ex target, Ex source, TExArgCtx bpi, bool isRate, bool isTrue, Ex rate) { if (isRate) { rate = rate.Mul(M.degRad); } if (isTrue) { rate = rate.Mul(ETime.FRAME_TIME); } TExV2 v = TExV2.Variable(); TEx <float> ang = ExUtils.VFloat(); Expression[] exprs = new Expression[3]; exprs[1] = ang.Is(RadDiff(target, v)); if (isTrue) { var key = bpi.Ctx.NameWithSuffix("_RotateLerpKey"); exprs[0] = v.Is( Ex.Condition(FiringCtx.Contains <Vector2>(bpi, key), FiringCtx.GetValue <Vector2>(bpi, key), FiringCtx.SetValue <Vector2>(bpi, key, source) )); exprs[2] = FiringCtx.SetValue <Vector2>(bpi, key, RotateRad(isRate ? (Ex)Limit(rate, ang) : ang.Mul(rate), v)); } else { exprs[0] = v.Is(source); exprs[2] = RotateRad(isRate ? (Ex)Limit(bpi.t.Mul(rate), ang) : ang.Mul(Min(bpi.t.Mul(rate), E1)), v); } return(Ex.Block(new ParameterExpression[] { v, ang }, exprs)); }
private static Ex dGetDegIndex(TEx <double> angleDeg) => Ex.And(angleDeg.Mul(ExC(degRatio)).As <int>(), ExC(LookupMask));
private static Ex dGetRadIndex(TEx <double> angleRad) => Ex.And(angleRad.Mul(ExC(radRatio)).As <int>(), ExC(LookupMask));