epaint: add some missing inline docs (#4815)

Document a few `Mesh` methods.
This commit is contained in:
Wojciech Muła 2024-07-11 11:52:27 +02:00 committed by GitHub
parent 20359a870f
commit 7f899c1d07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -76,6 +76,7 @@ impl Mesh {
self.vertices = Default::default(); self.vertices = Default::default();
} }
/// Returns the amount of memory used by the vertices and indices.
pub fn bytes_used(&self) -> usize { pub fn bytes_used(&self) -> usize {
std::mem::size_of::<Self>() std::mem::size_of::<Self>()
+ self.vertices.len() * std::mem::size_of::<Vertex>() + self.vertices.len() * std::mem::size_of::<Vertex>()
@ -107,6 +108,8 @@ impl Mesh {
} }
/// Append all the indices and vertices of `other` to `self`. /// Append all the indices and vertices of `other` to `self`.
///
/// Panics when `other` mesh has a different texture.
pub fn append(&mut self, other: Self) { pub fn append(&mut self, other: Self) {
crate::profile_function!(); crate::profile_function!();
debug_assert!(other.is_valid()); debug_assert!(other.is_valid());
@ -120,6 +123,8 @@ impl Mesh {
/// Append all the indices and vertices of `other` to `self` without /// Append all the indices and vertices of `other` to `self` without
/// taking ownership. /// taking ownership.
///
/// Panics when `other` mesh has a different texture.
pub fn append_ref(&mut self, other: &Self) { pub fn append_ref(&mut self, other: &Self) {
debug_assert!(other.is_valid()); debug_assert!(other.is_valid());
@ -138,6 +143,9 @@ impl Mesh {
self.vertices.extend(other.vertices.iter()); self.vertices.extend(other.vertices.iter());
} }
/// Add a colored vertex.
///
/// Panics when the mesh has assigned a texture.
#[inline(always)] #[inline(always)]
pub fn colored_vertex(&mut self, pos: Pos2, color: Color32) { pub fn colored_vertex(&mut self, pos: Pos2, color: Color32) {
debug_assert!(self.texture_id == TextureId::default()); debug_assert!(self.texture_id == TextureId::default());