Skip to content

Commit

Permalink
#219: Fix a sync range problem in WindingRenderer. Removing a winding…
Browse files Browse the repository at this point in the history
… from the buffer has to invalidate all data to the right.
  • Loading branch information
codereader committed Mar 27, 2022
1 parent 635e6a7 commit 5ad75e5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions radiantcore/rendersystem/backend/WindingRenderer.h
Expand Up @@ -448,7 +448,7 @@ class WindingRenderer final :
auto& bucket = _buckets.at(bucketIndex);
bucket.pendingDeletions.push_back(slotMapping.slotNumber);

updateModifiedRange(bucket, slotMapping.slotNumber);
updateModifiedRange(bucket, slotMapping.slotNumber, true); // true => deletion

// Invalidate the slot mapping
slotMapping.bucketIndex = InvalidBucketIndex;
Expand Down Expand Up @@ -565,11 +565,21 @@ class WindingRenderer final :
syncWithGeometryStore(bucket);
}

void updateModifiedRange(Bucket& bucket, typename VertexBuffer::Slot modifiedSlot)
void updateModifiedRange(Bucket& bucket, typename VertexBuffer::Slot modifiedSlot, bool dueToDeletion = false)
{
// Update the modified range
bucket.modifiedSlotRange.first = std::min(bucket.modifiedSlotRange.first, modifiedSlot);
bucket.modifiedSlotRange.second = std::max(bucket.modifiedSlotRange.second, modifiedSlot);

if (!dueToDeletion)
{
bucket.modifiedSlotRange.second = std::max(bucket.modifiedSlotRange.second, modifiedSlot);
}
else
{
// Deletions invalidates all data to the right
bucket.modifiedSlotRange.second = static_cast<typename VertexBuffer::Slot>(bucket.buffer.getNumberOfStoredWindings());
}

_geometryUpdatePending = true;
}

Expand Down

0 comments on commit 5ad75e5

Please sign in to comment.