public void Execute(int index) { float3 currentCellPosition; NativeMultiHashMapIterator <int> it; float totalW = 0f; bool keepgoing = CloudMarkersMap.TryGetFirstValue(CloudData[index].ID, out currentCellPosition, out it); if (!keepgoing) { return; } totalW += CloudCalculations.GetF(currentCellPosition, CloudPositions[index].Value, (CloudGoals[index].SubGoal - CloudPositions[index].Value)); while (CloudMarkersMap.TryGetNextValue(out currentCellPosition, ref it)) { totalW += CloudCalculations.GetF(currentCellPosition, CloudPositions[index].Value, (CloudGoals[index].SubGoal - CloudPositions[index].Value)); } cloudTotalAuxinWeight.TryAdd(CloudData[index].ID, totalW); }
public void Execute(int index) { float3 currentCellPosition; NativeMultiHashMapIterator <int> it; float3 moveStep = float3.zero; float3 direction = float3.zero; CloudTotalW.TryGetValue(CloudData[index].ID, out float totalW); bool keepgoing = CloudMarkersMap.TryGetFirstValue(CloudData[index].ID, out currentCellPosition, out it); if (!keepgoing) { return; } float F = CloudCalculations.GetF(currentCellPosition, CloudPositions[index].Value, CloudGoals[index].SubGoal - CloudPositions[index].Value); var auxinWeight = CloudCalculations.PartialW(totalW, F) * CloudData[index].MaxSpeed * (currentCellPosition - CloudPositions[index].Value); direction += auxinWeight; if (useSplit) { if (ExtraWeightCell.TryGetValue(CloudData[index].ID, out int extraweightcell)) { if (GridConverter.Position2CellID(currentCellPosition) == extraweightcell) { //TODO dynamic extra weight direction += 5 * auxinWeight; } } } while (CloudMarkersMap.TryGetNextValue(out currentCellPosition, ref it)) { F = CloudCalculations.GetF(currentCellPosition, CloudPositions[index].Value, CloudGoals[index].SubGoal - CloudPositions[index].Value); direction += CloudCalculations.PartialW(totalW, F) * CloudData[index].MaxSpeed * (currentCellPosition - CloudPositions[index].Value); if (useSplit) { if (ExtraWeightCell.TryGetValue(CloudData[index].ID, out int extraweightcell)) { if (GridConverter.Position2CellID(currentCellPosition) == extraweightcell) { direction += auxinWeight; } } } } float moduleM = math.length(direction); float s = (float)(moduleM * math.PI); float3 normalized_direction = math.normalize(direction); float3 normalized_goalvector = math.normalize(CloudGoals[index].SubGoal - CloudPositions[index].Value); if (s > CloudData[index].MaxSpeed) { s = CloudData[index].MaxSpeed; } if (moduleM > 0.00001f) { moveStep = s * (normalized_direction); } else { moveStep = float3.zero; } CloudStep[index] = new CloudMoveStep() { Delta = moveStep }; }