starting to add mesh update
This commit is contained in:
@@ -141,8 +141,7 @@ void VertexData::createDescriptors() {
|
|||||||
void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet> loadedMeshlets) {
|
void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet> loadedMeshlets) {
|
||||||
std::unique_lock l(vertexDataLock);
|
std::unique_lock l(vertexDataLock);
|
||||||
uint32 numChunks = (loadedMeshlets.size() + 2047) / 2048;
|
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();
|
uint32 meshletOffset = (uint32)meshlets.size();
|
||||||
AABB meshAABB;
|
AABB meshAABB;
|
||||||
uint32 numMeshlets = 0;
|
uint32 numMeshlets = 0;
|
||||||
@@ -174,7 +173,6 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
|||||||
.numMeshlets = numMeshlets,
|
.numMeshlets = numMeshlets,
|
||||||
.meshletOffset = meshletOffset,
|
.meshletOffset = meshletOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
// todo: in case of a index split for 16 bit, do something here
|
// todo: in case of a index split for 16 bit, do something here
|
||||||
meshData[id][0].firstIndex = (uint32)indices.size();
|
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));
|
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() {
|
void VertexData::commitMeshes() {
|
||||||
indexBuffer = graphics->createIndexBuffer(IndexBufferCreateInfo{
|
indexBuffer = graphics->createIndexBuffer(IndexBufferCreateInfo{
|
||||||
.sourceData =
|
.sourceData =
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class VertexData {
|
|||||||
void updateMesh(uint32 meshletOffset, PMesh mesh, Component::Transform& transform);
|
void updateMesh(uint32 meshletOffset, PMesh mesh, Component::Transform& transform);
|
||||||
virtual void createDescriptors();
|
virtual void createDescriptors();
|
||||||
void loadMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
|
void loadMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
|
||||||
|
void updateMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
|
||||||
void commitMeshes();
|
void commitMeshes();
|
||||||
MeshId allocateVertexData(uint64 numVertices);
|
MeshId allocateVertexData(uint64 numVertices);
|
||||||
uint64 getMeshOffset(MeshId id) const { return meshOffsets[id]; }
|
uint64 getMeshOffset(MeshId id) const { return meshOffsets[id]; }
|
||||||
|
|||||||
Reference in New Issue
Block a user