Struct epaint::Mesh

source ·
pub struct Mesh {
    pub indices: Vec<u32>,
    pub vertices: Vec<Vertex>,
    pub texture_id: TextureId,
}
Expand description

Textured triangles in two dimensions.

Fields§

§indices: Vec<u32>

Draw as triangles (i.e. the length is always multiple of three).

If you only support 16-bit indices you can use Mesh::split_to_u16.

egui is NOT consistent with what winding order it uses, so turn off backface culling.

§vertices: Vec<Vertex>

The vertex data indexed by indices.

§texture_id: TextureId

The texture to use when drawing these triangles.

Implementations§

source§

impl Mesh

source

pub fn with_texture(texture_id: TextureId) -> Self

source

pub fn clear(&mut self)

Restore to default state, but without freeing memory.

source

pub fn bytes_used(&self) -> usize

source

pub fn is_valid(&self) -> bool

Are all indices within the bounds of the contained vertices?

source

pub fn is_empty(&self) -> bool

source

pub fn calc_bounds(&self) -> Rect

Calculate a bounding rectangle.

source

pub fn append(&mut self, other: Self)

Append all the indices and vertices of other to self.

source

pub fn append_ref(&mut self, other: &Self)

Append all the indices and vertices of other to self without taking ownership.

source

pub fn colored_vertex(&mut self, pos: Pos2, color: Color32)

source

pub fn add_triangle(&mut self, a: u32, b: u32, c: u32)

Add a triangle.

source

pub fn reserve_triangles(&mut self, additional_triangles: usize)

Make room for this many additional triangles (will reserve 3x as many indices). See also reserve_vertices.

source

pub fn reserve_vertices(&mut self, additional: usize)

Make room for this many additional vertices. See also reserve_triangles.

source

pub fn add_rect_with_uv(&mut self, rect: Rect, uv: Rect, color: Color32)

Rectangle with a texture and color.

source

pub fn add_colored_rect(&mut self, rect: Rect, color: Color32)

Uniformly colored rectangle.

source

pub fn split_to_u16(self) -> Vec<Mesh16>

This is for platforms that only support 16-bit index buffers.

Splits this mesh into many smaller meshes (if needed) where the smaller meshes have 16-bit indices.

source

pub fn translate(&mut self, delta: Vec2)

Translate location by this much, in-place

source

pub fn rotate(&mut self, rot: Rot2, origin: Pos2)

Rotate by some angle about an origin, in-place.

Origin is a position in screen space.

Trait Implementations§

source§

impl Clone for Mesh

source§

fn clone(&self) -> Mesh

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Mesh

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Mesh

source§

fn default() -> Mesh

Returns the “default value” for a type. Read more
source§

impl From<Mesh> for Shape

source§

fn from(mesh: Mesh) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Mesh

source§

fn eq(&self, other: &Mesh) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Mesh

source§

impl StructuralEq for Mesh

source§

impl StructuralPartialEq for Mesh

Auto Trait Implementations§

§

impl RefUnwindSafe for Mesh

§

impl Send for Mesh

§

impl Sync for Mesh

§

impl Unpin for Mesh

§

impl UnwindSafe for Mesh

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.