kyle-emmerich / blueshift-engine

High performance C++ game engine in early development
https://noxastra.com/engine
BSD 3-Clause "New" or "Revised" License
9 stars 1 forks source link

Code Reflection #4

Closed kyle-emmerich closed 8 years ago

kyle-emmerich commented 8 years ago

The problem

In order to maximize serialization performance for networking and storage of data, the engine must include a mechanism for turning game objects into raw data.

Usually, one could simply transfer data to a C++ Plain Old Data (POD) type, but we want to be able to apply extra functionality to these types. To demonstrate this, review the parameters for a POD type in C++:

A Plain Old Data Structure in C++ is an aggregate class that contains only PODS as members, has no user-defined destructor, no user-defined copy assignment operator, and no nonstatic members of pointer-to-member type.

The important parts here:

Essentially, a plain C++ struct; not very useful. For networking objects, we'll definitely want a user-defined destructor and copy assignment operator. For everything else, we definitely want non-PODs as members.

The case for a custom solution

The existing solutions out there are not that great. Google's protobuf is one of the best, but it suffers from being difficult to setup, and the bindings are written in separate files. This is okay if you're writing an application that uses it, but a middleware level piece of software like a game engine can't do that.

Therefore, Blueshift will have its own inline reflection, much like Unreal Engine 4. We will also be using an automated build tool that will run before compilation in order to expand special macros and generate runtime-usable reflection data from classes.

This means low overhead during runtime, but slightly longer compilation times. If the tool is sufficiently optimized, this is unimportant.

kyle-emmerich commented 8 years ago

Closing this, possibly doing manual reflection.