pub struct PolygonMeshEditor<'a, V, A>where
    V: Copy + Debug,
    A: Attributes<V>,
{ pub attributes: &'a mut A, pub faces: &'a mut Faces<V>, /* private fields */ }
Expand description

Editor of polygon mesh

It has mutable references to all member variables of the polygon mesh as public variables, allowing for any destructive changes for optimization. At drop time, the indices of each vertex are judged to be within the range of the array of attributes, and a panic occurs if there is one outside the range (boundary check).

Examples

use truck_polymesh::*;

let positions = vec![
    Point3::new(1.0, 0.0, 0.0),
    Point3::new(0.0, 1.0, 0.0),
    Point3::new(0.0, 0.0, 1.0),
];
let faces = Faces::from_iter(&[[0, 1, 2]]);
let mut mesh = PolygonMesh::new(
    StandardAttributes {
        positions,
        ..Default::default()
    },
    faces,
);

// create editor
let editor = mesh.editor();

// destructive changes
editor.attributes.uv_coords.push(Vector2::new(0.0, 0.0));
editor.faces.tri_faces_mut()[0][0].uv = Some(0);
use truck_polymesh::*;

let positions = vec![
    Point3::new(1.0, 0.0, 0.0),
    Point3::new(0.0, 1.0, 0.0),
    Point3::new(0.0, 0.0, 1.0),
];
let faces = Faces::from_iter(&[[0, 1, 2]]);
let mut mesh = PolygonMesh::new(
    StandardAttributes {
        positions,
        ..Default::default()    
    },
    faces,
);

// create editor
let editor = mesh.editor();

// destructive changes
editor.faces.tri_faces_mut()[0][0].uv = Some(0);

// Panic occurs since no uv coord is added.

Fields§

§attributes: &'a mut A

attributions

§faces: &'a mut Faces<V>

mutable reference to the faces of the polygon mesh

Implementations§

Drops with boundary check and returns Result.

Trait Implementations§

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.