protected override void OnUpdate(ref JobHandle jobHandle) { if (Query == null) { return; } if (CurrentUpdateType == ModuleUpdateType.Job) { jobHandle = new ClearJob { HashMap = m_OwnerToAbilityMap, TargetCapacity = Query.CalculateEntityCount() + 32 }.Schedule(jobHandle); jobHandle = new SearchJob { OwnerToAbilityMap = m_OwnerToAbilityMap.AsParallelWriter() }.Schedule(Query, jobHandle); } else { new ClearJob { HashMap = m_OwnerToAbilityMap, TargetCapacity = Query.CalculateEntityCount() + 32 }.Run(); new SearchJob { OwnerToAbilityMap = m_OwnerToAbilityMap.AsParallelWriter() }.Run(Query); } }
protected override JobHandle OnUpdate(JobHandle inputDeps) //1,000,000 insert = 5ms { var job = new AddEntryJob { m = _map.ToConcurrent() }.Schedule(this, inputDeps); var handle = new ClearJob { m = _map }.Schedule(job); return(handle); }
private void Awake() { const int vertResolution = 1080; const float aspect = 16f / 9f; const float vfov = 50f; const float aperture = 0.002f; int horiResolution = (int)math.round(vertResolution * aspect); _fullQuality.Resolution = new int2(horiResolution, vertResolution); _debugQuality.Resolution = _fullQuality.Resolution; var position = new float3(10f, 1.5f, -2f); var lookDir = new float3(12, 1, -10) - position; var focus = math.length(lookDir); var rotation = quaternion.LookRotation(lookDir / focus, new float3(0, 1, 0)); _camera = new Camera(vfov, aspect, aperture, focus); _camera.Position = position; _camera.Rotation = rotation; Debug.Log("Resolution = " + _fullQuality.Resolution); int totalPixels = (int)(_fullQuality.Resolution.x * _fullQuality.Resolution.y); _screen = new NativeArray <float3>(totalPixels, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); _clear = new ClearJob(); _clear.Buffer = _screen; _scene = MakeScene(); _fibs = new NativeArray <float3>(4096, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); Math.GenerateFibonacciSphere(_fibs); _trace = new TraceJob(); _trace.Screen = _screen; _trace.Fibs = _fibs; _trace.Camera = _camera; _trace.Scene = _scene; _trace.RayCounter = new NativeArray <ulong>(1, Allocator.Persistent, NativeArrayOptions.ClearMemory); _tex = new Texture2D((int)_fullQuality.Resolution.x, (int)_fullQuality.Resolution.y, TextureFormat.ARGB32, false, true); _tex.filterMode = FilterMode.Point; Debug.Log(-2.5f % 1f); }
protected override void OnUpdate() { if (First) { Entities.ForEach((Entity entity, ref PathFindingData data) => { if (!hasDensityPresent && data.avoidMethod == CollisionAvoidanceMethod.DensityGrid) { hasDensityPresent = true; } }); } if (!hasDensityPresent) { return; } MapChanged(); EntityQuery entityQuery = GetEntityQuery(typeof(Translation), typeof(Walker), typeof(CollisionParameters)); var clearJob = new ClearJob() { array = densityMatrix }; var clearHandle = clearJob.Schedule(densityMatrix.Length, batchSize); var job = new SetProbabilityJob() { quadrantHashMap = densityMatrix, oneLayer = Map.OneLayer, max = Map.Values }; var handle = JobForEachExtensions.Schedule(job, entityQuery, clearHandle); ForeachColliders(); var addJob = new AddArrayJob() { from = collidersDensity, to = densityMatrix }; var addHandle = addJob.Schedule(densityMatrix.Length, batchSize, handle); addHandle.Complete(); //Debug(); }
private void NewGoalPointAdded() { var clearJob = new ClearJob() { array = densityMatrix, array2 = tempMatrix, minIndex = densityMatrix.Length - Map.OneLayer * (goalPoints.Length - LastGoalPointCount) }; var clearHandle = clearJob.Schedule(densityMatrix.Length, batchSize); clearHandle.Complete(); while (LastGoalPointCount < goalPoints.Length) { var index = QuadrantVariables.IndexFromPosition(goalPoints[LastGoalPointCount], float3.zero, Map.Values); densityMatrix[index.key + Map.OneLayer * LastGoalPointCount] = 0.5f; tempMatrix[index.key + Map.OneLayer * LastGoalPointCount] = 0.5f; LastGoalPointCount++; } }