Basic mutability framework
This commit is contained in:
@@ -9,6 +9,7 @@ Asset::Asset()
|
||||
, parentDir("")
|
||||
, extension("")
|
||||
, status(Status::Uninitialized)
|
||||
, byteSize(0)
|
||||
{
|
||||
}
|
||||
Asset::Asset(const std::filesystem::path& path)
|
||||
|
||||
@@ -28,12 +28,12 @@ public:
|
||||
std::string getExtension() const;
|
||||
inline Status getStatus()
|
||||
{
|
||||
std::unique_lock lck(lock);
|
||||
std::scoped_lock lck(lock);
|
||||
return status;
|
||||
}
|
||||
inline void setStatus(Status status)
|
||||
{
|
||||
std::unique_lock lck(lock);
|
||||
std::scoped_lock lck(lock);
|
||||
this->status = status;
|
||||
}
|
||||
protected:
|
||||
|
||||
@@ -25,24 +25,20 @@ MeshAsset::~MeshAsset()
|
||||
}
|
||||
void MeshAsset::save()
|
||||
{
|
||||
boost::archive::text_oarchive archive(getWriteStream());
|
||||
archive << meshes;
|
||||
}
|
||||
void MeshAsset::load()
|
||||
{
|
||||
boost::archive::text_iarchive archive(getReadStream());
|
||||
archive >> meshes;
|
||||
}
|
||||
|
||||
void MeshAsset::addMesh(PMesh mesh)
|
||||
{
|
||||
std::unique_lock lck(lock);
|
||||
meshes.add(mesh);
|
||||
referencedMaterials.add(mesh->referencedMaterial);
|
||||
std::scoped_lock lck(lock);
|
||||
meshes.push_back(mesh);
|
||||
referencedMaterials.push_back(mesh->referencedMaterial);
|
||||
}
|
||||
|
||||
const Array<PMesh> MeshAsset::getMeshes()
|
||||
const std::vector<PMesh> MeshAsset::getMeshes()
|
||||
{
|
||||
std::unique_lock lck(lock);
|
||||
std::scoped_lock lck(lock);
|
||||
return meshes;
|
||||
}
|
||||
@@ -15,11 +15,11 @@ public:
|
||||
virtual void save() override;
|
||||
virtual void load() override;
|
||||
void addMesh(PMesh mesh);
|
||||
const Array<PMesh> getMeshes();
|
||||
const std::vector<PMesh> getMeshes();
|
||||
//Workaround while no editor
|
||||
Array<PMaterialAsset> referencedMaterials;
|
||||
std::vector<PMaterialAsset> referencedMaterials;
|
||||
private:
|
||||
Array<PMesh> meshes;
|
||||
std::vector<PMesh> meshes;
|
||||
};
|
||||
DEFINE_REF(MeshAsset)
|
||||
} // namespace Seele
|
||||
@@ -122,7 +122,9 @@ VertexStreamComponent createVertexStream(uint32 size, aiVector3D* sourceData, Gf
|
||||
vbInfo.resourceData.data = (uint8 *)buffer.data();
|
||||
vbInfo.resourceData.owner = Gfx::QueueType::DEDICATED_TRANSFER;
|
||||
vbInfo.resourceData.size = sizeof(Vector) * (uint32)buffer.size();
|
||||
return VertexStreamComponent(graphics->createVertexBuffer(vbInfo), 0, vbInfo.vertexSize, Gfx::SE_FORMAT_R32G32B32_SFLOAT);
|
||||
Gfx::PVertexBuffer vertexBuffer = graphics->createVertexBuffer(vbInfo);
|
||||
vertexBuffer->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||
return VertexStreamComponent(vertexBuffer, 0, vbInfo.vertexSize, Gfx::SE_FORMAT_R32G32B32_SFLOAT);
|
||||
}
|
||||
VertexStreamComponent createVertexStream(uint32 size, aiVector2D* sourceData, Gfx::PGraphics graphics)
|
||||
{
|
||||
@@ -137,7 +139,9 @@ VertexStreamComponent createVertexStream(uint32 size, aiVector2D* sourceData, Gf
|
||||
vbInfo.resourceData.data = (uint8 *)buffer.data();
|
||||
vbInfo.resourceData.owner = Gfx::QueueType::DEDICATED_TRANSFER;
|
||||
vbInfo.resourceData.size = sizeof(Vector2) * (uint32)buffer.size();
|
||||
return VertexStreamComponent(graphics->createVertexBuffer(vbInfo), 0, vbInfo.vertexSize, Gfx::SE_FORMAT_R32G32_SFLOAT);
|
||||
Gfx::PVertexBuffer vertexBuffer = graphics->createVertexBuffer(vbInfo);
|
||||
vertexBuffer->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||
return VertexStreamComponent(vertexBuffer, 0, vbInfo.vertexSize, Gfx::SE_FORMAT_R32G32_SFLOAT);
|
||||
}
|
||||
void MeshLoader::loadGlobalMeshes(const aiScene* scene, Array<PMesh>& globalMeshes, const Array<PMaterialAsset>& materials, Gfx::PGraphics graphics)
|
||||
{
|
||||
|
||||
@@ -14,12 +14,12 @@ public:
|
||||
virtual void load() override;
|
||||
void setTexture(Gfx::PTexture texture)
|
||||
{
|
||||
std::unique_lock lck(lock);
|
||||
std::scoped_lock lck(lock);
|
||||
this->texture = texture;
|
||||
}
|
||||
Gfx::PTexture getTexture()
|
||||
{
|
||||
std::unique_lock lck(lock);
|
||||
std::scoped_lock lck(lock);
|
||||
return texture;
|
||||
}
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user