Fix acronym naming standard
- Now follow standard that acronyms should only capitalize the first letter
This commit is contained in:
@@ -233,7 +233,7 @@
|
|||||||
<ClCompile Include="src\copium\buffer\VertexBuffer.cpp" />
|
<ClCompile Include="src\copium\buffer\VertexBuffer.cpp" />
|
||||||
<ClCompile Include="src\copium\pipeline\VertexDescriptor.cpp" />
|
<ClCompile Include="src\copium\pipeline\VertexDescriptor.cpp" />
|
||||||
<ClCompile Include="src\copium\mesh\VertexPassthrough.cpp" />
|
<ClCompile Include="src\copium\mesh\VertexPassthrough.cpp" />
|
||||||
<ClCompile Include="src\copium\util\UUID.cpp" />
|
<ClCompile Include="src\copium\util\Uuid.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\copium\asset\Asset.h" />
|
<ClInclude Include="src\copium\asset\Asset.h" />
|
||||||
@@ -313,7 +313,7 @@
|
|||||||
<ClInclude Include="src\copium\mesh\Vertex.h" />
|
<ClInclude Include="src\copium\mesh\Vertex.h" />
|
||||||
<ClInclude Include="src\copium\buffer\VertexBuffer.h" />
|
<ClInclude Include="src\copium\buffer\VertexBuffer.h" />
|
||||||
<ClInclude Include="src\copium\pipeline\VertexDescriptor.h" />
|
<ClInclude Include="src\copium\pipeline\VertexDescriptor.h" />
|
||||||
<ClInclude Include="src\copium\util\UUID.h" />
|
<ClInclude Include="src\copium\util\Uuid.h" />
|
||||||
<ClInclude Include="src\copium\util\VulkanException.h" />
|
<ClInclude Include="src\copium\util\VulkanException.h" />
|
||||||
<ClInclude Include="src\copium\mesh\VertexPassthrough.h" />
|
<ClInclude Include="src\copium\mesh\VertexPassthrough.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -129,7 +129,7 @@
|
|||||||
<ClCompile Include="src\copium\pipeline\ShaderBinding.cpp">
|
<ClCompile Include="src\copium\pipeline\ShaderBinding.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\copium\util\UUID.cpp">
|
<ClCompile Include="src\copium\util\Uuid.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\copium\asset\AssetManager.cpp">
|
<ClCompile Include="src\copium\asset\AssetManager.cpp">
|
||||||
@@ -329,7 +329,7 @@
|
|||||||
<ClInclude Include="src\copium\pipeline\ShaderBinding.h">
|
<ClInclude Include="src\copium\pipeline\ShaderBinding.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\copium\util\UUID.h">
|
<ClInclude Include="src\copium\util\Uuid.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\copium\asset\AssetMeta.h">
|
<ClInclude Include="src\copium\asset\AssetMeta.h">
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Copium
|
|||||||
return metaData.name;
|
return metaData.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID Asset::GetUUID() const
|
Uuid Asset::GetUuid() const
|
||||||
{
|
{
|
||||||
return metaData.uuid;
|
return metaData.uuid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "copium/asset/AssetMeta.h"
|
#include "copium/asset/AssetMeta.h"
|
||||||
#include "copium/util/MetaFile.h"
|
#include "copium/util/MetaFile.h"
|
||||||
#include "copium/util/UUID.h"
|
#include "copium/util/Uuid.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ namespace Copium
|
|||||||
|
|
||||||
AssetHandle GetHandle() const;
|
AssetHandle GetHandle() const;
|
||||||
const std::string& GetName() const;
|
const std::string& GetName() const;
|
||||||
UUID GetUUID() const;
|
Uuid GetUuid() const;
|
||||||
bool isRuntime() const;
|
bool isRuntime() const;
|
||||||
|
|
||||||
operator AssetHandle() const;
|
operator AssetHandle() const;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Copium
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID AssetFile::GetUUID() const
|
Uuid AssetFile::GetUuid() const
|
||||||
{
|
{
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ namespace Copium
|
|||||||
void AssetFile::Load(const MetaFile& metaFile, const std::string& className)
|
void AssetFile::Load(const MetaFile& metaFile, const std::string& className)
|
||||||
{
|
{
|
||||||
const MetaFileClass& metaClass = metaFile.GetMetaClass(className);
|
const MetaFileClass& metaClass = metaFile.GetMetaClass(className);
|
||||||
uuid = UUID{metaClass.GetValue("uuid")};
|
uuid = Uuid{metaClass.GetValue("uuid")};
|
||||||
dateModified = FileSystem::DateModified(path);
|
dateModified = FileSystem::DateModified(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "copium/asset/AssetMeta.h"
|
#include "copium/asset/AssetMeta.h"
|
||||||
#include "copium/util/MetaFile.h"
|
#include "copium/util/MetaFile.h"
|
||||||
#include "copium/util/UUID.h"
|
#include "copium/util/Uuid.h"
|
||||||
|
|
||||||
namespace Copium
|
namespace Copium
|
||||||
{
|
{
|
||||||
@@ -12,7 +12,7 @@ namespace Copium
|
|||||||
private:
|
private:
|
||||||
static std::vector<std::string> assetTypes;
|
static std::vector<std::string> assetTypes;
|
||||||
std::string path;
|
std::string path;
|
||||||
UUID uuid;
|
Uuid uuid;
|
||||||
int64_t dateModified;
|
int64_t dateModified;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -22,7 +22,7 @@ namespace Copium
|
|||||||
void Load();
|
void Load();
|
||||||
|
|
||||||
const std::string& GetPath() const;
|
const std::string& GetPath() const;
|
||||||
UUID GetUUID() const;
|
Uuid GetUuid() const;
|
||||||
private:
|
private:
|
||||||
void Load(const MetaFile& metaFile, const std::string& className);
|
void Load(const MetaFile& metaFile, const std::string& className);
|
||||||
static void RegisterAssetType(const std::string& assetType);
|
static void RegisterAssetType(const std::string& assetType);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Asset& AssetManager::LoadAsset(const UUID& uuid)
|
Asset& AssetManager::LoadAsset(const Uuid& uuid)
|
||||||
{
|
{
|
||||||
CP_DEBUG("Loading uuid Asset: %s", uuid.ToString().c_str());
|
CP_DEBUG("Loading uuid Asset: %s", uuid.ToString().c_str());
|
||||||
for (auto&& assetFile : cachedAssetFiles)
|
for (auto&& assetFile : cachedAssetFiles)
|
||||||
@@ -91,7 +91,7 @@ namespace Copium
|
|||||||
if (assetFile.NeedReload())
|
if (assetFile.NeedReload())
|
||||||
assetFile.Load();
|
assetFile.Load();
|
||||||
|
|
||||||
if (assetFile.GetUUID() != uuid)
|
if (assetFile.GetUuid() != uuid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return LoadAssetFromPath(assetFile.GetPath());
|
return LoadAssetFromPath(assetFile.GetPath());
|
||||||
@@ -145,7 +145,7 @@ namespace Copium
|
|||||||
Asset* asset2 = assets.emplace(handle, std::move(asset)).first->second.get();
|
Asset* asset2 = assets.emplace(handle, std::move(asset)).first->second.get();
|
||||||
asset2->metaData.handle = handle;
|
asset2->metaData.handle = handle;
|
||||||
asset2->metaData.name = name;
|
asset2->metaData.name = name;
|
||||||
asset2->metaData.uuid = UUID();
|
asset2->metaData.uuid = Uuid();
|
||||||
asset2->metaData.isRuntime = true;
|
asset2->metaData.isRuntime = true;
|
||||||
nameToAssetCache.emplace(name, handle);
|
nameToAssetCache.emplace(name, handle);
|
||||||
return *asset2;
|
return *asset2;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace Copium
|
|||||||
static void UnregisterAssetDir(std::string assetDir);
|
static void UnregisterAssetDir(std::string assetDir);
|
||||||
static Asset& GetAsset(AssetHandle handle);
|
static Asset& GetAsset(AssetHandle handle);
|
||||||
static Asset& LoadAsset(const std::string& assetPath);
|
static Asset& LoadAsset(const std::string& assetPath);
|
||||||
static Asset& LoadAsset(const UUID& uuid);
|
static Asset& LoadAsset(const Uuid& uuid);
|
||||||
static void UnloadAsset(AssetHandle handle);
|
static void UnloadAsset(AssetHandle handle);
|
||||||
static Asset& RegisterRuntimeAsset(const std::string& name, std::unique_ptr<Asset>&& asset);
|
static Asset& RegisterRuntimeAsset(const std::string& name, std::unique_ptr<Asset>&& asset);
|
||||||
static void Cleanup();
|
static void Cleanup();
|
||||||
@@ -51,7 +51,7 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename AssetT>
|
template <typename AssetT>
|
||||||
static AssetT& LoadAsset(const UUID& uuid)
|
static AssetT& LoadAsset(const Uuid& uuid)
|
||||||
{
|
{
|
||||||
AssetT* asset = dynamic_cast<AssetT*>(&LoadAsset(uuid));
|
AssetT* asset = dynamic_cast<AssetT*>(&LoadAsset(uuid));
|
||||||
CP_ASSERT(asset, "Invalid Asset cast");
|
CP_ASSERT(asset, "Invalid Asset cast");
|
||||||
@@ -86,7 +86,7 @@ namespace Copium
|
|||||||
Asset& asset = *assets.emplace(handle, std::make_unique<T>(metaFile)).first->second.get();
|
Asset& asset = *assets.emplace(handle, std::make_unique<T>(metaFile)).first->second.get();
|
||||||
asset.metaData.handle = handle;
|
asset.metaData.handle = handle;
|
||||||
asset.metaData.name = metaFile.GetFilePath();
|
asset.metaData.name = metaFile.GetFilePath();
|
||||||
asset.metaData.uuid = UUID{metaFile.GetMetaClass(metaFileClass).GetValue("uuid")};
|
asset.metaData.uuid = Uuid{metaFile.GetMetaClass(metaFileClass).GetValue("uuid")};
|
||||||
asset.metaData.isRuntime = false;
|
asset.metaData.isRuntime = false;
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "copium/util/UUID.h"
|
#include "copium/util/Uuid.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -14,7 +14,7 @@ namespace Copium
|
|||||||
{
|
{
|
||||||
AssetHandle handle;
|
AssetHandle handle;
|
||||||
std::string name;
|
std::string name;
|
||||||
UUID uuid;
|
Uuid uuid;
|
||||||
bool isRuntime = false;
|
bool isRuntime = false;
|
||||||
int loadCount = 1;
|
int loadCount = 1;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Copium
|
|||||||
Framebuffer::Framebuffer(const MetaFile& metaFile)
|
Framebuffer::Framebuffer(const MetaFile& metaFile)
|
||||||
{
|
{
|
||||||
const MetaFileClass& metaClass = metaFile.GetMetaClass("Framebuffer");
|
const MetaFileClass& metaClass = metaFile.GetMetaClass("Framebuffer");
|
||||||
ColorAttachment& attachment = AssetManager::LoadAsset<ColorAttachment>(UUID{metaClass.GetValue("rendertexture-uuid")});
|
ColorAttachment& attachment = AssetManager::LoadAsset<ColorAttachment>(Uuid{metaClass.GetValue("rendertexture-uuid")});
|
||||||
colorAttachment = attachment;
|
colorAttachment = attachment;
|
||||||
width = attachment.GetWidth();
|
width = attachment.GetWidth();
|
||||||
height = attachment.GetHeight();
|
height = attachment.GetHeight();
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace Copium
|
|||||||
|
|
||||||
std::sort(devicePriorities.begin(), devicePriorities.end(), [](const std::pair<VkPhysicalDevice, uint32_t>& lhs, const std::pair<VkPhysicalDevice, uint32_t>& rhs) { return lhs.second > rhs.second; });
|
std::sort(devicePriorities.begin(), devicePriorities.end(), [](const std::pair<VkPhysicalDevice, uint32_t>& lhs, const std::pair<VkPhysicalDevice, uint32_t>& rhs) { return lhs.second > rhs.second; });
|
||||||
auto&& it = devicePriorities.begin();
|
auto&& it = devicePriorities.begin();
|
||||||
CP_ASSERT(it->second != 0, "Failed to find suitable GPU");
|
CP_ASSERT(it->second != 0, "Failed to find suitable gpu");
|
||||||
|
|
||||||
VkPhysicalDeviceProperties deviceProperties;
|
VkPhysicalDeviceProperties deviceProperties;
|
||||||
vkGetPhysicalDeviceProperties(it->first, &deviceProperties);
|
vkGetPhysicalDeviceProperties(it->first, &deviceProperties);
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ namespace Copium
|
|||||||
std::vector<Component> components;
|
std::vector<Component> components;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ComponentPool(EntityID entity, const Component& component)
|
ComponentPool(EntityId entity, const Component& component)
|
||||||
{
|
{
|
||||||
Emplace(entity, component);
|
Emplace(entity, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
Component& Emplace(EntityID entity, const Component& component)
|
Component& Emplace(EntityId entity, const Component& component)
|
||||||
{
|
{
|
||||||
components.push_back(component);
|
components.push_back(component);
|
||||||
entities.Emplace(entity);
|
entities.Emplace(entity);
|
||||||
@@ -34,7 +34,7 @@ namespace Copium
|
|||||||
entities.Pop();
|
entities.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Erase(EntityID entity)
|
bool Erase(EntityId entity)
|
||||||
{
|
{
|
||||||
size_t index = entities.Find(entity);
|
size_t index = entities.Find(entity);
|
||||||
if (!entities.Erase(entity))
|
if (!entities.Erase(entity))
|
||||||
@@ -48,12 +48,12 @@ namespace Copium
|
|||||||
return operator[](index);
|
return operator[](index);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Find(EntityID entity)
|
size_t Find(EntityId entity)
|
||||||
{
|
{
|
||||||
return entities.Find(entity);
|
return entities.Find(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
Component* FindComponent(EntityID entity)
|
Component* FindComponent(EntityId entity)
|
||||||
{
|
{
|
||||||
size_t index = Find(entity);
|
size_t index = Find(entity);
|
||||||
if (index < Size())
|
if (index < Size())
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace Copium
|
namespace Copium
|
||||||
{
|
{
|
||||||
std::vector<EntityID>& ComponentPoolBase::GetEntities()
|
std::vector<EntityId>& ComponentPoolBase::GetEntities()
|
||||||
{
|
{
|
||||||
return entities.GetList();
|
return entities.GetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<EntityID>& ComponentPoolBase::GetEntities() const
|
const std::vector<EntityId>& ComponentPoolBase::GetEntities() const
|
||||||
{
|
{
|
||||||
return entities.GetList();
|
return entities.GetList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ namespace Copium
|
|||||||
|
|
||||||
virtual size_t Size() = 0;
|
virtual size_t Size() = 0;
|
||||||
virtual void Pop() = 0;
|
virtual void Pop() = 0;
|
||||||
virtual bool Erase(EntityID entity) = 0;
|
virtual bool Erase(EntityId entity) = 0;
|
||||||
std::vector<EntityID>& GetEntities();
|
std::vector<EntityId>& GetEntities();
|
||||||
const std::vector<EntityID>& GetEntities() const;
|
const std::vector<EntityId>& GetEntities() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace Copium
|
namespace Copium
|
||||||
{
|
{
|
||||||
using EntityID = uint32_t;
|
using EntityId = uint32_t;
|
||||||
const static uint32_t MAX_NUM_ENTITIES = std::numeric_limits<uint32_t>::max();
|
const static uint32_t MAX_NUM_ENTITIES = std::numeric_limits<uint32_t>::max();
|
||||||
const static uint32_t INVALID_ENTITY = 0;
|
const static uint32_t INVALID_ENTITY = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Copium
|
|||||||
return entities.size();
|
return entities.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityID ECSManager::CreateEntity()
|
EntityId ECSManager::CreateEntity()
|
||||||
{
|
{
|
||||||
CP_ASSERT(currentEntityId != MAX_NUM_ENTITIES, "No more entities available");
|
CP_ASSERT(currentEntityId != MAX_NUM_ENTITIES, "No more entities available");
|
||||||
entities.emplace(currentEntityId);
|
entities.emplace(currentEntityId);
|
||||||
@@ -35,7 +35,7 @@ namespace Copium
|
|||||||
return currentEntityId - 1;
|
return currentEntityId - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ECSManager::DestroyEntity(EntityID entity)
|
void ECSManager::DestroyEntity(EntityId entity)
|
||||||
{
|
{
|
||||||
auto it = entities.find(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=%u)", entity);
|
||||||
@@ -46,12 +46,12 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ECSManager::ValidEntity(EntityID entity)
|
bool ECSManager::ValidEntity(EntityId entity)
|
||||||
{
|
{
|
||||||
return entities.find(entity) != entities.end();
|
return entities.find(entity) != entities.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ECSManager::Each(std::function<void(EntityID)> function)
|
void ECSManager::Each(std::function<void(EntityId)> function)
|
||||||
{
|
{
|
||||||
for (auto e : entities)
|
for (auto e : entities)
|
||||||
function(e);
|
function(e);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Copium
|
|||||||
class ECSManager final
|
class ECSManager final
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::unordered_set<EntityID> entities;
|
std::unordered_set<EntityId> entities;
|
||||||
std::map<std::type_index, ComponentPoolBase*> componentPool;
|
std::map<std::type_index, ComponentPoolBase*> componentPool;
|
||||||
|
|
||||||
std::unique_ptr<SystemPool> systemPool;
|
std::unique_ptr<SystemPool> systemPool;
|
||||||
@@ -34,26 +34,26 @@ namespace Copium
|
|||||||
|
|
||||||
void UpdateSystems();
|
void UpdateSystems();
|
||||||
|
|
||||||
EntityID CreateEntity();
|
EntityId CreateEntity();
|
||||||
void DestroyEntity(EntityID entity);
|
void DestroyEntity(EntityId entity);
|
||||||
size_t GetEntityCount() const;
|
size_t GetEntityCount() const;
|
||||||
bool ValidEntity(EntityID entity);
|
bool ValidEntity(EntityId entity);
|
||||||
void Each(std::function<void(EntityID)> function);
|
void Each(std::function<void(EntityId)> function);
|
||||||
|
|
||||||
template <typename... Components>
|
template <typename... Components>
|
||||||
std::tuple<Components&...> AddComponents(EntityID entity, Components&&... components)
|
std::tuple<Components&...> AddComponents(EntityId entity, Components&&... components)
|
||||||
{
|
{
|
||||||
return std::forward_as_tuple(AddComponent(entity, Components(components))...);
|
return std::forward_as_tuple(AddComponent(entity, Components(components))...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component, typename... Args>
|
template <typename Component, typename... Args>
|
||||||
Component& AddComponent(EntityID entity, Args&&... args)
|
Component& AddComponent(EntityId entity, Args&&... args)
|
||||||
{
|
{
|
||||||
return AddComponent(entity, Component{args...});
|
return AddComponent(entity, Component{args...});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
Component& AddComponent(EntityID entity, const Component& component)
|
Component& AddComponent(EntityId entity, const Component& component)
|
||||||
{
|
{
|
||||||
auto pool = GetComponentPool<Component>();
|
auto pool = GetComponentPool<Component>();
|
||||||
|
|
||||||
@@ -71,20 +71,20 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
void RemoveComponent(EntityID entity)
|
void RemoveComponent(EntityId entity)
|
||||||
{
|
{
|
||||||
auto pool = GetComponentPoolAssure<Component>();
|
auto pool = GetComponentPoolAssure<Component>();
|
||||||
CP_ASSERT(pool->Erase(entity), "Entity did not contain component (entity=%u, Component=%s)", entity, typeid(Component).name());
|
CP_ASSERT(pool->Erase(entity), "Entity did not contain component (entity=%u, Component=%s)", entity, typeid(Component).name());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Components>
|
template <typename... Components>
|
||||||
void RemoveComponents(EntityID entity)
|
void RemoveComponents(EntityId entity)
|
||||||
{
|
{
|
||||||
(RemoveComponent<Components>(entity), ...);
|
(RemoveComponent<Components>(entity), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
Component& GetComponent(EntityID entity)
|
Component& GetComponent(EntityId entity)
|
||||||
{
|
{
|
||||||
auto pool = GetComponentPoolAssure<Component>();
|
auto pool = GetComponentPoolAssure<Component>();
|
||||||
Component* component = pool->FindComponent(entity);
|
Component* component = pool->FindComponent(entity);
|
||||||
@@ -93,7 +93,7 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
bool HasComponent(EntityID entity)
|
bool HasComponent(EntityId entity)
|
||||||
{
|
{
|
||||||
auto pool = GetComponentPool<Component>();
|
auto pool = GetComponentPool<Component>();
|
||||||
if (pool)
|
if (pool)
|
||||||
@@ -102,13 +102,13 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Components>
|
template <typename... Components>
|
||||||
bool HasComponents(EntityID entity)
|
bool HasComponents(EntityId entity)
|
||||||
{
|
{
|
||||||
return (HasComponent<Components>(entity) && ...);
|
return (HasComponent<Components>(entity) && ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Components>
|
template <typename... Components>
|
||||||
bool HasAnyComponent(EntityID entity)
|
bool HasAnyComponent(EntityId entity)
|
||||||
{
|
{
|
||||||
return (HasComponent<Components>(entity) || ...);
|
return (HasComponent<Components>(entity) || ...);
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
void Each(std::function<void(EntityID, Component&)> function)
|
void Each(std::function<void(EntityId, Component&)> function)
|
||||||
{
|
{
|
||||||
auto pool = GetComponentPool<Component>();
|
auto pool = GetComponentPool<Component>();
|
||||||
if (pool)
|
if (pool)
|
||||||
@@ -147,7 +147,7 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component, typename... Components, typename Func>
|
template <typename Component, typename... Components, typename Func>
|
||||||
EntityID Find(Func function)
|
EntityId Find(Func function)
|
||||||
{
|
{
|
||||||
auto pool = GetComponentPool<Component>();
|
auto pool = GetComponentPool<Component>();
|
||||||
if (pool)
|
if (pool)
|
||||||
@@ -167,7 +167,7 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
EntityID Find(std::function<bool(EntityID, Component&)> function)
|
EntityId Find(std::function<bool(EntityId, Component&)> function)
|
||||||
{
|
{
|
||||||
auto pool = GetComponentPool<Component>();
|
auto pool = GetComponentPool<Component>();
|
||||||
if (pool)
|
if (pool)
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ namespace Copium
|
|||||||
: manager{manager}, id{INVALID_ENTITY}
|
: manager{manager}, id{INVALID_ENTITY}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Entity::Entity(ECSManager* manager, EntityID id)
|
Entity::Entity(ECSManager* manager, EntityId id)
|
||||||
: manager{manager}, id{id}
|
: manager{manager}, id{id}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Entity::operator EntityID() const
|
Entity::operator EntityId() const
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::operator=(EntityID entityId)
|
void Entity::operator=(EntityId entityId)
|
||||||
{
|
{
|
||||||
id = entityId;
|
id = entityId;
|
||||||
}
|
}
|
||||||
@@ -54,12 +54,12 @@ namespace Copium
|
|||||||
manager->DestroyEntity(id);
|
manager->DestroyEntity(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::SetID(EntityID aId)
|
void Entity::SetId(EntityId entityId)
|
||||||
{
|
{
|
||||||
id = aId;
|
id = entityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityID Entity::GetID() const
|
EntityId Entity::GetId() const
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,23 +11,23 @@ namespace Copium
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ECSManager* manager;
|
ECSManager* manager;
|
||||||
EntityID id;
|
EntityId id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Entity();
|
Entity();
|
||||||
Entity(ECSManager* manager);
|
Entity(ECSManager* manager);
|
||||||
Entity(ECSManager* manager, EntityID id);
|
Entity(ECSManager* manager, EntityId id);
|
||||||
|
|
||||||
operator EntityID() const;
|
operator EntityId() const;
|
||||||
void operator=(EntityID entityId);
|
void operator=(EntityId entityId);
|
||||||
bool operator==(const Entity& entity);
|
bool operator==(const Entity& entity);
|
||||||
bool operator!=(const Entity& entity);
|
bool operator!=(const Entity& entity);
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
|
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
void SetID(EntityID aId);
|
void SetId(EntityId entityId);
|
||||||
EntityID GetID() const;
|
EntityId GetId() const;
|
||||||
ECSManager* GetManager() const;
|
ECSManager* GetManager() const;
|
||||||
|
|
||||||
static Entity Create(ECSManager* manager);
|
static Entity Create(ECSManager* manager);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Copium
|
namespace Copium
|
||||||
{
|
{
|
||||||
bool EntitySet::Emplace(EntityID entity)
|
bool EntitySet::Emplace(EntityId entity)
|
||||||
{
|
{
|
||||||
auto res = entitiesMap.emplace(entity, entitiesList.size());
|
auto res = entitiesMap.emplace(entity, entitiesList.size());
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ namespace Copium
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntitySet::Erase(EntityID entity)
|
bool EntitySet::Erase(EntityId entity)
|
||||||
{
|
{
|
||||||
auto it = entitiesMap.find(entity);
|
auto it = entitiesMap.find(entity);
|
||||||
if (it == entitiesMap.end())
|
if (it == entitiesMap.end())
|
||||||
@@ -42,7 +42,7 @@ namespace Copium
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t EntitySet::Find(EntityID entity)
|
size_t EntitySet::Find(EntityId entity)
|
||||||
{
|
{
|
||||||
auto it = entitiesMap.find(entity);
|
auto it = entitiesMap.find(entity);
|
||||||
if (it == entitiesMap.end())
|
if (it == entitiesMap.end())
|
||||||
@@ -55,9 +55,9 @@ namespace Copium
|
|||||||
return entitiesList.size();
|
return entitiesList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<EntityID>& EntitySet::GetList() { return entitiesList; }
|
std::vector<EntityId>& EntitySet::GetList() { return entitiesList; }
|
||||||
const std::vector<EntityID>& EntitySet::GetList() const { return entitiesList; }
|
const std::vector<EntityId>& EntitySet::GetList() const { return entitiesList; }
|
||||||
|
|
||||||
std::vector<EntityID>::iterator EntitySet::begin() { return entitiesList.begin(); }
|
std::vector<EntityId>::iterator EntitySet::begin() { return entitiesList.begin(); }
|
||||||
std::vector<EntityID>::iterator EntitySet::end() { return entitiesList.end(); }
|
std::vector<EntityId>::iterator EntitySet::end() { return entitiesList.end(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,18 +10,18 @@ namespace Copium
|
|||||||
class EntitySet
|
class EntitySet
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<EntityID> entitiesList;
|
std::vector<EntityId> entitiesList;
|
||||||
std::unordered_map<EntityID, size_t> entitiesMap; // Maps the entity id to a component index
|
std::unordered_map<EntityId, size_t> entitiesMap; // Maps the entity id to a component index
|
||||||
public:
|
public:
|
||||||
bool Emplace(EntityID entity);
|
bool Emplace(EntityId entity);
|
||||||
bool Erase(EntityID entity);
|
bool Erase(EntityId entity);
|
||||||
bool Pop();
|
bool Pop();
|
||||||
size_t Find(EntityID entity);
|
size_t Find(EntityId entity);
|
||||||
size_t Size() const;
|
size_t Size() const;
|
||||||
std::vector<EntityID>& GetList();
|
std::vector<EntityId>& GetList();
|
||||||
const std::vector<EntityID>& GetList() const;
|
const std::vector<EntityId>& GetList() const;
|
||||||
|
|
||||||
std::vector<EntityID>::iterator begin();
|
std::vector<EntityId>::iterator begin();
|
||||||
std::vector<EntityID>::iterator end();
|
std::vector<EntityId>::iterator end();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Copium
|
|||||||
public:
|
public:
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
manager->Each<Components...>([&](EntityID entityId, Components&... components) { RunEntity(Entity{manager, entityId}, components...); });
|
manager->Each<Components...>([&](EntityId entityId, Components&... components) { RunEntity(Entity{manager, entityId}, components...); });
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void RunEntity(Entity entity, Components&... components) = 0;
|
virtual void RunEntity(Entity entity, Components&... components) = 0;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Copium
|
|||||||
VkRenderPass renderPass;
|
VkRenderPass renderPass;
|
||||||
if (metaFileClass.HasValue("framebuffer-uuid"))
|
if (metaFileClass.HasValue("framebuffer-uuid"))
|
||||||
{
|
{
|
||||||
Framebuffer& fb = AssetManager::LoadAsset<Framebuffer>(UUID{metaFileClass.GetValue("framebuffer-uuid")});
|
Framebuffer& fb = AssetManager::LoadAsset<Framebuffer>(Uuid{metaFileClass.GetValue("framebuffer-uuid")});
|
||||||
renderPass = fb.GetRenderPass();
|
renderPass = fb.GetRenderPass();
|
||||||
framebuffer = fb;
|
framebuffer = fb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
#include "copium/util/UUID.h"
|
#include "copium/util/Uuid.h"
|
||||||
|
|
||||||
#include "copium/util/Common.h"
|
#include "copium/util/Common.h"
|
||||||
|
|
||||||
namespace Copium
|
namespace Copium
|
||||||
{
|
{
|
||||||
|
|
||||||
std::random_device UUID::randomDevice{};
|
std::random_device Uuid::randomDevice{};
|
||||||
std::mt19937 UUID::randomGenerator{randomDevice()};
|
std::mt19937 Uuid::randomGenerator{randomDevice()};
|
||||||
std::uniform_int_distribution<uint64_t> UUID::randomDistribution{std::numeric_limits<uint64_t>::min(), std::numeric_limits<uint64_t>::max()};
|
std::uniform_int_distribution<uint64_t> Uuid::randomDistribution{std::numeric_limits<uint64_t>::min(), std::numeric_limits<uint64_t>::max()};
|
||||||
|
|
||||||
UUID::UUID()
|
Uuid::Uuid()
|
||||||
: msb{randomDistribution(randomGenerator)}, lsb{randomDistribution(randomGenerator)}
|
: msb{randomDistribution(randomGenerator)}, lsb{randomDistribution(randomGenerator)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
UUID::UUID(uint64_t msb, uint64_t lsb)
|
Uuid::Uuid(uint64_t msb, uint64_t lsb)
|
||||||
: msb{msb}, lsb{lsb}
|
: msb{msb}, lsb{lsb}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
UUID::UUID(const std::string& uuidString)
|
Uuid::Uuid(const std::string& uuidString)
|
||||||
: msb{0}, lsb{0}
|
: msb{0}, lsb{0}
|
||||||
{
|
{
|
||||||
CP_ASSERT(uuidString.size() == 36, "Invalid UUID string size: %s", uuidString.c_str());
|
CP_ASSERT(uuidString.size() == 36, "Invalid Uuid string size: %s", uuidString.c_str());
|
||||||
for (int i = 0; i < 18; i++)
|
for (int i = 0; i < 18; i++)
|
||||||
{
|
{
|
||||||
if (i == 8 || i == 13) // skip "-"
|
if (i == 8 || i == 13) // skip "-"
|
||||||
@@ -37,7 +37,7 @@ namespace Copium
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UUID::ToString() const
|
std::string Uuid::ToString() const
|
||||||
{
|
{
|
||||||
std::string string;
|
std::string string;
|
||||||
string.reserve(36);
|
string.reserve(36);
|
||||||
@@ -55,36 +55,36 @@ namespace Copium
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UUID::operator==(const UUID& rhs)
|
bool Uuid::operator==(const Uuid& rhs)
|
||||||
{
|
{
|
||||||
return msb == rhs.msb && lsb == rhs.lsb;
|
return msb == rhs.msb && lsb == rhs.lsb;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UUID::operator!=(const UUID& rhs)
|
bool Uuid::operator!=(const Uuid& rhs)
|
||||||
{
|
{
|
||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UUID::operator<(const UUID& rhs)
|
bool Uuid::operator<(const Uuid& rhs)
|
||||||
{
|
{
|
||||||
if (msb != rhs.msb)
|
if (msb != rhs.msb)
|
||||||
return msb < rhs.msb;
|
return msb < rhs.msb;
|
||||||
return lsb < rhs.lsb;
|
return lsb < rhs.lsb;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const UUID& uuid)
|
std::ostream& operator<<(std::ostream& os, const Uuid& uuid)
|
||||||
{
|
{
|
||||||
return os << uuid.ToString();
|
return os << uuid.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t UUID::HexToDec(char c) const
|
uint8_t Uuid::HexToDec(char c) const
|
||||||
{
|
{
|
||||||
if (c >= '0' && c <= '9') return c - '0';
|
if (c >= '0' && c <= '9') return c - '0';
|
||||||
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
||||||
CP_ABORT("Invalid char value: %c (%d)", c, (int)c);
|
CP_ABORT("Invalid char value: %c (%d)", c, (int)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
char UUID::DecToHex(uint8_t nibble) const
|
char Uuid::DecToHex(uint8_t nibble) const
|
||||||
{
|
{
|
||||||
if (nibble >= 0 && nibble <= 9) return '0' + nibble;
|
if (nibble >= 0 && nibble <= 9) return '0' + nibble;
|
||||||
if (nibble >= 10 && nibble <= 15) return 'a' + nibble - 10;
|
if (nibble >= 10 && nibble <= 15) return 'a' + nibble - 10;
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace Copium
|
namespace Copium
|
||||||
{
|
{
|
||||||
class UUID
|
class Uuid
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
uint64_t msb;
|
uint64_t msb;
|
||||||
@@ -15,18 +15,18 @@ namespace Copium
|
|||||||
static std::mt19937 randomGenerator;
|
static std::mt19937 randomGenerator;
|
||||||
static std::uniform_int_distribution<uint64_t> randomDistribution;
|
static std::uniform_int_distribution<uint64_t> randomDistribution;
|
||||||
public:
|
public:
|
||||||
UUID();
|
Uuid();
|
||||||
UUID(uint64_t msb, uint64_t lsb);
|
Uuid(uint64_t msb, uint64_t lsb);
|
||||||
// Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
// Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||||
UUID(const std::string& uuidString);
|
Uuid(const std::string& uuidString);
|
||||||
|
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
|
|
||||||
bool operator==(const UUID& rhs);
|
bool operator==(const Uuid& rhs);
|
||||||
bool operator!=(const UUID& rhs);
|
bool operator!=(const Uuid& rhs);
|
||||||
bool operator<(const UUID& rhs);
|
bool operator<(const Uuid& rhs);
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const UUID& uuid);
|
friend std::ostream& operator<<(std::ostream& os, const Uuid& uuid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t HexToDec(char c) const;
|
uint8_t HexToDec(char c) const;
|
||||||
Reference in New Issue
Block a user