Expand description
Vertex access and deformation for EditableMesh: the building blocks for procedural
animation, destruction, terrain tools and “squash and stretch” effects from scripts.
Every method works in the mesh’s local space (before the object’s transform), marks the
mesh as changed so the GPU copy is refreshed, and keeps the normals as they are. Call
EditableMesh::recalculate_normals after a deformation when lighting matters.
use kvas_engine::{mesh::MeshData, mesh_edit::EditableMesh};
use glam::Vec3;
let mut mesh = EditableMesh::from_mesh(&MeshData::primitive("cube").unwrap()).unwrap();
let (min, max) = mesh.bounds();
mesh.twist(Vec3::Y, 45.0); // 45 degrees per metre along Y
mesh.wave(Vec3::X, Vec3::Y, 0.1, 1.0, 0.0);
mesh.recalculate_normals().unwrap();
assert!(mesh.bounds() != (min, max), "the shape changed");