epaint

Struct 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

Returns the amount of memory used by the vertices and indices.

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.

Panics when other mesh has a different texture.

Source

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

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

Panics when other mesh has a different texture.

Source

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

Add a colored vertex.

Panics when the mesh has assigned a texture.

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 transform(&mut self, transform: TSTransform)

Transform the mesh in-place with the given transform.

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<'de> Deserialize<'de> for Mesh

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Mesh

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Mesh

Source§

impl StructuralPartialEq for Mesh

Auto Trait Implementations§

§

impl Freeze for Mesh

§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,