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§
§impl Mesh
impl Mesh
pub fn with_texture(texture_id: TextureId) -> Mesh
pub fn clear(&mut self)
pub fn clear(&mut self)
Restore to default state, but without freeing memory.
pub fn bytes_used(&self) -> usize
pub fn bytes_used(&self) -> usize
Returns the amount of memory used by the vertices and indices.
pub fn is_empty(&self) -> bool
pub fn calc_bounds(&self) -> Rect
pub fn calc_bounds(&self) -> Rect
Calculate a bounding rectangle.
pub fn append(&mut self, other: Mesh)
pub fn append(&mut self, other: Mesh)
Append all the indices and vertices of other
to self
.
Panics when other
mesh has a different texture.
pub fn append_ref(&mut self, other: &Mesh)
pub fn append_ref(&mut self, other: &Mesh)
Append all the indices and vertices of other
to self
without
taking ownership.
Panics when other
mesh has a different texture.
pub fn colored_vertex(&mut self, pos: Pos2, color: Color32)
pub fn colored_vertex(&mut self, pos: Pos2, color: Color32)
Add a colored vertex.
Panics when the mesh has assigned a texture.
pub fn add_triangle(&mut self, a: u32, b: u32, c: u32)
pub fn add_triangle(&mut self, a: u32, b: u32, c: u32)
Add a triangle.
pub fn reserve_triangles(&mut self, additional_triangles: usize)
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
.
pub fn reserve_vertices(&mut self, additional: usize)
pub fn reserve_vertices(&mut self, additional: usize)
Make room for this many additional vertices.
See also reserve_triangles
.
pub fn add_rect_with_uv(&mut self, rect: Rect, uv: Rect, color: Color32)
pub fn add_rect_with_uv(&mut self, rect: Rect, uv: Rect, color: Color32)
Rectangle with a texture and color.
pub fn add_colored_rect(&mut self, rect: Rect, color: Color32)
pub fn add_colored_rect(&mut self, rect: Rect, color: Color32)
Uniformly colored rectangle.
pub fn split_to_u16(self) -> Vec<Mesh16>
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.
pub fn transform(&mut self, transform: TSTransform)
pub fn transform(&mut self, transform: TSTransform)
Transform the mesh in-place with the given transform.
Trait Implementations§
§impl<'de> Deserialize<'de> for Mesh
impl<'de> Deserialize<'de> for Mesh
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Mesh, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Mesh, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Mesh
impl Serialize for Mesh
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Mesh
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request