Struct truck_polymesh::polygon_mesh::PolygonMeshEditor
source · pub struct PolygonMeshEditor<'a, 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