예제 #1
0
    void Update()
    {
        var dt           = Time.deltaTime;
        var vectorBounds = new VectorBounds(bounds.min, bounds.max, boundsMode);

        System.Action <int> body = (i) => {
            var c     = _characters [i];
            var speed = c.velocity.magnitude;
            c.time        += speed * dt;
            c.position    += c.velocity * dt;
            c.position     = vectorBounds.Clamp(c.position);
            _positions [i] = _characters [i].position;
        };
        if (mode == ModeEnum.Sequential)
        {
            for (var i = 0; i < _characters.Length; i++)
            {
                body(i);
            }
        }
        else
        {
            Parallel.For(0, _characters.Length, body);
        }
        _positionBuf.SetData(_positions);
    }
예제 #2
0
    void Update()
    {
        var dt = Time.deltaTime;
        var vectorBounds = new VectorBounds (bounds.min, bounds.max, boundsMode);

        System.Action<int> body = (i) => {
            var c = _characters [i];
            var speed = c.velocity.magnitude;
            c.time += speed * dt;
            c.position += c.velocity * dt;
            c.position = vectorBounds.Clamp(c.position);
            _positions [i] = _characters [i].position;
        };
        if (mode == ModeEnum.Sequential) {
            for (var i = 0; i < _characters.Length; i++)
                body(i);
        } else {
            Parallel.For(0, _characters.Length, body);
        }
        _positionBuf.SetData (_positions);
    }