-
Hello everybody, I'm sorting the rendered entities (the order defined, e.g., by a component that specifies how far we are from the camera) and I was wondering what's the approach that works best for you. My current approach is to sort at each frame by using the sort method of the registry Would it be better to just sort the components on demand ? Meaning to call the sort function on construction or on destruction of the relevant component, i.e., using the on_... methods to observe changes of the registry. Would this approach cost the same or less as the per-frame resorting? Thanks in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you added N elements of the same type in a tick, the last method would sort N times a pool vs a single time of the original approach. |
Beta Was this translation helpful? Give feedback.
If you added N elements of the same type in a tick, the last method would sort N times a pool vs a single time of the original approach.
If you really want to lazy sort things on demand, use signals or another approach to raise a flag and check this flag before sorting.
This way you know that you're only sorting once and when needed. This is probably the best of the two worlds.