Ejemplo n.º 1
0
        private static bool RedirectStreams(Process /*!*/ process, PhpArray /*!*/ descriptors, PhpArray /*!*/ pipes)
        {
            using (var descriptors_enum = descriptors.GetFastEnumerator())
                while (descriptors_enum.MoveNext())
                {
                    int desc_no = descriptors_enum.CurrentKey.Integer;

                    StreamAccessOptions access;
                    Stream stream;
                    switch (desc_no)
                    {
                    case 0: stream = process.StandardInput.BaseStream; access = StreamAccessOptions.Write; break;

                    case 1: stream = process.StandardOutput.BaseStream; access = StreamAccessOptions.Read; break;

                    case 2: stream = process.StandardError.BaseStream; access = StreamAccessOptions.Read; break;

                    default: Debug.Fail(null); return(false);
                    }

                    object      value = PhpVariable.Dereference(descriptors_enum.CurrentValue);
                    PhpResource resource;
                    PhpArray    array;

                    if ((array = PhpArray.AsPhpArray(value)) != null)
                    {
                        if (!array.Contains(0))
                        {
                            // value must be either a resource or an array:
                            PhpException.Throw(PhpError.Warning, LibResources.GetString("descriptor_item_missing_qualifier", desc_no));
                            return(false);
                        }

                        string qualifier = Core.Convert.ObjectToString(array[0]);

                        switch (qualifier)
                        {
                        case "pipe":
                        {
                            // mode is ignored (it's determined by the stream):
                            PhpStream php_stream = new NativeStream(stream, null, access, String.Empty, StreamContext.Default);
                            pipes.Add(desc_no, php_stream);
                            break;
                        }

                        case "file":
                        {
                            if (!array.Contains(1))
                            {
                                PhpException.Throw(PhpError.Warning, LibResources.GetString("descriptor_item_missing_file_name", desc_no));
                                return(false);
                            }

                            if (!array.Contains(2))
                            {
                                PhpException.Throw(PhpError.Warning, LibResources.GetString("descriptor_item_missing_mode", desc_no));
                                return(false);
                            }

                            string path = Core.Convert.ObjectToString(array[1]);
                            string mode = Core.Convert.ObjectToString(array[2]);

                            PhpStream php_stream = PhpStream.Open(path, mode, StreamOpenOptions.Empty, StreamContext.Default);
                            if (php_stream == null)
                            {
                                return(false);
                            }

                            if (!ActivePipe.BeginIO(stream, php_stream, access, desc_no))
                            {
                                return(false);
                            }
                            break;
                        }

                        default:
                            PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_handle_qualifier", qualifier));
                            return(false);
                        }
                    }
                    else if ((resource = value as PhpResource) != null)
                    {
                        PhpStream php_stream = PhpStream.GetValid(resource);
                        if (php_stream == null)
                        {
                            return(false);
                        }

                        if (!ActivePipe.BeginIO(stream, php_stream, access, desc_no))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        // value must be either a resource or an array:
                        PhpException.Throw(PhpError.Warning, LibResources.GetString("descriptor_item_not_array_nor_resource", desc_no));
                        return(false);
                    }
                }

            return(true);
        }
Ejemplo n.º 2
0
 /// <inheritdoc />
 public override unsafe void Serialize(ref double value)
 {
     fixed(double *valuePtr = &value)
     * ((ulong *)valuePtr) = NativeStream.ReadUInt64();
 }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public override void Serialize(ref ushort value)
 {
     value = NativeStream.ReadUInt16();
 }
Ejemplo n.º 4
0
 /// <inheritdoc />
 public override void Serialize(ref ulong value)
 {
     NativeStream.Write(value);
 }
Ejemplo n.º 5
0
 /// <inheritdoc/>
 public override void Serialize(IntPtr memory, int count)
 {
     NativeStream.Read(memory, count);
 }
Ejemplo n.º 6
0
 /// <inheritdoc />
 public override unsafe void Serialize(ref float value)
 {
     fixed(float *valuePtr = &value)
     NativeStream.Write(*(uint *)valuePtr);
 }
Ejemplo n.º 7
0
 /// <inheritdoc />
 public override void Serialize(ref short value)
 {
     NativeStream.Write((ushort)value);
 }
Ejemplo n.º 8
0
        public void TreeOverlapPerfTest(int elementCount, bool newOverlap)
        {
            // Execute dummy job just to get Burst compilation out of the way.
            {
                var dummyStream  = new NativeStream(1, Allocator.TempJob);
                var dummyNodes   = new NativeArray <Node>(0, Allocator.TempJob);
                var dummyFilters = new NativeArray <CollisionFilter>(0, Allocator.TempJob);
                new TestTreeOverlapJob
                {
                    CollisionPairWriter = dummyStream.AsWriter(),
                    Nodes      = dummyNodes,
                    Filter     = dummyFilters,
                    NumObjects = 0,
                    DummyRun   = true
                }.Run();
                dummyStream.Dispose();
                dummyNodes.Dispose();
                dummyFilters.Dispose();
            }

            elementCount *= 2;
            int numNodes = elementCount / 3 * 2 + 4;
            var points   = new NativeArray <PointAndIndex>(elementCount, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            var aabbs    = new NativeArray <Aabb>(elementCount, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            var filters  = new NativeArray <CollisionFilter>(elementCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

            // Override filter data with default filters.
            for (int i = 0; i < filters.Length; i++)
            {
                filters[i] = CollisionFilter.Default;
            }

            InitInputWithCopyArrays(points, aabbs, filters);

            var nodes = new NativeArray <Node>(numNodes, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

            var bvh = new BoundingVolumeHierarchy(nodes);

            bvh.Build(points, aabbs, out int numNodesOut);
            bvh.CheckIntegrity();

            var collisionPairs = new NativeStream(1, Allocator.TempJob);

            var job = new TestTreeOverlapJob
            {
                Nodes               = nodes,
                Filter              = filters,
                NumObjects          = elementCount,
                CollisionPairWriter = collisionPairs.AsWriter(),
                DummyRun            = false
            };

            Measure.Method(() =>
            {
                job.Run();
            }).Definition(sampleUnit: SampleUnit.Millisecond)
            .MeasurementCount(1)
            .Run();

            points.Dispose();
            aabbs.Dispose();
            nodes.Dispose();
            collisionPairs.Dispose();
            filters.Dispose();
        }
        private static bool RedirectStreams(Context ctx, Process /*!*/ process, PhpArray /*!*/ descriptors, PhpArray /*!*/ pipes)
        {
            var descriptors_enum = descriptors.GetFastEnumerator();

            while (descriptors_enum.MoveNext())
            {
                int desc_no = descriptors_enum.CurrentKey.Integer;

                StreamAccessOptions access;
                Stream stream;
                switch (desc_no)
                {
                case 0: stream = process.StandardInput.BaseStream; access = StreamAccessOptions.Write; break;

                case 1: stream = process.StandardOutput.BaseStream; access = StreamAccessOptions.Read; break;

                case 2: stream = process.StandardError.BaseStream; access = StreamAccessOptions.Read; break;

                default: Debug.Fail(null); return(false);
                }

                var         value = descriptors_enum.CurrentValue;
                PhpResource resource;
                PhpArray    array;

                if ((array = value.AsArray()) != null)
                {
                    if (!array.Contains(0))
                    {
                        // value must be either a resource or an array:
                        PhpException.Throw(PhpError.Warning, Resources.LibResources.descriptor_item_missing_qualifier, desc_no.ToString());
                        return(false);
                    }

                    string qualifier = array[0].ToString(ctx);

                    switch (qualifier)
                    {
                    case "pipe":
                    {
                        // mode is ignored (it's determined by the stream):
                        PhpStream php_stream = new NativeStream(ctx, stream, null, access, String.Empty, StreamContext.Default);
                        pipes.Add(desc_no, php_stream);
                        break;
                    }

                    case "file":
                    {
                        if (!array.Contains(1))
                        {
                            PhpException.Throw(PhpError.Warning, Resources.LibResources.descriptor_item_missing_file_name, desc_no.ToString());
                            return(false);
                        }

                        if (!array.Contains(2))
                        {
                            PhpException.Throw(PhpError.Warning, Resources.LibResources.descriptor_item_missing_mode, desc_no.ToString());
                            return(false);
                        }

                        string path = array[1].ToString(ctx);
                        string mode = array[2].ToString(ctx);

                        PhpStream php_stream = PhpStream.Open(ctx, path, mode, StreamOpenOptions.Empty, StreamContext.Default);
                        if (php_stream == null)
                        {
                            return(false);
                        }

                        //if (!ActivePipe.BeginIO(stream, php_stream, access, desc_no)) return false;
                        //break;
                        throw new NotImplementedException();
                    }

                    default:
                        PhpException.Throw(PhpError.Warning, Resources.LibResources.invalid_handle_qualifier, qualifier);
                        return(false);
                    }
                }
                else if ((resource = value.AsResource()) != null)
                {
                    PhpStream php_stream = PhpStream.GetValid(resource);
                    if (php_stream == null)
                    {
                        return(false);
                    }

                    //if (!ActivePipe.BeginIO(stream, php_stream, access, desc_no)) return false;
                    throw new NotImplementedException();
                }
                else
                {
                    // value must be either a resource or an array:
                    PhpException.Throw(PhpError.Warning, Resources.LibResources.descriptor_item_not_array_nor_resource, desc_no.ToString());
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 10
0
        public unsafe void BuildTreeAndOverlapTasks([Values(2, 10, 33, 100)] int elementCount)
        {
            const int threadCount = 8;

            elementCount *= 2;
            int numNodes = elementCount + Constants.MaxNumTreeBranches;

            var points      = new NativeArray <PointAndIndex>(elementCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
            var aabbs       = new NativeArray <Aabb>(elementCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
            var filters     = new NativeArray <CollisionFilter>(elementCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
            var nodefilters = new NativeArray <CollisionFilter>(numNodes, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
            var branchCount = new NativeArray <int>(1, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

            InitInputWithCopyArrays(points, aabbs, filters);

            // Override filter data with default filters.
            for (int i = 0; i < filters.Length; i++)
            {
                filters[i] = CollisionFilter.Default;
            }

            for (int i = 0; i < nodefilters.Length; i++)
            {
                nodefilters[i] = CollisionFilter.Default;
            }

            var nodes = new NativeArray <Node>(numNodes, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

            var ranges           = new NativeArray <Range>(Constants.MaxNumTreeBranches, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
            var branchNodeOffset = new NativeArray <int>(Constants.MaxNumTreeBranches, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
            var shouldDoWork     = new NativeArray <int>(1, Allocator.TempJob);

            shouldDoWork[0] = 1;
            int oldBranchCount = branchCount[0];

            JobHandle handle = new BuildFirstNLevelsJob
            {
                Points            = points,
                Nodes             = (Node *)nodes.GetUnsafePtr(),
                Ranges            = ranges,
                BranchNodeOffsets = branchNodeOffset,
                BranchCount       = branchCount,
                ThreadCount       = threadCount,
                ShouldDoWork      = shouldDoWork
            }.Schedule();

            handle = new BuildBranchesJob
            {
                Points            = points,
                Aabbs             = aabbs,
                BodyFilters       = filters,
                Nodes             = (Node *)nodes.GetUnsafePtr(),
                Ranges            = ranges,
                BranchNodeOffsets = branchNodeOffset,
                BranchCount       = branchCount
            }.ScheduleUnsafeIndex0(branchCount, 1, handle);

            new FinalizeTreeJob
            {
                Aabbs             = aabbs,
                LeafFilters       = filters,
                Nodes             = (Node *)nodes.GetUnsafePtr(),
                BranchNodeOffsets = branchNodeOffset,
                NumNodes          = numNodes,
                BranchCount       = branchCount,
                ShouldDoWork      = shouldDoWork,
                OldBranchCount    = oldBranchCount
            }.Schedule(handle).Complete();

            int numBranchOverlapPairs = branchCount[0] * (branchCount[0] + 1) / 2;
            var nodePairIndices       = new NativeList <int2>(Allocator.TempJob);

            nodePairIndices.ResizeUninitialized(numBranchOverlapPairs);
            var collisionPairs = new NativeStream(numBranchOverlapPairs, Allocator.TempJob);

            handle = new Broadphase.DynamicVsDynamicBuildBranchNodePairsJob
            {
                Ranges          = ranges,
                NumBranches     = branchCount,
                NodePairIndices = nodePairIndices
            }.Schedule();

            handle = new Broadphase.DynamicVsDynamicFindOverlappingPairsJob
            {
                DynamicNodes       = nodes,
                PairWriter         = collisionPairs.AsWriter(),
                BodyFilters        = filters,
                NodePairIndices    = nodePairIndices,
                DynamicNodeFilters = nodefilters,
            }.Schedule(nodePairIndices, numBranchOverlapPairs, handle);

            handle.Complete();


            int numPairs = collisionPairs.ComputeItemCount();

            Assert.AreEqual(elementCount / 2, numPairs);
            //Debug.Log($"Num colliding pairs: {numPairs}");

            var bvh = new BoundingVolumeHierarchy(nodes);

            bvh.CheckIntegrity();


            nodePairIndices.Dispose();
            filters.Dispose();
            nodefilters.Dispose();
            nodes.Dispose();
            ranges.Dispose();
            collisionPairs.Dispose();
            branchCount.Dispose();
            shouldDoWork.Dispose();
        }
Ejemplo n.º 11
0
        public unsafe void OverlapTaskFilteringTest([Values(2, 10, 33, 100)] int elementCount)
        {
            elementCount *= 2;
            int numNodes = elementCount + Constants.MaxNumTreeBranches;

            var points      = new NativeArray <PointAndIndex>(elementCount, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            var aabbs       = new NativeArray <Aabb>(elementCount, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            var bodyFilters = new NativeArray <CollisionFilter>(elementCount, Allocator.Temp, NativeArrayOptions.UninitializedMemory);

            InitInputWithCopyArrays(points, aabbs, bodyFilters);

            var   nodes    = new NativeArray <Node>(numNodes, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            Node *nodesPtr = (Node *)nodes.GetUnsafePtr();

            var seenUnfiltered = new HashSet <BodyIndexPair>();
            {
                var bvhUnfiltered = new BoundingVolumeHierarchy(nodes);
                bvhUnfiltered.Build(points, aabbs, out int numNodesOut);
                bvhUnfiltered.CheckIntegrity();

                EverythingWriter pairWriter = new EverythingWriter {
                    SeenPairs = seenUnfiltered
                };
                BoundingVolumeHierarchy.TreeOverlap(ref pairWriter, nodesPtr, nodesPtr);
            }

            var nodeFilters = new NativeArray <CollisionFilter>(numNodes, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            var bvhFiltered = new BoundingVolumeHierarchy(nodes, nodeFilters);
            int numNodesFilteredTree;

            bvhFiltered.Build(points, aabbs, out numNodesFilteredTree);
            bvhFiltered.BuildCombinedCollisionFilter(bodyFilters, 0, numNodesFilteredTree - 1);

            var filteredCollisionPairs = new NativeStream(1, Allocator.TempJob);

            NativeStream.Writer filteredPairWriter = filteredCollisionPairs.AsWriter();
            filteredPairWriter.BeginForEachIndex(0);
            CollisionFilter *bodyFiltersPtr = (CollisionFilter *)bodyFilters.GetUnsafePtr();
            var bufferedPairs = new Broadphase.BodyPairWriter(&filteredPairWriter, bodyFiltersPtr);

            CollisionFilter *nodeFiltersPtr = (CollisionFilter *)nodeFilters.GetUnsafePtr();

            BoundingVolumeHierarchy.TreeOverlap(ref bufferedPairs, nodesPtr, nodesPtr, nodeFiltersPtr, nodeFiltersPtr);
            bufferedPairs.Close();
            filteredPairWriter.EndForEachIndex();

            NativeStream.Reader filteredPairReader = filteredCollisionPairs.AsReader();
            filteredPairReader.BeginForEachIndex(0);

            // Check that every pair in our filtered set also appears in the unfiltered set
            while (filteredPairReader.RemainingItemCount > 0)
            {
                var pair = filteredPairReader.Read <BodyIndexPair>();

                Assert.IsTrue(seenUnfiltered.Contains(pair));
                seenUnfiltered.Remove(pair); // Remove the pair
            }

            // Pairs were removed, so the only remaining ones should be filtered
            foreach (BodyIndexPair pair in seenUnfiltered)
            {
                bool shouldCollide = CollisionFilter.IsCollisionEnabled(bodyFilters[pair.BodyAIndex], bodyFilters[pair.BodyBIndex]);
                Assert.IsFalse(shouldCollide);
            }

            nodeFilters.Dispose();
            nodes.Dispose();
            bodyFilters.Dispose();
            aabbs.Dispose();
            points.Dispose();
            filteredCollisionPairs.Dispose();
        }
 public DotsFrameTrace(Allocator allocator)
 {
     NativeStream = new NativeStream(1, allocator);
     _writer      = NativeStream.AsWriter();
     _writer.BeginForEachIndex(0);
 }
Ejemplo n.º 13
0
        protected override void OnUpdate()
        {
            var ecsJH = Dependency;

            //Query arrays
            var aliveListenerEntities = m_aliveListenersQuery.ToEntityArrayAsync(Allocator.TempJob, out JobHandle aliveListenerEntitiesJH);
            var deadListenerEntities  = m_deadListenersQuery.ToEntityArrayAsync(Allocator.TempJob, out JobHandle deadListenerEntitiesJH);
            var listenerEntitiesJH    = JobHandle.CombineDependencies(aliveListenerEntitiesJH, deadListenerEntitiesJH);

            //Type handles
            var entityHandle      = GetEntityTypeHandle();
            var listenerHandle    = GetComponentTypeHandle <AudioListener>(true);
            var oneshotHandle     = GetComponentTypeHandle <AudioSourceOneShot>(false);
            var loopedHandle      = GetComponentTypeHandle <AudioSourceLooped>(false);
            var coneHandle        = GetComponentTypeHandle <AudioSourceEmitterCone>(true);
            var translationHandle = GetComponentTypeHandle <Translation>(true);
            var rotationHandle    = GetComponentTypeHandle <Rotation>(true);
            var ltwHandle         = GetComponentTypeHandle <LocalToWorld>(true);
            var parentHandle      = GetComponentTypeHandle <Parent>(true);

            var audioSettingsCdfe          = GetComponentDataFromEntity <AudioSettings>(true);
            var listenerCdfe               = GetComponentDataFromEntity <AudioListener>(true);
            var listenerGraphStateCdfe     = GetComponentDataFromEntity <ListenerGraphState>(false);
            var entityOutputGraphStateCdfe = GetComponentDataFromEntity <EntityOutputGraphState>(false);

            //Buffer
            m_currentBufferId++;
            var ildBuffer = new ManagedIldBuffer
            {
                buffer   = new NativeList <float>(Allocator.Persistent),
                channels = new NativeList <IldBufferChannel>(Allocator.Persistent),
                bufferId = m_currentBufferId
            };

            //Containers
            var destroyCommandBuffer     = latiosWorld.syncPoint.CreateDestroyCommandBuffer().AsParallelWriter();
            var entityCommandBuffer      = latiosWorld.syncPoint.CreateEntityCommandBuffer();
            var dspCommandBlock          = m_graph.CreateCommandBlock();
            var listenersWithTransforms  = new NativeList <ListenerWithTransform>(aliveListenerEntities.Length, Allocator.TempJob);
            var listenerBufferParameters = new NativeArray <ListenerBufferParameters>(aliveListenerEntities.Length,
                                                                                      Allocator.TempJob,
                                                                                      NativeArrayOptions.UninitializedMemory);
            var forIndexToListenerAndChannelIndices = new NativeList <int2>(Allocator.TempJob);
            var oneshotEmitters = new NativeArray <OneshotEmitter>(m_oneshotsQuery.CalculateEntityCount(),
                                                                   Allocator.TempJob,
                                                                   NativeArrayOptions.UninitializedMemory);
            var loopedEmitters       = new NativeArray <LoopedEmitter>(m_loopedQuery.CalculateEntityCount(), Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
            var oneshotWeightsStream = new NativeStream(oneshotEmitters.Length / CullingAndWeighting.BATCH_SIZE + 1, Allocator.TempJob);
            var loopedWeightsStream  = new NativeStream(loopedEmitters.Length / CullingAndWeighting.BATCH_SIZE + 1, Allocator.TempJob);
            var oneshotListenerEmitterPairsStream = new NativeStream(oneshotEmitters.Length / CullingAndWeighting.BATCH_SIZE + 1, Allocator.TempJob);
            var loopedListenerEmitterPairsStream  = new NativeStream(loopedEmitters.Length / CullingAndWeighting.BATCH_SIZE + 1, Allocator.TempJob);
            var oneshotClipFrameLookups           = new NativeList <ClipFrameLookup>(Allocator.TempJob);
            var loopedClipFrameLookups            = new NativeList <ClipFrameLookup>(Allocator.TempJob);
            var oneshotBatchedWeights             = new NativeList <Weights>(Allocator.TempJob);
            var loopedBatchedWeights         = new NativeList <Weights>(Allocator.TempJob);
            var oneshotTargetListenerIndices = new NativeList <int>(Allocator.TempJob);
            var loopedTargetListenerIndices  = new NativeList <int>(Allocator.TempJob);

            //Jobs
            m_lastUpdateJobHandle.Complete();

            //This may lag behind what the job threads will see.
            //That's fine, as this is only used for disposing memory.
            int lastReadIldBufferFromMainThread = m_lastReadBufferId.Value;

            var captureListenersJH = new InitUpdateDestroy.UpdateListenersJob
            {
                listenerHandle          = listenerHandle,
                translationHandle       = translationHandle,
                rotationHandle          = rotationHandle,
                ltwHandle               = ltwHandle,
                listenersWithTransforms = listenersWithTransforms
            }.Schedule(m_aliveListenersQuery, ecsJH);

            var captureFrameJH = new GraphHandling.CaptureIldFrameJob
            {
                packedFrameCounterBufferId = m_packedFrameCounterBufferId,
                audioFrame       = m_audioFrame,
                lastReadBufferId = m_lastReadBufferId
            }.Schedule();

            var ecsCaptureFrameJH = JobHandle.CombineDependencies(ecsJH, captureFrameJH);

            var updateListenersGraphJH = new GraphHandling.UpdateListenersGraphJob
            {
                listenerEntities          = aliveListenerEntities,
                destroyedListenerEntities = deadListenerEntities,
                listenerCdfe                 = listenerCdfe,
                listenerGraphStateCdfe       = listenerGraphStateCdfe,
                listenerOutputGraphStateCdfe = entityOutputGraphStateCdfe,
                ecb = entityCommandBuffer,
                audioSettingsCdfe                   = audioSettingsCdfe,
                worldBlackboardEntity               = worldBlackboardEntity,
                audioFrame                          = m_audioFrame,
                systemMixNodePortFreelist           = m_mixNodePortFreelist,
                systemMixNodePortCount              = m_mixNodePortCount,
                systemMixNode                       = m_mixNode,
                systemIldNodePortCount              = m_ildNodePortCount,
                systemIldNode                       = m_ildNode,
                commandBlock                        = dspCommandBlock,
                listenerBufferParameters            = listenerBufferParameters,
                forIndexToListenerAndChannelIndices = forIndexToListenerAndChannelIndices,
                outputSamplesMegaBuffer             = ildBuffer.buffer,
                outputSamplesMegaBufferChannels     = ildBuffer.channels,
                bufferId           = m_currentBufferId,
                samplesPerSubframe = m_samplesPerSubframe
            }.Schedule(JobHandle.CombineDependencies(captureListenersJH, captureFrameJH, listenerEntitiesJH));

            var destroyOneshotsJH = new InitUpdateDestroy.DestroyOneshotsWhenFinishedJob
            {
                dcb                   = destroyCommandBuffer,
                entityHandle          = entityHandle,
                oneshotHandle         = oneshotHandle,
                audioFrame            = m_audioFrame,
                sampleRate            = m_sampleRate,
                settingsCdfe          = audioSettingsCdfe,
                samplesPerSubframe    = m_samplesPerSubframe,
                worldBlackboardEntity = worldBlackboardEntity
            }.ScheduleParallel(m_oneshotsToDestroyWhenFinishedQuery, 1, ecsCaptureFrameJH);

            var updateOneshotsJH = new InitUpdateDestroy.UpdateOneshotsJob
            {
                oneshotHandle        = oneshotHandle,
                ltwHandle            = ltwHandle,
                translationHandle    = translationHandle,
                rotationHandle       = rotationHandle,
                parentHandle         = parentHandle,
                coneHandle           = coneHandle,
                audioFrame           = m_audioFrame,
                lastConsumedBufferId = m_lastReadBufferId,
                bufferId             = m_currentBufferId,
                emitters             = oneshotEmitters
            }.ScheduleParallel(m_oneshotsQuery, 1, destroyOneshotsJH);

            var updateLoopedJH = new InitUpdateDestroy.UpdateLoopedsJob
            {
                loopedHandle         = loopedHandle,
                ltwHandle            = ltwHandle,
                translationHandle    = translationHandle,
                rotationHandle       = rotationHandle,
                parentHandle         = parentHandle,
                coneHandle           = coneHandle,
                audioFrame           = m_audioFrame,
                lastConsumedBufferId = m_lastReadBufferId,
                bufferId             = m_currentBufferId,
                emitters             = loopedEmitters
            }.ScheduleParallel(m_loopedQuery, 1, ecsCaptureFrameJH);

            //No more ECS
            var oneshotsCullingWeightingJH = new CullingAndWeighting.OneshotsJob
            {
                emitters = oneshotEmitters,
                listenersWithTransforms = listenersWithTransforms,
                weights = oneshotWeightsStream.AsWriter(),
                listenerEmitterPairs = oneshotListenerEmitterPairsStream.AsWriter()
            }.ScheduleBatch(oneshotEmitters.Length, CullingAndWeighting.BATCH_SIZE, JobHandle.CombineDependencies(captureListenersJH, updateOneshotsJH));

            var loopedCullingWeightingJH = new CullingAndWeighting.LoopedJob
            {
                emitters = loopedEmitters,
                listenersWithTransforms = listenersWithTransforms,
                weights = loopedWeightsStream.AsWriter(),
                listenerEmitterPairs = loopedListenerEmitterPairsStream.AsWriter()
            }.ScheduleBatch(loopedEmitters.Length, CullingAndWeighting.BATCH_SIZE, JobHandle.CombineDependencies(captureListenersJH, updateLoopedJH));

            var oneshotsBatchingJH = new Batching.BatchOneshotsJob
            {
                emitters              = oneshotEmitters,
                pairWeights           = oneshotWeightsStream.AsReader(),
                listenerEmitterPairs  = oneshotListenerEmitterPairsStream.AsReader(),
                clipFrameLookups      = oneshotClipFrameLookups,
                batchedWeights        = oneshotBatchedWeights,
                targetListenerIndices = oneshotTargetListenerIndices
            }.Schedule(oneshotsCullingWeightingJH);

            var loopedBatchingJH = new Batching.BatchLoopedJob
            {
                emitters              = loopedEmitters,
                pairWeights           = loopedWeightsStream.AsReader(),
                listenerEmitterPairs  = loopedListenerEmitterPairsStream.AsReader(),
                clipFrameLookups      = loopedClipFrameLookups,
                batchedWeights        = loopedBatchedWeights,
                targetListenerIndices = loopedTargetListenerIndices
            }.Schedule(loopedCullingWeightingJH);

            var oneshotSamplingJH = new Sampling.SampleOneshotClipsJob
            {
                clipFrameLookups                    = oneshotClipFrameLookups.AsDeferredJobArray(),
                weights                             = oneshotBatchedWeights.AsDeferredJobArray(),
                targetListenerIndices               = oneshotTargetListenerIndices.AsDeferredJobArray(),
                listenerBufferParameters            = listenerBufferParameters,
                forIndexToListenerAndChannelIndices = forIndexToListenerAndChannelIndices.AsDeferredJobArray(),
                outputSamplesMegaBuffer             = ildBuffer.buffer.AsDeferredJobArray(),
                sampleRate                          = m_sampleRate,
                samplesPerSubframe                  = m_samplesPerSubframe,
                audioFrame                          = m_audioFrame
            }.Schedule(forIndexToListenerAndChannelIndices, 1, JobHandle.CombineDependencies(updateListenersGraphJH, oneshotsBatchingJH));

            var loopedSamplingJH = new Sampling.SampleLoopedClipsJob
            {
                clipFrameLookups                    = loopedClipFrameLookups.AsDeferredJobArray(),
                weights                             = loopedBatchedWeights.AsDeferredJobArray(),
                targetListenerIndices               = loopedTargetListenerIndices.AsDeferredJobArray(),
                listenerBufferParameters            = listenerBufferParameters,
                forIndexToListenerAndChannelIndices = forIndexToListenerAndChannelIndices.AsDeferredJobArray(),
                outputSamplesMegaBuffer             = ildBuffer.buffer.AsDeferredJobArray(),
                sampleRate                          = m_sampleRate,
                samplesPerSubframe                  = m_samplesPerSubframe,
                audioFrame                          = m_audioFrame
            }.Schedule(forIndexToListenerAndChannelIndices, 1, JobHandle.CombineDependencies(oneshotSamplingJH, loopedBatchingJH));

            var shipItJH = new GraphHandling.SubmitToDspGraphJob
            {
                commandBlock = dspCommandBlock
            }.Schedule(loopedSamplingJH);

            Dependency = JobHandle.CombineDependencies(updateListenersGraphJH, //handles captureListener and captureFrame
                                                       updateOneshotsJH,       //handles destroyOneshots
                                                       updateLoopedJH
                                                       );

            var disposeJobHandles = new NativeList <JobHandle>(Allocator.TempJob);

            disposeJobHandles.Add(aliveListenerEntities.Dispose(updateListenersGraphJH));
            disposeJobHandles.Add(deadListenerEntities.Dispose(updateListenersGraphJH));
            disposeJobHandles.Add(listenersWithTransforms.Dispose(JobHandle.CombineDependencies(oneshotsCullingWeightingJH, loopedCullingWeightingJH)));
            disposeJobHandles.Add(listenerBufferParameters.Dispose(loopedSamplingJH));
            disposeJobHandles.Add(forIndexToListenerAndChannelIndices.Dispose(loopedSamplingJH));
            disposeJobHandles.Add(oneshotEmitters.Dispose(oneshotsBatchingJH));
            disposeJobHandles.Add(loopedEmitters.Dispose(loopedBatchingJH));
            disposeJobHandles.Add(oneshotWeightsStream.Dispose(oneshotsBatchingJH));
            disposeJobHandles.Add(loopedWeightsStream.Dispose(loopedBatchingJH));
            disposeJobHandles.Add(oneshotListenerEmitterPairsStream.Dispose(oneshotsBatchingJH));
            disposeJobHandles.Add(loopedListenerEmitterPairsStream.Dispose(loopedBatchingJH));
            disposeJobHandles.Add(oneshotClipFrameLookups.Dispose(oneshotSamplingJH));
            disposeJobHandles.Add(loopedClipFrameLookups.Dispose(loopedSamplingJH));
            disposeJobHandles.Add(oneshotBatchedWeights.Dispose(oneshotSamplingJH));
            disposeJobHandles.Add(loopedBatchedWeights.Dispose(loopedSamplingJH));
            disposeJobHandles.Add(oneshotTargetListenerIndices.Dispose(oneshotSamplingJH));
            disposeJobHandles.Add(loopedTargetListenerIndices.Dispose(loopedSamplingJH));
            disposeJobHandles.Add(shipItJH);

            for (int i = 0; i < m_buffersInFlight.Count; i++)
            {
                var buffer = m_buffersInFlight[i];
                if (buffer.bufferId - lastReadIldBufferFromMainThread < 0)
                {
                    disposeJobHandles.Add(buffer.buffer.Dispose(ecsJH));
                    disposeJobHandles.Add(buffer.channels.Dispose(ecsJH));
                    m_buffersInFlight.RemoveAtSwapBack(i);
                    i--;
                }
            }

            m_lastUpdateJobHandle = JobHandle.CombineDependencies(disposeJobHandles);
            disposeJobHandles.Dispose();

            m_buffersInFlight.Add(ildBuffer);
        }
    protected unsafe override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var entityCount = m_CharacterControllerGroup.CalculateEntityCount();

        if (entityCount == 0)
        {
            return(inputDeps);
        }

        var defferredImpulses = new NativeStream(entityCount, Allocator.TempJob);
        var time        = m_TimeSingletonQuery.GetSingleton <GlobalGameTime>().gameTime;
        var physicWorld = m_BuildPhysicsWorld.PhysicsWorld;

        var writer = defferredImpulses.AsWriter();

        var constraints  = new NativeList <SurfaceConstraintInfo>(Allocator.Temp);
        var castHits     = new NativeList <ColliderCastHit>(Allocator.Temp);
        var distanceHits = new NativeList <DistanceHit>(Allocator.Temp);

        var input  = new ColliderCastInput();
        var hit    = new ColliderCastHit();
        var hasHit = false;

        var deltaTime = Time.DeltaTime;

        Entities
        .WithName("CharacterControllerStepSystem")
        .ForEach((
                     ref CharacterControllerComponentData ccData,
                     ref CharacterControllerCollider ccCollider,
                     ref CharacterControllerMoveQuery moveQuery,
                     ref CharacterControllerMoveResult moveResult,
                     ref CharacterControllerVelocity velocity
                     ) => {
            var collider = (Collider *)ccCollider.Collider.GetUnsafePtr();

            var stepInput = new CharacterControllerUtilities.CharacterControllerStepInput {
                World = physicWorld,
                //DeltaTime = time.tickDuration,
                DeltaTime        = deltaTime,
                Gravity          = new float3(0.0f, -9.8f, 0.0f),
                MaxIterations    = ccData.MaxIterations,
                Tau              = CharacterControllerUtilities.k_DefaultTau,
                Damping          = CharacterControllerUtilities.k_DefaultDamping,
                SkinWidth        = ccData.SkinWidth,
                ContactTolerance = ccData.ContactTolearance,
                MaxSlope         = ccData.MaxSlope,
                RigidBodyIndex   = -1,
                CurrentVelocity  = velocity.WorldVelocity,
                MaxMovementSpeed = ccData.MaxMovementSpeed,
                FollowGroud      = moveQuery.FollowGroud
            };

            var transform = new RigidTransform {
                pos = moveQuery.StartPosition,
                rot = quaternion.identity
            };

            CharacterControllerUtilities.CollideAndIntegrate(
                stepInput,
                ccData.CharacterMass,
                ccData.AffectsPhysicsBodies > 0,
                collider,
                ref transform,
                ref velocity.WorldVelocity,
                ref writer,
                ref constraints,
                ref castHits,
                ref distanceHits,
                out input,
                out hit);

            moveResult.MoveResult = transform.pos;
        })
        .Run();


        var applyJob = new ApplyDefferedImpulses()
        {
            DeferredImpulseReader = defferredImpulses.AsReader(),
            PhysicsVelocityData   = GetComponentDataFromEntity <PhysicsVelocity>(),
            PhysicsMassData       = GetComponentDataFromEntity <PhysicsMass>(),
            TranslationData       = GetComponentDataFromEntity <Translation>(),
            RotationData          = GetComponentDataFromEntity <Rotation>()
        };

        applyJob.Run();

        CharacterControllerDebug.input = input;
        CharacterControllerDebug.hit   = hit;

        defferredImpulses.Dispose();
        constraints.Dispose();
        castHits.Dispose();
        distanceHits.Dispose();

        return(inputDeps);
    }
Ejemplo n.º 15
0
 /// <inheritdoc />
 public override void Flush()
 {
     NativeStream.Flush();
 }
Ejemplo n.º 16
0
        // Schedule a set of jobs which will write all overlapping body pairs to the given steam,
        // where at least one of the bodies is dynamic. The results are unsorted.
        public SimulationJobHandles ScheduleFindOverlapsJobs(out NativeStream dynamicVsDynamicPairsStream, out NativeStream staticVsDynamicPairsStream,
                                                             JobHandle inputDeps, bool multiThreaded = true)
        {
            SimulationJobHandles returnHandles = default;

            if (!multiThreaded)
            {
                dynamicVsDynamicPairsStream        = new NativeStream(1, Allocator.TempJob);
                staticVsDynamicPairsStream         = new NativeStream(1, Allocator.TempJob);
                returnHandles.FinalExecutionHandle = new FindOverlapsJob
                {
                    Broadphase = this,
                    DynamicVsDynamicPairsWriter = dynamicVsDynamicPairsStream.AsWriter(),
                    StaticVsDynamicPairsWriter  = staticVsDynamicPairsStream.AsWriter()
                }.Schedule(inputDeps);

                return(returnHandles);
            }

            var dynamicVsDynamicNodePairIndices = new NativeList <int2>(Allocator.TempJob);
            var staticVsDynamicNodePairIndices  = new NativeList <int2>(Allocator.TempJob);

            JobHandle allocateDeps = new AllocateDynamicVsStaticNodePairs
            {
                dynamicVsDynamicNodePairIndices = dynamicVsDynamicNodePairIndices,
                staticVsDynamicNodePairIndices  = staticVsDynamicNodePairIndices,
                dynamicBranchCount = m_DynamicTree.BranchCount,
                staticBranchCount  = m_StaticTree.BranchCount
            }.Schedule(inputDeps);

            // Build pairs of branch node indices
            JobHandle dynamicVsDynamicPairs = new DynamicVsDynamicBuildBranchNodePairsJob
            {
                Ranges          = m_DynamicTree.Ranges,
                NumBranches     = m_DynamicTree.BranchCount,
                NodePairIndices = dynamicVsDynamicNodePairIndices.AsDeferredJobArray()
            }.Schedule(allocateDeps);

            JobHandle staticVsDynamicPairs = new StaticVsDynamicBuildBranchNodePairsJob
            {
                DynamicRanges      = m_DynamicTree.Ranges,
                StaticRanges       = m_StaticTree.Ranges,
                NumStaticBranches  = m_StaticTree.BranchCount,
                NumDynamicBranches = m_DynamicTree.BranchCount,
                NodePairIndices    = staticVsDynamicNodePairIndices.AsDeferredJobArray()
            }.Schedule(allocateDeps);

            //@TODO: We only need a dependency on allocateDeps, but the safety system doesn't understand that we can not change length list in DynamicVsDynamicBuildBranchNodePairsJob & StaticVsDynamicBuildBranchNodePairsJob
            //       if this is a performance issue we can use [NativeDisableContainerSafetyRestriction] on DynamicVsDynamicBuildBranchNodePairsJob & StaticVsDynamicBuildBranchNodePairsJob
            JobHandle dynamicConstruct = NativeStream.ScheduleConstruct(out dynamicVsDynamicPairsStream, dynamicVsDynamicNodePairIndices, dynamicVsDynamicPairs, Allocator.TempJob);
            JobHandle staticConstruct  = NativeStream.ScheduleConstruct(out staticVsDynamicPairsStream, staticVsDynamicNodePairIndices, staticVsDynamicPairs, Allocator.TempJob);

            // Write all overlaps to the stream (also deallocates nodePairIndices)
            JobHandle dynamicVsDynamicHandle = new DynamicVsDynamicFindOverlappingPairsJob
            {
                DynamicTree     = m_DynamicTree,
                PairWriter      = dynamicVsDynamicPairsStream.AsWriter(),
                NodePairIndices = dynamicVsDynamicNodePairIndices.AsDeferredJobArray()
            }.Schedule(dynamicVsDynamicNodePairIndices, 1, JobHandle.CombineDependencies(dynamicVsDynamicPairs, dynamicConstruct));

            // Write all overlaps to the stream (also deallocates nodePairIndices)
            JobHandle staticVsDynamicHandle = new StaticVsDynamicFindOverlappingPairsJob
            {
                StaticTree      = m_StaticTree,
                DynamicTree     = m_DynamicTree,
                PairWriter      = staticVsDynamicPairsStream.AsWriter(),
                NodePairIndices = staticVsDynamicNodePairIndices.AsDeferredJobArray()
            }.Schedule(staticVsDynamicNodePairIndices, 1, JobHandle.CombineDependencies(staticVsDynamicPairs, staticConstruct));

            // Dispose node pair lists
            var disposeOverlapPairs0 = dynamicVsDynamicNodePairIndices.Dispose(dynamicVsDynamicHandle);
            var disposeOverlapPairs1 = staticVsDynamicNodePairIndices.Dispose(staticVsDynamicHandle);

            returnHandles.FinalDisposeHandle   = JobHandle.CombineDependencies(disposeOverlapPairs0, disposeOverlapPairs1);
            returnHandles.FinalExecutionHandle = JobHandle.CombineDependencies(dynamicVsDynamicHandle, staticVsDynamicHandle);

            return(returnHandles);
        }
Ejemplo n.º 17
0
 /// <inheritdoc />
 public override void Serialize(ref bool value)
 {
     NativeStream.WriteByte(value ? (byte)1 : (byte)0);
 }
Ejemplo n.º 18
0
        // Schedules a set of jobs to iterate the provided dispatch pairs and create contacts based on them.
        internal static SimulationJobHandles ScheduleCreateContactsJobs(ref PhysicsWorld world, float timeStep,
                                                                        ref NativeStream contacts, ref NativeStream jacobians, ref NativeList <DispatchPairSequencer.DispatchPair> dispatchPairs,
                                                                        JobHandle inputDeps, ref DispatchPairSequencer.SolverSchedulerInfo solverSchedulerInfo, int threadCountHint = 0)
        {
            SimulationJobHandles returnHandles = default;

            if (threadCountHint <= 0)
            {
                contacts  = new NativeStream(1, Allocator.TempJob);
                jacobians = new NativeStream(1, Allocator.TempJob);
                returnHandles.FinalExecutionHandle = new CreateContactsJob
                {
                    World          = world,
                    TimeStep       = timeStep,
                    DispatchPairs  = dispatchPairs.AsDeferredJobArray(),
                    ContactsWriter = contacts.AsWriter()
                }.Schedule(inputDeps);
            }
            else
            {
                var numWorkItems    = solverSchedulerInfo.NumWorkItems;
                var contactsHandle  = NativeStream.ScheduleConstruct(out contacts, numWorkItems, inputDeps, Allocator.TempJob);
                var jacobiansHandle = NativeStream.ScheduleConstruct(out jacobians, numWorkItems, inputDeps, Allocator.TempJob);

                var processHandle = new ParallelCreateContactsJob
                {
                    World               = world,
                    TimeStep            = timeStep,
                    DispatchPairs       = dispatchPairs.AsDeferredJobArray(),
                    SolverSchedulerInfo = solverSchedulerInfo,
                    ContactsWriter      = contacts.AsWriter()
                }.ScheduleUnsafeIndex0(numWorkItems, 1, JobHandle.CombineDependencies(contactsHandle, jacobiansHandle));


                returnHandles.FinalExecutionHandle = processHandle;
            }

            return(returnHandles);
        }
Ejemplo n.º 19
0
 /// <inheritdoc />
 public override unsafe void Serialize(ref double value)
 {
     fixed(double *valuePtr = &value)
     NativeStream.Write(*(ulong *)valuePtr);
 }
Ejemplo n.º 20
0
 public StreamPair(int count)
 {
     Stream       = new NativeStream(count, Allocator.Persistent);
     ForEachCount = count;
 }
Ejemplo n.º 21
0
 /// <inheritdoc />
 public override void Serialize(ref int value)
 {
     NativeStream.Write((uint)value);
 }
Ejemplo n.º 22
0
 public CollisionEvents(NativeStream eventStream)
 {
     m_EventStream = eventStream;
 }
Ejemplo n.º 23
0
        // Steps the simulation immediately on a single thread without spawning any jobs.
        public static void StepImmediate(SimulationStepInput input, ref SimulationContext simulationContext)
        {
            SafetyChecks.CheckFiniteAndPositiveAndThrow(input.TimeStep, nameof(input.TimeStep));
            SafetyChecks.CheckInRangeAndThrow(input.NumSolverIterations, new int2(1, int.MaxValue), nameof(input.NumSolverIterations));

            if (input.World.NumDynamicBodies == 0)
            {
                // No need to do anything, since nothing can move
                return;
            }

            // Inform the context of the timeStep
            simulationContext.TimeStep = input.TimeStep;

            // Find all body pairs that overlap in the broadphase
            var dynamicVsDynamicBodyPairs = new NativeStream(1, Allocator.Temp);
            var dynamicVsStaticBodyPairs  = new NativeStream(1, Allocator.Temp);
            {
                var dynamicVsDynamicBodyPairsWriter = dynamicVsDynamicBodyPairs.AsWriter();
                var dynamicVsStaticBodyPairsWriter  = dynamicVsStaticBodyPairs.AsWriter();
                input.World.CollisionWorld.FindOverlaps(ref dynamicVsDynamicBodyPairsWriter, ref dynamicVsStaticBodyPairsWriter);
            }

            // Create dispatch pairs
            var dispatchPairs = new NativeList <DispatchPairSequencer.DispatchPair>(Allocator.Temp);

            DispatchPairSequencer.CreateDispatchPairs(ref dynamicVsDynamicBodyPairs, ref dynamicVsStaticBodyPairs,
                                                      input.World.NumDynamicBodies, input.World.Joints, ref dispatchPairs);

            // Apply gravity and copy input velocities
            Solver.ApplyGravityAndCopyInputVelocities(input.World.DynamicsWorld.MotionVelocities,
                                                      simulationContext.InputVelocities, input.TimeStep * input.Gravity);

            // Narrow phase
            var contacts = new NativeStream(1, Allocator.Temp);
            {
                var contactsWriter = contacts.AsWriter();
                NarrowPhase.CreateContacts(ref input.World, dispatchPairs.AsArray(), input.TimeStep, ref contactsWriter);
            }

            // Build Jacobians
            var jacobians = new NativeStream(1, Allocator.Temp);

            {
                var contactsReader  = contacts.AsReader();
                var jacobiansWriter = jacobians.AsWriter();
                Solver.BuildJacobians(ref input.World, input.TimeStep, input.Gravity, input.NumSolverIterations,
                                      dispatchPairs.AsArray(), ref contactsReader, ref jacobiansWriter);
            }

            // Solve Jacobians
            {
                var jacobiansReader       = jacobians.AsReader();
                var collisionEventsWriter = simulationContext.CollisionEventDataStream.AsWriter();
                var triggerEventsWriter   = simulationContext.TriggerEventDataStream.AsWriter();
                Solver.StabilizationData solverStabilizationData = new Solver.StabilizationData(input, simulationContext);
                Solver.SolveJacobians(ref jacobiansReader, input.World.DynamicsWorld.MotionVelocities,
                                      input.TimeStep, input.NumSolverIterations, ref collisionEventsWriter, ref triggerEventsWriter, solverStabilizationData);
            }

            // Integrate motions
            Integrator.Integrate(input.World.DynamicsWorld.MotionDatas, input.World.DynamicsWorld.MotionVelocities, input.TimeStep);

            // Synchronize the collision world if asked for
            if (input.SynchronizeCollisionWorld)
            {
                input.World.CollisionWorld.UpdateDynamicTree(ref input.World, input.TimeStep, input.Gravity);
            }
        }
Ejemplo n.º 24
0
 internal TriggerEvents(NativeStream eventDataStream)
 {
     m_EventDataStream = eventDataStream;
 }
Ejemplo n.º 25
0
 /// <inheritdoc />
 public override unsafe void Serialize(ref float value)
 {
     fixed(float *valuePtr = &value)
     * ((uint *)valuePtr) = NativeStream.ReadUInt32();
 }
Ejemplo n.º 26
0
 /// <inheritdoc />
 public override void Serialize(ref sbyte value)
 {
     NativeStream.WriteByte((byte)value);
 }
Ejemplo n.º 27
0
 /// <inheritdoc />
 public override void Serialize(ref long value)
 {
     value = (long)NativeStream.ReadUInt64();
 }
Ejemplo n.º 28
0
 /// <inheritdoc />
 public override void Serialize([NotNull] byte[] values, int offset, int count)
 {
     NativeStream.Write(values, offset, count);
 }
Ejemplo n.º 29
0
 /// <inheritdoc />
 public override void Serialize(ref uint value)
 {
     value = NativeStream.ReadUInt32();
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Get a NativeStream.Writer to write the effects to consume.
 /// </summary>
 /// <param name="foreachCount">The number of chunk of thread that writes to the NativeStream</param>
 /// <returns></returns>
 public NativeStream.Writer GetConsumerWriter(int foreachCount)
 {
     _effectStream = new NativeStream(foreachCount, Allocator.TempJob);
     _forEachCount = foreachCount;
     return(_effectStream.AsWriter());
 }