Skip to content

Commit

Permalink
Add a clear() method to VertexBuffers
Browse files Browse the repository at this point in the history
This is just a convenience method for easier reuse.
  • Loading branch information
tgross35 authored and nical committed May 15, 2024
1 parent c65b5da commit 8a451c1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/tessellation/src/geometry_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@
//! ```
//!
pub use crate::error::GeometryBuilderError;
use crate::math::Point;
use crate::{FillVertex, Index, StrokeVertex, VertexId};
pub use crate::error::GeometryBuilderError;

use alloc::vec::Vec;
use core::convert::From;
use core::ops::Add;
use alloc::vec::Vec;

/// An interface separating tessellators and other geometry generation algorithms from the
/// actual vertex construction.
Expand Down Expand Up @@ -277,6 +277,12 @@ impl<OutputVertex, OutputIndex> VertexBuffers<OutputVertex, OutputIndex> {
indices: Vec::with_capacity(num_indices),
}
}

/// Empty the buffers without freeing memory, for reuse without reallocation.
pub fn clear(&mut self) {
self.vertices.clear();
self.indices.clear();
}
}

/// A temporary view on a `VertexBuffers` object which facilitate the population of vertex and index
Expand Down

0 comments on commit 8a451c1

Please sign in to comment.