pub struct MaterialDescriptor { /* private fields */ }
Expand description
A descriptor for a future Material
.
A MaterialDescriptor
is used to construct a Material
.
A Descriptor
is a smiliar idea as a Builder
,
but there is an important difference between which has to be adressed with a differen name.
A Builder
would always construct a new instance of a struct, in this project meaning it cannot be used twice in the same KinematicTree
.
Since using a Builder
twice would result in two exactly the same objects.
A Descriptor
on the other hand, first checks if there already exists an instance which matches it description, in this case a Material
.
If not the case a new instance (Material
) is constructed and added to the index.
If an instance already exists, which exactly matches the description, then the ‘new’ Material
will refer to the pre-existing data.
This is desirable in the case of Materials, since they are often reused.
This could also allow for changing a Material
and the other used of it changing withit.
OLD STUFF TODO: UPDATE
When a MaterialDescriptor
is constructed for a specific KinematicDataTee
, the following steps happen:
- Check if the description of the
MaterialDescriptor
matches a pre-existingMaterial
already in the tree.- If the a
Material
matches the description, the reference to that material is returned. - If no
Material
matches the desctiption, a newMaterial
is constructed and inserted to thematerial_index
of theKinematicDataTree
and the reference is returned. - If only the
name
of theMaterial
matches, an error is raised.
- If the a
Implementations§
source§impl MaterialDescriptor
impl MaterialDescriptor
sourcepub fn new_color(red: f32, green: f32, blue: f32, alpha: f32) -> Self
pub fn new_color(red: f32, green: f32, blue: f32, alpha: f32) -> Self
Creates a new MaterialDescriptor
with a solid color (rgba)
The red
, green
, blue
and alpha
fields expect a value between 0 and 1.
Example
MaterialDescriptor::new_color(1., 0.4, 0.6, 0.5)
sourcepub fn new_rgb(red: f32, green: f32, blue: f32) -> Self
pub fn new_rgb(red: f32, green: f32, blue: f32) -> Self
Creates a new MaterialDescriptor
with a solid color (rgb)
The red
, green
, blue
fields expect a value between 0 and 1.
Example
MaterialDescriptor::new_rgb(1., 0.4, 0.6)
sourcepub fn new_texture(texture_path: impl Into<String>) -> Self
pub fn new_texture(texture_path: impl Into<String>) -> Self
Creates a new MaterialDescriptor
with a texture.
texture_path
should be a valid package path (e.g. "package://NAME_OF_PACKAGE/path/{texture}"
). You are on your own here.
Example
MaterialDescriptor::new_texture("package://robot_description/textures/example_texture.png")
sourcepub fn named(self, name: impl Into<String>) -> Self
pub fn named(self, name: impl Into<String>) -> Self
Adds a name
to the MaterialDescriptor
, so it can later be used as a referenced Material
Important
When a named Material
is used, it needs to be the same as all materials with the same name.
Otherwise, problems will arise later down the line.
Example
MaterialDescriptor::new_rgb(0.5, 1., 0.5).named("soft-green")
source§impl MaterialDescriptor
impl MaterialDescriptor
Non-builder methods
sourcepub fn name(&self) -> Option<&String>
pub fn name(&self) -> Option<&String>
Gets the optional of the MaterialDescriptor
as a optional reference.
sourcepub fn data(&self) -> &MaterialData
pub fn data(&self) -> &MaterialData
Gets a reference to the MaterialData
of the MaterialDescriptor
Trait Implementations§
source§impl Clone for MaterialDescriptor
impl Clone for MaterialDescriptor
source§fn clone(&self) -> MaterialDescriptor
fn clone(&self) -> MaterialDescriptor
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MaterialDescriptor
impl Debug for MaterialDescriptor
source§impl GroupIDChanger for MaterialDescriptor
impl GroupIDChanger for MaterialDescriptor
source§unsafe fn change_group_id_unchecked(&mut self, new_group_id: &str)
unsafe fn change_group_id_unchecked(&mut self, new_group_id: &str)
source§fn apply_group_id(&mut self)
fn apply_group_id(&mut self)
GroupID
delimiter replacements. Read moresource§fn change_group_id(
&mut self,
new_group_id: impl GroupID
) -> Result<(), GroupIDError>
fn change_group_id( &mut self, new_group_id: impl GroupID ) -> Result<(), GroupIDError>
source§impl PartialEq<MaterialDescriptor> for MaterialDescriptor
impl PartialEq<MaterialDescriptor> for MaterialDescriptor
source§fn eq(&self, other: &MaterialDescriptor) -> bool
fn eq(&self, other: &MaterialDescriptor) -> bool
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for MaterialDescriptor
Auto Trait Implementations§
impl RefUnwindSafe for MaterialDescriptor
impl Send for MaterialDescriptor
impl Sync for MaterialDescriptor
impl Unpin for MaterialDescriptor
impl UnwindSafe for MaterialDescriptor
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.