Now that we have an animated flow of particles on a predefined path, we need to think about how that path is defined in relation to entities in the simulation.
In some cases, the message flow will be directly from message producer to consumer. In that case we may not want to define intermediate points at all. Even in this simple case, we may want to flow messages over the ground rather than through the air to reduce visual pollution in the 'airspace'. Plus, we may need to avoid collision with other objects.
Sometimes the path between producer and consumer will be more indirect, for example - a message may be directed to Kafka, on a specific topic and then Kafka will direct the message to a partition based on the partition key. Interaction between Kubernetes pods may be directed through a sidecar, and flow to a reverse-proxy nginx or haproxy.
Calculating a Path Around Entities
The simple requirement is really to plot a path across a series of objects that is the most optimal. An object in this case is simple a 3D vector and size (more complex shapes are out of scope). Like our curve calculation, the path is going to be defined by the previous, current and next points.
A simple approach to this would be to rely on distance calculation. Each entity has potentially six connection points (assuming a rectangular cuboid, which I'm just going to call a box). For our three points (P0,P1,P2), we can use the center point of the previous and next point while we calculate the connection point of P1. The combined shortest distance of the six possibilities wins.
The problem with this simplistic approach is that the path chosen for the next step (P1,P2,P3) will impact the previous leg (P0,P1,P2). A compromise brute force approach to this is to consider all combinations, so for a 4 point (3 segment) path we would need to chose from 6^2 points and chose the shortest path. You can see that in action below: