Skip to main content

ChangeSet

Struct ChangeSet 

Source
pub struct ChangeSet {
    pub vertices_added: Vec<VertexId>,
    pub vertices_removed: Vec<VertexId>,
    pub vertices_moved: Vec<VertexId>,
    pub triangles_added: Vec<TriangleId>,
    pub triangles_removed: Vec<TriangleId>,
    pub triangles_changed: Vec<TriangleId>,
    pub channels: Vec<(String, Vec<VertexId>)>,
    pub channels_toggled: Vec<String>,
}
Expand description

What an edit, undo or redo changed. All lists are sorted and free of duplicates.

Fields§

§vertices_added: Vec<VertexId>§vertices_removed: Vec<VertexId>§vertices_moved: Vec<VertexId>

Existing vertices whose position changed. In a set produced by ChangeSet::merge, such a vertex may also have changed values in any channel, so treat it as dirty for all channels.

§triangles_added: Vec<TriangleId>§triangles_removed: Vec<TriangleId>§triangles_changed: Vec<TriangleId>

Existing triangles whose vertex ids changed.

§channels: Vec<(String, Vec<VertexId>)>

Source channels written for existing vertices: (channel name, vertex ids).

§channels_toggled: Vec<String>

Channels that went away or came back whole (a crate::Transaction::drop_channel, its undo or redo), sorted by name: read Mesh::channel for where they stand now. Their values are not listed in ChangeSet::channels.

Implementations§

Source§

impl ChangeSet

Source

pub fn topology_changed(&self) -> bool

True when triangles were added, removed or rewritten.

Source

pub fn is_empty(&self) -> bool

Source

pub fn merge(&mut self, later: &ChangeSet)

Folds later, the change set of an edit (or undo or redo) made after self, into self, so that self describes the net effect of both. Per slot:

  • added, then removed: reported as neither;
  • removed, then added again (slot reuse): reported as moved (vertex) or changed (triangle), because the slot was alive before and is alive after;
  • moved and changed are unions, minus slots that end up added or removed;
  • channel lists are unioned per channel name, minus vertices that end up added or removed. A reused (removed, then added) vertex is added to every channel list named in either input, because its slot got brand-new contents. Names are kept even when their list ends up empty.

A slot that was written and then restored to its original value stays in the moved, changed and channel lists; the lists are supersets of the real differences. All lists stay sorted, duplicate-free and disjoint.

In a merged set, a vertex in vertices_moved may have changed values in any channel (a reused slot may differ in channels no input named), so consumers must treat it as dirty for all channels.

Both sets must satisfy the ChangeSet invariants: every list sorted and duplicate-free, added, removed and moved/changed disjoint, and channel lists free of added and removed vertices. Sets returned by this crate do.

Trait Implementations§

Source§

impl Clone for ChangeSet

Source§

fn clone(&self) -> ChangeSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ChangeSet

Source§

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

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

impl Default for ChangeSet

Source§

fn default() -> ChangeSet

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

impl Eq for ChangeSet

Source§

impl PartialEq for ChangeSet

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ChangeSet

Auto Trait Implementations§

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, dest: *mut u8)

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