fix: boundary check condition in renderstate (#7274)
This commit is contained in:
1 file changed
+6
-4
@@ -308,16 +308,18 @@ impl<'a> QuadAllocator for MappedQuads<'a> {
|
||||
|
||||
fn extend_with(&mut self, vertices: &[Vertex]) {
|
||||
let idx = *self.next;
|
||||
let len = vertices.len();
|
||||
|
||||
// idx and next are number of quads, so divide by number of vertices
|
||||
*self.next += vertices.len() / VERTICES_PER_CELL;
|
||||
*self.next += len / VERTICES_PER_CELL;
|
||||
// Only copy in if there is enough room.
|
||||
// We'll detect the out of space condition at the end of
|
||||
// the render pass.
|
||||
let idx = idx * VERTICES_PER_CELL;
|
||||
let len = self.capacity * VERTICES_PER_CELL;
|
||||
if idx + vertices.len() < len {
|
||||
let capacity = self.capacity * VERTICES_PER_CELL;
|
||||
if idx + len <= capacity {
|
||||
self.mapping
|
||||
.slice_mut(idx..idx + vertices.len())
|
||||
.slice_mut(idx..idx + len)
|
||||
.copy_from_slice(vertices);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user