pub struct MaterialPainter {
pub layers: Vec<PaintLayer>,
pub active_layer: usize,
pub brush: Brush,
pub presets: Vec<MaterialPreset>,
pub show_layers: bool,
pub show_params: bool,
pub recent_colors: Vec<Vec4>,
/* private fields */
}Expand description
Top-level material painter state.
Fields§
§layers: Vec<PaintLayer>§active_layer: usize§brush: Brush§presets: Vec<MaterialPreset>Preset library — available materials for quick selection.
show_layers: boolWhether to show the layer panel in the UI.
show_params: boolWhether to show the material param panel in the UI.
recent_colors: Vec<Vec4>Custom colour palette (recent colours).
Implementations§
Source§impl MaterialPainter
impl MaterialPainter
pub fn new() -> Self
pub fn add_layer(&mut self, name: impl Into<String>) -> usize
pub fn remove_layer(&mut self, idx: usize)
pub fn move_layer_up(&mut self, idx: usize)
pub fn move_layer_down(&mut self, idx: usize)
pub fn active_layer(&self) -> &PaintLayer
pub fn active_layer_mut(&mut self) -> &mut PaintLayer
Sourcepub fn begin_stroke(&mut self, surface_p: Vec3)
pub fn begin_stroke(&mut self, surface_p: Vec3)
Begin a paint stroke at surface_p (world space on the SDF surface).
Sourcepub fn continue_stroke(&mut self, surface_p: Vec3)
pub fn continue_stroke(&mut self, surface_p: Vec3)
Continue a stroke as the cursor moves.
Sourcepub fn end_stroke(&mut self)
pub fn end_stroke(&mut self)
End the current stroke.
Sourcepub fn erase_at(&mut self, p: Vec3, radius: f32)
pub fn erase_at(&mut self, p: Vec3, radius: f32)
Erase all patches on the active layer within radius of p.
Sourcepub fn classify(&self, p: Vec3) -> Option<(MaterialTag, &MaterialParams)>
pub fn classify(&self, p: Vec3) -> Option<(MaterialTag, &MaterialParams)>
Return the best material tag and params for a world-space point. Layers are composited in order (last visible layer covering the point wins).
Sourcepub fn classify_or_default(&self, p: Vec3) -> (MaterialTag, MaterialParams)
pub fn classify_or_default(&self, p: Vec3) -> (MaterialTag, MaterialParams)
Return the default material if no patch covers p.
pub fn undo(&mut self)
pub fn redo(&mut self)
pub fn save_preset(&mut self, name: impl Into<String>)
pub fn apply_preset(&mut self, idx: usize)
pub fn total_patches(&self) -> usize
pub fn status_line(&self) -> String
Trait Implementations§
Source§impl Debug for MaterialPainter
impl Debug for MaterialPainter
Auto Trait Implementations§
impl Freeze for MaterialPainter
impl RefUnwindSafe for MaterialPainter
impl Send for MaterialPainter
impl Sync for MaterialPainter
impl Unpin for MaterialPainter
impl UnsafeUnpin for MaterialPainter
impl UnwindSafe for MaterialPainter
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.