コード例 #1
0
    private void Update()
    {
        for (int i = 0; i < _transformAccessArray.length; i++)
        {
            _positions[i]  = new float3(_transformAccessArray[i].position);
            _directions[i] = new float3(_transformAccessArray[i].forward);
        }

        var boidSystemJob = new BoidSystemJob()
        {
            boidResultant  = _boidResultant,
            boidPositions  = _positions,
            boidDirections = _directions,
            settings       = settings
        };
        var applyBoidPositionJob = new ApplyPositionJob()
        {
            boidResultant = _boidResultant,
            avoidancehits = _avoidanceHits,
            settings      = settings
        };
        JobHandle boidSimulation  = boidSystemJob.Schedule(boidNumber, 64);
        JobHandle avoidanceHandle = SphereRaycastAhead(_transformAccessArray, boidSimulation);
        JobHandle finalHandle     = applyBoidPositionJob.Schedule(_transformAccessArray, JobHandle.CombineDependencies(avoidanceHandle, boidSimulation));

        finalHandle.Complete();
    }
コード例 #2
0
    private void Update()
    {
        var applyBoidPositionJob = new ApplyPositionJob()
        {
            settings      = settings,
            underHits     = _surfaceNormalsHits,
            avoidanceHits = _avoidanceHits
        };
        JobHandle crowdSimulation = SphereRaycastAhead(_transformAccessArray);
        JobHandle surfaceHandle   = SphereCastUnder(_transformAccessArray);
        JobHandle finalHandle     = applyBoidPositionJob.Schedule(_transformAccessArray,
                                                                  JobHandle.CombineDependencies(surfaceHandle, crowdSimulation));

        finalHandle.Complete();
    }