How much of a performance loss is there to use flatbuffer mutable?
Is it "correct" use of flatbuffers to have a object/stuct which should be editable (ie game state)
In my example i have the following classes at the moment:
class Game:
std::vector<Player>;
int frames;
class Player:
std::string name;
int oil;
std::vector<Unit>;
class Unit:
int id;
int hp
...
Would it be sensible to use a flatbuffer for each of these objects storing all information about each unit? Or would a mutable flatbuffer decrease performance?
If flatbuffers are wrong tool for this job, which technology should be used?
FlatBuffers has very efficient in-place mutation of scalars, but mutating things like vectors in-place requires the use of reflection, which currently is slower and clumsier, thus not recommended for use as game state that is frequently modified.
Instead, in your case, I'd recommend using the object API (--gen-object-api
) which gives you automatic conversion to/from a FlatBuffer and allows you convenient mutation with standard C++ types.