public void Execute(int index) { BioClouds.CloudIDPosRadius CloudPos; float3 currentMarkerPosition; NativeMultiHashMapIterator <int> it; float3 moveStep = float3.zero; float3 direction = float3.zero; float totalW; AgentTotalW.TryGetValue(AgentData[index].ID, out totalW); bool keepgoing = AgentMarkersMap.TryGetFirstValue(AgentData[index].ID, out currentMarkerPosition, out it); if (!keepgoing) { return; } float F = AgentCalculations.GetF(currentMarkerPosition, AgentPos[index].Value, AgentGoals[index].SubGoal - AgentPos[index].Value); direction += AgentCalculations.PartialW(totalW, F) * AgentData[index].MaxSpeed * (currentMarkerPosition - AgentPos[index].Value); while (AgentMarkersMap.TryGetNextValue(out currentMarkerPosition, ref it)) { F = AgentCalculations.GetF(currentMarkerPosition, AgentPos[index].Value, AgentGoals[index].SubGoal - AgentPos[index].Value); direction += AgentCalculations.PartialW(totalW, F) * AgentData[index].MaxSpeed * (currentMarkerPosition - AgentPos[index].Value); } float moduleM = math.length(direction); float s = (float)(moduleM * math.PI); if (s > AgentData[index].MaxSpeed) { s = AgentData[index].MaxSpeed; } if (moduleM > 0.00001f) { moveStep = s * (math.normalize(direction)); } else { moveStep = float3.zero; } AgentStep[index] = new AgentStep() { delta = moveStep }; }
public void Execute(int index) { BioClouds.CloudIDPosRadius CloudPos; if (!BioClouds2PosMap.TryGetValue(AgentCloudID[index].CloudID, out CloudPos)) { return; } float3 CloudPosition = CloudPos.position; float3 BioCrowdsCloudPosition = WindowManager.Clouds2Crowds(CloudPosition); float3 Agent2CloudCenterVec = BioCrowdsCloudPosition - AgentPos[index].Value; float3 NormalizedAgent2CloudCenter = math.normalize(Agent2CloudCenterVec); float3 currentMarkerPosition; NativeMultiHashMapIterator <int> it; float3 moveStep = float3.zero; float3 direction = float3.zero; float totalW; AgentTotalW.TryGetValue(AgentData[index].ID, out totalW); bool keepgoing = AgentMarkersMap.TryGetFirstValue(AgentData[index].ID, out currentMarkerPosition, out it); if (!keepgoing) { return; } float extraweight = math.dot(NormalizedAgent2CloudCenter, currentMarkerPosition - AgentPos[index].Value); float F = AgentCalculations.GetF(currentMarkerPosition, AgentPos[index].Value, AgentGoals[index].SubGoal - AgentPos[index].Value); F += extraweight * 0.1f; direction += AgentCalculations.PartialW(totalW, F) * AgentData[index].MaxSpeed * (currentMarkerPosition - AgentPos[index].Value); while (AgentMarkersMap.TryGetNextValue(out currentMarkerPosition, ref it)) { extraweight = math.dot(NormalizedAgent2CloudCenter, currentMarkerPosition - AgentPos[index].Value); F = AgentCalculations.GetF(currentMarkerPosition, AgentPos[index].Value, AgentGoals[index].SubGoal - AgentPos[index].Value); F += extraweight * 0.1f; direction += AgentCalculations.PartialW(totalW, F) * AgentData[index].MaxSpeed * (currentMarkerPosition - AgentPos[index].Value); } float moduleM = math.length(direction); float s = (float)(moduleM * math.PI); if (s > AgentData[index].MaxSpeed) { s = AgentData[index].MaxSpeed; } if (moduleM > 0.00001f) { moveStep = s * (math.normalize(direction)); } else { moveStep = float3.zero; } AgentStep[index] = new AgentStep() { delta = moveStep }; }