Beispiel #1
0
        private void Update(EvaluationContext context)
        {
            if (!_initialized || TriggerReset.GetValue(context))
            {
                Result.Value = DefaultValue.GetValue(context);
                _initialized = true;
            }

            var triggered = Running.GetValue(context);

            if (OnlyCountChanges.GetValue(context) && triggered == _lastTrigger)
            {
                return;
            }

            _lastTrigger = triggered;

            if (triggered)
            {
                Result.Value += Increment.GetValue(context);
            }

            var modulo = Modulo.GetValue(context);

            if (modulo != 0)
            {
                Result.Value %= modulo;
            }
        }
Beispiel #2
0
        private void Update(EvaluationContext context)
        {
            if (IsActve.GetValue(context))
            {
                _maxPointCount = MaxPointCount.GetValue(context);

                if (TriggerReset.GetValue(context))
                {
                    Reset();
                }

                var isMouseDown = IsMouseButtonDown.GetValue(context);
                if (!isMouseDown && _mouseWasDown)
                {
                    if (_currentStrokeLength == 1 && _writeIndex > 0) // add to points for single click to make it visible as a dot
                    {
                        var lastPoint = _pointList.TypedElements[_writeIndex - 1];
                        lastPoint.Position = PointFromMousePos(context, _lastMousePos + new Vector2(0, 0.01f));
                        AppendPoint(lastPoint);
                    }
                    AppendPoint(Point.Separator());
                    _currentStrokeLength = 0;
                }
                else if (isMouseDown)
                {
                    var mousePos = MousePos.GetValue(context);
                    if (!_mouseWasDown || Vector2.Distance(_lastMousePos, mousePos) > 0.001f)
                    {
                        AppendPoint(new Point()
                        {
                            Position    = PointFromMousePos(context, mousePos),
                            Orientation = Quaternion.Identity,
                            W           = 1,
                        });
                        AppendPoint(Point.Separator(), advanceIndex: false);
                        _currentStrokeLength++;
                    }
                    _lastMousePos = mousePos;
                }

                _mouseWasDown = isMouseDown;
            }

            PointList.Value = _pointList;
        }
Beispiel #3
0
        private void Update(EvaluationContext context)
        {
            var startPosition = StartValue.GetValue(context);
            var modulo        = Modulo.GetValue(context);
            var increment     = Increment.GetValue(context);

            _rate     = Rate.GetValue(context);
            _phase    = Phase.GetValue(context);
            _blending = Blending.GetValue(context);
            var reset = TriggerReset.GetValue(context);
            var jump  = TriggerCount.GetValue(context);

            //var jump = false;

            if (!_initialized || reset || float.IsNaN(_count))
            {
                _count       = 0;
                _initialized = true;
                jump         = true;
            }

            _beatTime = EvaluationContext.BeatTime;

            if (UseRate)
            {
                var activationIndex = (int)(_beatTime * _rate + _phase);
                if (activationIndex != _lastActivationIndex)
                {
                    //Log.Debug($"ai {activationIndex}  != {_lastActivationIndex}  rate={_rate} t = {_beatTime} ");
                    _lastActivationIndex = activationIndex;
                    jump = true;
                }
            }

            if (jump)
            {
                if (modulo > 0.001f)
                {
                    _jumpStartOffset   = _jumpTargetOffset;
                    _jumpTargetOffset += 1;
                }
                else
                {
                    _jumpStartOffset  = _count;
                    _jumpTargetOffset = _count + increment;
                }

                // if (_jumpTargetOffset > modulo)
                // {
                //     _count = 0;
                //     _jumpStartOffset = 0;
                //     _jumpTargetOffset = increment;
                // }
                _lastJumpTime = _beatTime;
            }

            if (_blending >= 0.001)
            {
                var t = (Fragment / _blending).Clamp(0, 1);
                if (SmoothBlending.GetValue(context))
                {
                    t = MathUtils.SmootherStep(0, 1, t);
                }

                _count = MathUtils.Lerp(_jumpStartOffset, _jumpTargetOffset, t);
            }
            else
            {
                _count = _jumpTargetOffset;
            }

            if (modulo > 0.001f)
            {
                Result.Value = (_count % modulo) * increment + startPosition;
            }
            else
            {
                Result.Value = _count + startPosition;
            }

            WasStep.Value = jump;
            Result.DirtyFlag.Clear();
            WasStep.DirtyFlag.Clear();
        }