Serialization : started to unify how to allocate entity whether its from MakeEntity or during deserialization.
This commit is contained in:
@@ -257,17 +257,19 @@ To prevent monolithic engine updates from forcing all gameplay assets to re-vers
|
||||
Every serializable entity or component is described by an immutable `Class` instance:
|
||||
|
||||
```cpp
|
||||
using serialize_fct_type = void (*)(Archive& ar, uint16 version, void* payload);
|
||||
using serialize_fct_type = void (*)(Archive& ar, uint16 version, void* payload);
|
||||
using default_init_fct_type = void (*)(void* payload);
|
||||
|
||||
struct Class
|
||||
{
|
||||
uint32 CRC;
|
||||
uint8 kind;
|
||||
uint16 version;
|
||||
const Class* base_class;
|
||||
serialize_fct_type serialize_fct;
|
||||
size_t size_of;
|
||||
size_t alignment;
|
||||
uint32 CRC;
|
||||
uint8 kind;
|
||||
uint16 version;
|
||||
const Class* base_class;
|
||||
serialize_fct_type serialize_fct;
|
||||
default_init_fct_type default_init_fct;
|
||||
size_t size_of;
|
||||
size_t alignment;
|
||||
|
||||
#if JULIET_DEBUG
|
||||
String Name;
|
||||
@@ -281,8 +283,10 @@ struct Class
|
||||
static Class* kind;
|
||||
|
||||
#define DEFINE_CLASS_VERSIONED(cls, version, base_class, serialize_fct) \
|
||||
inline void default_init_##cls(void* payload) { *static_cast<cls*>(payload) = cls{}; } \
|
||||
constexpr Class classKind##cls = \
|
||||
MakeClass(ConstString(#cls), 0, (version), (base_class), sizeof(cls), alignof(cls), (serialize_fct)); \
|
||||
MakeClass(ConstString(#cls), 0, (version), (base_class), sizeof(cls), alignof(cls), \
|
||||
(serialize_fct), default_init_##cls); \
|
||||
Class* cls::kind = const_cast<Class*>(&classKind##cls);
|
||||
```
|
||||
|
||||
@@ -293,8 +297,10 @@ For derived entity types, `DECLARE_ENTITY()` and `DEFINE_ENTITY_VERSIONED` compo
|
||||
DECLARE_CLASS()
|
||||
|
||||
#define DEFINE_ENTITY_VERSIONED(entity, version, serialize_fct) \
|
||||
inline void default_init_##entity(void* payload) { *static_cast<entity*>(payload) = entity{}; } \
|
||||
constexpr Class entityKind##entity = MakeClass(ConstString(#entity), (uint8)Entity_Type::entity, (version), \
|
||||
&classKindEntity, sizeof(entity), alignof(entity), (serialize_fct)); \
|
||||
&classKindEntity, sizeof(entity), alignof(entity), \
|
||||
(serialize_fct), default_init_##entity); \
|
||||
Class* entity::kind = const_cast<Class*>(&entityKind##entity);
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user