protected override JobHandle OnUpdate(JobHandle inputDeps) { int massCount = massQuery.CalculateEntityCount(); int springCount = springQuery.CalculateEntityCount(); if (massCount == 0 || springCount == 0) { return(inputDeps); } NativeMultiHashMap <Entity, float3> hashMap = new NativeMultiHashMap <Entity, float3>(massCount * 4, Allocator.TempJob); HashSpringForceJob hashMassSpringJob = new HashSpringForceJob { _hashMap = hashMap.AsParallelWriter() }; JobHandle hashMassSPringHandle = hashMassSpringJob.Schedule(this, inputDeps); MassSpringForceJob massSpringForceJob = new MassSpringForceJob { _massSpringHashMap = hashMap }; JobHandle massSpringForceHandle = massSpringForceJob.Schedule(this, hashMassSPringHandle); massSpringForceHandle.Complete(); hashMap.Dispose(); return(massSpringForceHandle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { if (_massData.Length == 0 || _springData.Length == 0) { return(inputDeps); } NativeMultiHashMap <Entity, float3> hashMap = new NativeMultiHashMap <Entity, float3>(_massData.Length * 4, Allocator.Temp); HashSpringForceJob hashMassSpringJob = new HashSpringForceJob { _hashMap = hashMap.ToConcurrent(), _springEntityPairs = _springData.EntityPairs, _springElasticities = _springData.Elasticities, _springLines = _springData.Lines }; JobHandle hashMassSPringHandle = hashMassSpringJob.Schedule(_springData.Length, 64, inputDeps); MassSpringForceJob massSpringForceJob = new MassSpringForceJob { _massSpringHashMap = hashMap, _massEntities = _massData.Entities, _massPhysicals = _massData.Physicals }; JobHandle massSpringForceHandle = massSpringForceJob.Schedule(_massData.Length, 64, hashMassSPringHandle); massSpringForceHandle.Complete(); hashMap.Dispose(); return(massSpringForceHandle); }