I'm writing a graphical, online program in Java and using Kryonet library to handle the networking.
I believe this library requires the packets to be instances of classes. I am not sure of this, however have not found any documentation suggesting otherwise.
I know a little bit about networking and memory efficiency but do not understand this library thoroughly and therefore am not sure if standard approaches will be effective.
My best guess for an efficient data structure is to break my Vec2 objects down into floats representing the X and Y properties respectively. Logically, it should be efficient to store these values in a single float array and then transfer that as a packet.
I'm not that familiar with memory management as it pertains to object oriented programming. Since this 'packet' is technically an instance, I'm guessing this would make the 'memory arrangement' more similar to a 'C structure'. In addition, I have no idea how Kryonet handles the data, so it's all very theoretical.
My question is: Would cramming all of the data into a single float array be more efficient than say, arranging all of the properties as individual members of the class? Or perhaps sets of arrays rather than just one?
Thanks in advance.