ongoing refactor of serialization and various cleanup
This commit is contained in:
@@ -46,30 +46,26 @@ EntityManager& GetEntityManager()
|
||||
entity_template* RegisterEntity(EntityManager& manager, Entity* base, DerivedType entity)
|
||||
{
|
||||
base->ID = EntityManager::ID++;
|
||||
base->Derived = entity;
|
||||
base->derived = entity;
|
||||
|
||||
manager.Entities.PushBack(*base);
|
||||
|
||||
auto* ptr = (entity_template*)ArenaPushSize(manager.by_type[base->Kind->kind].arena, base->Kind->size_of, base->Kind->alignment,
|
||||
false JULIET_DEBUG_PARAM(kEntity_type_names[base->Kind->kind]));
|
||||
MemCopy(ptr, entity, base->Kind->size_of);
|
||||
manager.by_type[base->Kind->kind].count += 1;
|
||||
auto* ptr = (entity_template*)ArenaPushSize(manager.by_type[base->derived_kind->kind].arena,
|
||||
base->derived_kind->size_of, base->derived_kind->alignment,
|
||||
false JULIET_DEBUG_PARAM(kEntity_type_names[base->derived_kind->kind]));
|
||||
MemCopy(ptr, entity, base->derived_kind->size_of);
|
||||
manager.by_type[base->derived_kind->kind].count += 1;
|
||||
|
||||
ptr->Base = manager.Entities.Back();
|
||||
ptr->base = manager.Entities.Back();
|
||||
|
||||
if (manager.by_type[base->Kind->kind].array == nullptr)
|
||||
if (manager.by_type[base->derived_kind->kind].array == nullptr)
|
||||
{
|
||||
manager.by_type[base->Kind->kind].array = ptr;
|
||||
manager.by_type[base->derived_kind->kind].array = ptr;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void RegisterBaseEntity(EntityManager& manager, Entity&& base)
|
||||
{
|
||||
GetEntityManager().Entities.PushBack(std::move(base));
|
||||
}
|
||||
|
||||
void UpdateEntityManager(EntityManager& manager)
|
||||
{
|
||||
// Todo : inert by definition dont move, but this is for test
|
||||
@@ -79,7 +75,9 @@ void UpdateEntityManager(EntityManager& manager)
|
||||
Inert* inert = reinterpret_cast<Inert*>(by_type.array) + i;
|
||||
if (inert->MeshInstance != indexMax)
|
||||
{
|
||||
SetMeshInstanceTransform(inert->MeshInstance, MatrixTranslation(inert->Base->X, inert->Base->Y, inert->Base->Z));
|
||||
SetMeshInstanceTransform(inert->MeshInstance,
|
||||
MatrixTranslation(inert->base->position.x, inert->base->position.y,
|
||||
inert->base->position.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user