Can you explain this C++ Unreal Engine code? void USLDSubsystem::CleanUpGraph() {…
- User
Can you explain this C++ Unreal Engine code?
void USLDSubsystem::CleanUpGraph() { UE_LOG(LogTemp, Warning, TEXT("%i/%i ports are dirty at beginning of cleanup"), PortsDirty.Num(), Ports.Num()); //Handle PortsToAdd for (auto& PortIndex : PortsToAdd) { Adjacencies.FindOrAdd(PortIndex, PortIndex); } PortsDirty.Append(PortsToAdd); PortsToAdd.Empty(); UE_LOG(LogTemp, Warning, TEXT("%i/%i ports are dirty afer PortsToAdd"), PortsDirty.Num(), Ports.Num());
code//Handle PortsToRemove const TArray<int32> Neighbors = GetConnectedPorts(PortsToRemove); PortsDirty.Append(Neighbors); for (const auto& PortIndex : PortsToRemove) { TArray<int32> AdjacentPorts; Adjacencies.MultiFind(PortIndex, AdjacentPorts); for (const auto& Adjacent : AdjacentPorts) { Adjacencies.Remove(Adjacent, PortIndex); } Adjacencies.Remove(PortIndex); Ports.RemoveAt(PortIndex); } PortsToRemove.Empty(); UE_LOG(LogTemp, Warning, TEXT("%i/%i ports are dirty afer PortsToRemove"), PortsDirty.Num(), Ports.Num()); //Dirty all dirty ports connected neighbors PortsDirty = GetConnectedPorts(PortsDirty); UE_LOG(LogTemp, Warning, TEXT("%i/%i ports are dirty after dirtying neighbors"), PortsDirty.Num(), Ports.Num()); //Dissolve all network values back into port data TArray<int32> NetworkIndicesToRemove; for (const auto& PortIndex : PortsDirty) { int32 NetworkIndex = Ports[PortIndex].Index; if (NetworkIndex >= 0) { const FSLDData Network = Networks[NetworkIndex]; Ports[PortIndex].Data.Value = Network.Value / Network.Capacity; NetworkIndicesToRemove.AddUnique(NetworkIndex); UE_LOG(LogTemp, Warning, TEXT("Port %i has value %f and capacity %f after network dissolve"), PortIndex, Ports[PortIndex].Data.Value, Ports[PortIndex].Data.Capacity); } } //Remove all dirty port's Networks for (const auto& Index:NetworkIndicesToRemove) { Networks.RemoveAt(Index); } UE_LOG(LogTemp, Warning, TEXT("%i dirty %i total %i networks %i connections"), PortsDirty.Num(), Ports.Num(), Networks.Num(), Adjacencies.Num()); //Create network for each set of connected dirty ports TSet<int32> Visited; for (const auto& Port : PortsDirty) { if (!Visited.Contains(Port) && Ports.IsValidIndex(Port)) { auto Connected = GetConnectedPorts(TArray<int32>{Port}); Visited.Append(Connected); CreateNetworkForPorts(Connected); } } PortsDirty.Empty(); UE_LOG(LogTemp, Warning, TEXT("%i dirty %i total %i networks %i connections"), PortsDirty.Num(), Ports.Num(), Networks.Num(), Adjacencies.Num()); TestPrintALlPortData(); - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.