starting to add mesh update

This commit is contained in:
Dynamitos
2025-04-14 16:03:22 +02:00
parent 3213289f10
commit d0899355c5
2 changed files with 10 additions and 3 deletions
+9 -3
View File
@@ -141,8 +141,7 @@ void VertexData::createDescriptors() {
void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet> loadedMeshlets) {
std::unique_lock l(vertexDataLock);
uint32 numChunks = (loadedMeshlets.size() + 2047) / 2048;
for(uint32 chunkIdx = 0; chunkIdx < numChunks; ++chunkIdx)
{
for (uint32 chunkIdx = 0; chunkIdx < numChunks; ++chunkIdx) {
uint32 meshletOffset = (uint32)meshlets.size();
AABB meshAABB;
uint32 numMeshlets = 0;
@@ -174,7 +173,6 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
.numMeshlets = numMeshlets,
.meshletOffset = meshletOffset,
});
}
// todo: in case of a index split for 16 bit, do something here
meshData[id][0].firstIndex = (uint32)indices.size();
@@ -183,6 +181,14 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
std::memcpy(indices.data() + meshData[id][0].firstIndex, loadedIndices.data(), loadedIndices.size() * sizeof(uint32));
}
void VertexData::updateMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets) {
uint32 numMeshlets = 0;
for (const auto& dat : meshData[id]) {
numMeshlets += dat.numMeshlets;
}
int32 difference = meshlets.size() - numMeshlets;
}
void VertexData::commitMeshes() {
indexBuffer = graphics->createIndexBuffer(IndexBufferCreateInfo{
.sourceData =
+1
View File
@@ -58,6 +58,7 @@ class VertexData {
void updateMesh(uint32 meshletOffset, PMesh mesh, Component::Transform& transform);
virtual void createDescriptors();
void loadMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
void updateMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
void commitMeshes();
MeshId allocateVertexData(uint64 numVertices);
uint64 getMeshOffset(MeshId id) const { return meshOffsets[id]; }