Skip to content

Add a clear() method to VertexBuffers #903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading