Beispiel #1
0
    void Update()
    {
        for (int i = 0; i < num; i++)
        {
            rnd[i] = new Random(seed.NextUInt());
        }
        var jobWall = new UpdateWall {
            position = pos, accel = acc, scale = areaSize
        };
        var jobSmlt = new UpdateSmlt {
            position = pos, velocity = vel, accel = acc, dstThreshold = distThreshold, weights = simWeight
        };
        var jobMove = new UpdateMove {
            position = pos, velocity = vel, accel = acc, dt = Time.deltaTime, limit = velThreshold
        };
        var jobBlck = new UpdateBlck {
            position = pos, result = rst
        };
        var handlerWall = jobWall.Schedule(num, 0);
        var handlerSmlt = jobSmlt.Schedule(num, 0, handlerWall);
        var handlerMove = jobMove.Schedule(trs, handlerSmlt);
        var handlerBlck = jobBlck.Schedule(handlerMove);

        handlerBlck.Complete();
    }
Beispiel #2
0
    void Update()
    {
        if (!systemReady)
        {
            return;
        }
        handle.Complete();
        updateMove = new UpdateMove()
        {
            Entities = _entities
        };

        handle = updateMove.Schedule(accessArray);
        count++;
        avg += Time.deltaTime;
        if (count == 30)
        {
            ms = avg /= 30; count = 0; avg = 0;
        }

        //for (int i = 0; i < entities.Length - 1; i++) MoveEntity(i);
    }
    void Update()
    {
        // add instance
        if (Input.GetKey(add))
        {
            AddInstance();
        }
        // remove instance
        if (num > 0 && Input.GetKey(remove))
        {
            var i = UnityEngine.Random.Range(0, num);
            Destroy(trs[i].gameObject);
            pos.RemoveAtSwapBack(i);
            vel.RemoveAtSwapBack(i);
            acc.RemoveAtSwapBack(i);
            trs.RemoveAtSwapBack(i);
            num--;
        }

        var jobWall = new UpdateWall {
            position = pos.AsDeferredJobArray(), accel = acc.AsDeferredJobArray(), scale = areaSize
        };
        var jobSmlt = new UpdateSmlt {
            position = pos.AsDeferredJobArray(), velocity = vel.AsDeferredJobArray(), accel = acc.AsDeferredJobArray(), dstThreshold = distThreshold, weights = simWeight
        };
        var jobMove = new UpdateMove {
            position = pos.AsDeferredJobArray(), velocity = vel.AsDeferredJobArray(), accel = acc.AsDeferredJobArray(), dt = Time.deltaTime, limit = velThreshold
        };
        var jobBlck = new UpdateBlck {
            position = pos.AsDeferredJobArray(), result = rst
        };
        var handlerWall = jobWall.Schedule(num, 0);
        var handlerSmlt = jobSmlt.Schedule(num, 0, handlerWall);
        var handlerMove = jobMove.Schedule(trs, handlerSmlt);
        var handlerBlck = jobBlck.Schedule(handlerMove);

        handlerBlck.Complete();
    }