Rework tracing system and enum creators
- Rework tracing system, now using "{}" for formatting instead of the
standard %s,%d,%f formatting that C++ uses.
- Rework enums creators to not take in namespace
- Fix single use CommandBuffers sometimes failing due to indexing them
with the current frame in flight
- Add DropEvent to Window
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include "copium/ecs/ComponentPoolBase.h"
|
||||
#include "copium/ecs/Config.h"
|
||||
#include "copium/ecs/EntitySet.h"
|
||||
#include "copium/util/Common.h"
|
||||
#include "copium/util/Trace.h"
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
@@ -68,8 +68,8 @@ namespace Copium
|
||||
return;
|
||||
|
||||
CP_ASSERT(queueOperationOrder.size() == addQueue.size() + removeQueue.size(),
|
||||
"queueOperationOrder size=%zu doesn't match the sum of the addQueue size=%zu and removeQueue size=%zu, "
|
||||
"which is %zu",
|
||||
"queueOperationOrder size={} doesn't match the sum of the addQueue size={} and removeQueue size={}, "
|
||||
"which is {}",
|
||||
queueOperationOrder.size(),
|
||||
addQueue.size(),
|
||||
removeQueue.size(),
|
||||
@@ -152,14 +152,14 @@ namespace Copium
|
||||
void CommitAddComponent(int queueIndex)
|
||||
{
|
||||
CP_ASSERT(
|
||||
queueIndex < addQueue.size(), "queueIndex=%d is greater than the addQueueSize=%d", queueIndex, addQueue.size());
|
||||
queueIndex < addQueue.size(), "queueIndex={} is greater than the addQueueSize={}", queueIndex, addQueue.size());
|
||||
|
||||
const auto& [entity, component] = addQueue[queueIndex];
|
||||
// TODO: Debugging errors caused by this assert might be a bit difficult, since there wont be any stacktrace for
|
||||
// where the component was added. Might want to validate this in AddComponent somehow (like looping through
|
||||
// the queued changes and work out if the component already exists)
|
||||
CP_ASSERT(Find(entity) == Size(),
|
||||
"Component already exists in entity (entity=%u, Component=%s)",
|
||||
"Component already exists in entity (entity={}, Component={})",
|
||||
entity,
|
||||
typeid(Component).name());
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Copium
|
||||
void CommitRemoveComponent(int queueIndex)
|
||||
{
|
||||
CP_ASSERT(queueIndex < removeQueue.size(),
|
||||
"queueIndex=%d is greater than the removeQueueSize=%d",
|
||||
"queueIndex={} is greater than the removeQueueSize={}",
|
||||
queueIndex,
|
||||
removeQueue.size());
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Copium
|
||||
// TODO: Debugging warnings caused by this might be a bit difficult, since there wont be any stacktrace for
|
||||
// where the component was added. Might want to validate this in AddComponent somehow (like looping
|
||||
// through the queued changes and work out if the component already exists)
|
||||
CP_WARN("Entity did not contain component (entity=%u, Component=%s)", entity, typeid(Component).name());
|
||||
CP_WARN("Entity did not contain component (entity={}, Component={})", entity, typeid(Component).name());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "copium/ecs/ECSManager.h"
|
||||
|
||||
#include "copium/util/Common.h"
|
||||
#include "copium/util/Trace.h"
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace Copium
|
||||
void ECSManager::UpdateSystems(const Uuid& systemPoolId)
|
||||
{
|
||||
auto it = systemPools.find(systemPoolId);
|
||||
CP_ASSERT(it != systemPools.end(), "SystemPool doesn't exist with Uuid=%s", systemPoolId.ToString().c_str());
|
||||
CP_ASSERT(it != systemPools.end(), "SystemPool doesn't exist with Uuid={}", systemPoolId);
|
||||
it->second->CommitSignals();
|
||||
CommitEntityUpdates();
|
||||
it->second->CommitUpdates();
|
||||
@@ -60,7 +60,7 @@ namespace Copium
|
||||
void ECSManager::DestroyEntity(EntityId entity)
|
||||
{
|
||||
auto it = entities.find(entity);
|
||||
CP_ASSERT(it != entities.end(), "Entity does not exist in ECSManager (entity=%u)", entity);
|
||||
CP_ASSERT(it != entities.end(), "Entity does not exist in ECSManager (entity={})", entity);
|
||||
if (entity == currentEntityId - 1)
|
||||
{
|
||||
currentEntityId--;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <typeindex>
|
||||
#include <unordered_set>
|
||||
@@ -12,6 +13,7 @@
|
||||
#include "copium/ecs/SystemPool.h"
|
||||
#include "copium/util/Common.h"
|
||||
#include "copium/util/GenericType.h"
|
||||
#include "copium/util/Trace.h"
|
||||
#include "copium/util/Uuid.h"
|
||||
|
||||
namespace Copium
|
||||
@@ -50,7 +52,7 @@ namespace Copium
|
||||
void RemoveSystem(const Uuid& systemPoolId)
|
||||
{
|
||||
auto it = systemPools.find(systemPoolId);
|
||||
CP_ASSERT(it != systemPools.end(), "SystemPool doesn't exist with Uuid=%s", systemPoolId.ToString().c_str());
|
||||
CP_ASSERT(it != systemPools.end(), "SystemPool doesn't exist with Uuid={}", systemPoolId);
|
||||
|
||||
it->second->RemoveSystem(typeid(SystemClass));
|
||||
|
||||
@@ -146,7 +148,7 @@ namespace Copium
|
||||
auto pool = GetComponentPoolAssure<Component>();
|
||||
Component* component = pool->FindComponent(entity);
|
||||
CP_ASSERT(
|
||||
component, "Entity did not contain component (entity=%u, Component=%s)", entity, typeid(Component).name());
|
||||
component, "Entity did not contain component (entity={}, Component={})", entity, typeid(Component).name());
|
||||
return *component;
|
||||
}
|
||||
|
||||
@@ -258,7 +260,7 @@ namespace Copium
|
||||
void AddGlobalData(const Args&... args)
|
||||
{
|
||||
auto it = globalDatas.find(typeid(T));
|
||||
CP_ASSERT(!HasGlobalData<T>(), "Global with typeid=%s already exists. Do nothing", typeid(T).name());
|
||||
CP_ASSERT(!HasGlobalData<T>(), "Global with typeid={} already exists. Do nothing", typeid(T).name());
|
||||
|
||||
globalDatas.emplace(typeid(T), GenericType::Create<T>(args...));
|
||||
}
|
||||
@@ -267,7 +269,7 @@ namespace Copium
|
||||
T& GetGlobalData()
|
||||
{
|
||||
auto it = globalDatas.find(typeid(T));
|
||||
CP_ASSERT(it != globalDatas.end(), "Global with typeid=%s doesn't exist");
|
||||
CP_ASSERT(it != globalDatas.end(), "Global with typeid={} doesn't exist");
|
||||
|
||||
return it->second.Get<T>();
|
||||
}
|
||||
@@ -282,7 +284,7 @@ namespace Copium
|
||||
void RemoveGlobalData()
|
||||
{
|
||||
auto it = globalDatas.find(typeid(T));
|
||||
CP_ASSERT("Global with typeid=%s doesn't exist. Do nothing", typeid(T).name());
|
||||
CP_ASSERT("Global with typeid={} doesn't exist. Do nothing", typeid(T).name());
|
||||
globalDatas.erase(it);
|
||||
}
|
||||
|
||||
@@ -299,7 +301,7 @@ namespace Copium
|
||||
{
|
||||
auto it = componentPools.find(GetComponentId<Component>());
|
||||
CP_ASSERT(it != componentPools.end(),
|
||||
"Component has not been added to an entity (Component=%s)",
|
||||
"Component has not been added to an entity (Component={})",
|
||||
typeid(Component).name());
|
||||
return static_cast<ComponentPool<std::remove_const_t<Component>>*>(it->second);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace Copium
|
||||
return;
|
||||
|
||||
CP_ASSERT(queueOperationOrder.size() == addQueue.size() + removeQueue.size(),
|
||||
"queueOperationOrder size=%zu doesn't match the sum of the addQueue size=%zu and removeQueue size=%zu, "
|
||||
"which is %zu",
|
||||
"queueOperationOrder size={} doesn't match the sum of the addQueue size={} and removeQueue size={}, "
|
||||
"which is {}",
|
||||
queueOperationOrder.size(),
|
||||
addQueue.size(),
|
||||
removeQueue.size(),
|
||||
@@ -116,9 +116,9 @@ namespace Copium
|
||||
void SystemPool::MoveSystemAfter(const std::type_index& systemId, const std::type_index& afterSystemId)
|
||||
{
|
||||
auto it1 = systems.find(systemId);
|
||||
CP_ASSERT(it1 != systems.end(), "System with typeid=%s does not exist in SystemPool", systemId.name());
|
||||
CP_ASSERT(it1 != systems.end(), "System with typeid={} does not exist in SystemPool", systemId.name());
|
||||
auto it2 = systems.find(afterSystemId);
|
||||
CP_ASSERT(it2 != systems.end(), "System with typeid=%s does not exist in SystemPool", afterSystemId.name());
|
||||
CP_ASSERT(it2 != systems.end(), "System with typeid={} does not exist in SystemPool", afterSystemId.name());
|
||||
|
||||
auto itSystemId = std::find(systemOrder.rbegin(), systemOrder.rend(), it1->second);
|
||||
auto itAfterSystemId = std::find(systemOrder.rbegin(), systemOrder.rend(), it2->second);
|
||||
@@ -128,9 +128,9 @@ namespace Copium
|
||||
void SystemPool::MoveSystemBefore(const std::type_index& systemId, const std::type_index& beforeSystemId)
|
||||
{
|
||||
auto it1 = systems.find(systemId);
|
||||
CP_ASSERT(it1 != systems.end(), "System with typeid=%s does not exist in SystemPool", systemId.name());
|
||||
CP_ASSERT(it1 != systems.end(), "System with typeid={} does not exist in SystemPool", systemId.name());
|
||||
auto it2 = systems.find(beforeSystemId);
|
||||
CP_ASSERT(it2 != systems.end(), "System with typeid=%s does not exist in SystemPool", beforeSystemId.name());
|
||||
CP_ASSERT(it2 != systems.end(), "System with typeid={} does not exist in SystemPool", beforeSystemId.name());
|
||||
|
||||
auto itSystemId = std::find(systemOrder.rbegin(), systemOrder.rend(), it1->second);
|
||||
auto itBeforeSystemId = std::find(systemOrder.rbegin(), systemOrder.rend(), it2->second);
|
||||
@@ -141,10 +141,10 @@ namespace Copium
|
||||
void SystemPool::CommitAddSystem(int queueIndex)
|
||||
{
|
||||
CP_ASSERT(
|
||||
queueIndex < addQueue.size(), "queueIndex=%d is greater than the addQueueSize=%d", queueIndex, addQueue.size());
|
||||
queueIndex < addQueue.size(), "queueIndex={} is greater than the addQueueSize={}", queueIndex, addQueue.size());
|
||||
|
||||
auto& [systemId, system, ordering] = addQueue[queueIndex];
|
||||
CP_ASSERT(systems.find(systemId) == systems.end(), "System with typeid=%s already exists in SystemPool");
|
||||
CP_ASSERT(systems.find(systemId) == systems.end(), "System with typeid={} already exists in SystemPool");
|
||||
|
||||
systems.emplace(systemId, system);
|
||||
systemOrder.emplace_back(system);
|
||||
@@ -154,16 +154,16 @@ namespace Copium
|
||||
void SystemPool::CommitRemoveSystem(int queueIndex)
|
||||
{
|
||||
CP_ASSERT(queueIndex < removeQueue.size(),
|
||||
"queueIndex=%d is greater than the removeQueueSize=%d",
|
||||
"queueIndex={} is greater than the removeQueueSize={}",
|
||||
queueIndex,
|
||||
removeQueue.size());
|
||||
|
||||
const auto& systemId = removeQueue[queueIndex];
|
||||
auto it = systems.find(systemId);
|
||||
CP_ASSERT(it != systems.end(), "System with typeid=%s does not exist in SystemPool", systemId.name());
|
||||
CP_ASSERT(it != systems.end(), "System with typeid={} does not exist in SystemPool", systemId.name());
|
||||
|
||||
auto itOrder = std::find(systemOrder.begin(), systemOrder.end(), it->second);
|
||||
CP_ASSERT(itOrder != systemOrder.end(), "System with typeid=%s does not exist in systemOrder", systemId.name());
|
||||
CP_ASSERT(itOrder != systemOrder.end(), "System with typeid={} does not exist in systemOrder", systemId.name());
|
||||
|
||||
delete it->second;
|
||||
systems.erase(it);
|
||||
|
||||
Reference in New Issue
Block a user