private void Execute(DecalEntityChunk entityChunk, DecalCachedChunk cachedChunk, int count) { if (count == 0) { return; } cachedChunk.currentJobHandle.Complete(); // Make sure draw order is up to date var material = entityChunk.material; if (material.HasProperty("_DrawOrder")) { cachedChunk.drawOrder = material.GetInt("_DrawOrder"); } // Shader can change any time in editor, so we have to update passes each time #if !UNITY_EDITOR if (!cachedChunk.isCreated) #endif { int passIndexDBuffer = material.FindPass(DecalShaderPassNames.DBufferProjector); cachedChunk.passIndexDBuffer = passIndexDBuffer; int passIndexEmissive = material.FindPass(DecalShaderPassNames.DecalProjectorForwardEmissive); cachedChunk.passIndexEmissive = passIndexEmissive; int passIndexScreenSpace = material.FindPass(DecalShaderPassNames.DecalScreenSpaceProjector); cachedChunk.passIndexScreenSpace = passIndexScreenSpace; int passIndexGBuffer = material.FindPass(DecalShaderPassNames.DecalGBufferProjector); cachedChunk.passIndexGBuffer = passIndexGBuffer; cachedChunk.isCreated = true; } using (new ProfilingScope(null, m_SamplerJob)) { UpdateTransformsJob updateTransformJob = new UpdateTransformsJob() { positions = cachedChunk.positions, rotations = cachedChunk.rotation, scales = cachedChunk.scales, dirty = cachedChunk.dirty, scaleModes = cachedChunk.scaleModes, sizeOffsets = cachedChunk.sizeOffsets, decalToWorlds = cachedChunk.decalToWorlds, normalToWorlds = cachedChunk.normalToWorlds, boundingSpheres = cachedChunk.boundingSpheres, minDistance = 0.0001f, }; var handle = updateTransformJob.Schedule(entityChunk.transformAccessArray); cachedChunk.currentJobHandle = handle; } }
public static JobHandle Begin(TransformAccessArray array, NativeArray <float3> positions, JobHandle dependency) { UpdateTransformsJob job = new UpdateTransformsJob() { Positions = positions }; return(IJobParallelForTransformExtensions.Schedule(job, array, dependency)); }
void Update() { if (_moveJob.IsCompleted) { _moveJob.Complete(); _moveJob = MoveJob.Begin(_positions, _batchSize); } _updateTransformJob = UpdateTransformsJob.Begin(_transforms, _positions, _moveJob); }