domenica 16 ottobre 2016

Day 178: NetworkObject and refactoring

Today I spent time trying to figure out how to make the system work. The main problem is to automatize the network communication so that it exchanges messages without having to code it in the scene class. A major challenge is to create the objects in every connected client. The idea I have to solve this problem is to give the scene a virtual function to call when a new object is instantiated over the network. This way I can control what to do when the event occurs.

Then I created the networkObject component, which will be the component that identify an object through the network, Every NetworkObject is identified uniquely by three pieces of data: owner_ip, owner_port, local_id.

In the afternoon I made a substantial refactoring of the DeferredRenderer and Game classes. They used to iterate through the game object every frame to get the active lights, model and network_ids. Now I added a static field to each of this components to keep track of every object of that type. Performance are a bit better, and the code is much easier to maintain.

Nessun commento:

Posta un commento