mesh_graph/ops/
transform.rs1use glam::{Mat4, Quat};
2
3use crate::MeshGraph;
4
5impl MeshGraph {
6 pub fn apply_quat(&mut self, quat: Quat) {
10 for pos in self.positions.values_mut() {
11 *pos = quat * *pos;
12 }
13
14 if let Some(normals) = self.vertex_normals.as_mut() {
15 for normal in normals.values_mut() {
16 *normal = quat * *normal;
17 }
18 }
19 }
20
21 pub fn apply_projection(&mut self, projection: Mat4) {
25 for pos in self.positions.values_mut() {
26 *pos = projection.project_point3(*pos);
27 }
28
29 if self.vertex_normals.is_some() {
30 self.compute_vertex_normals();
31 }
32 }
33
34 pub fn apply_transform(&mut self, transform: Mat4) {
38 for pos in self.positions.values_mut() {
39 *pos = transform.transform_point3(*pos);
40 }
41
42 if let Some(normals) = self.vertex_normals.as_mut() {
43 for normal in normals.values_mut() {
44 *normal = transform.transform_vector3(*normal);
45 }
46 }
47 }
48}