Merge pull request #2010 from Domanffe/perf/skip-lookup-once

🤖 Agent: contrib-gate-17 verified this head (26.3 sources, integration tree build, clippy, tests, parity; details in the PR comment). Thanks @Domanffe!
This commit is contained in:
Ludovic Marie
2026-10-26 14:13:29 +01:00
committed by GitHub
+19 -15
View File
@@ -951,21 +951,25 @@ fn draw_normals(
return; return;
} }
let normals = normals.part(p); let normals = normals.part(p);
for poly in part.polygons.iter().filter(|_| !poses.skips(part)) { // `skips` is a name lookup: ask once per part, not once per polygon. A part
let normal = poly.vertex_normal(normals); // hidden this way still draws its children, so only the polygons are gated.
for v in poly.vertices { if !poses.skips(part) {
let pos = m.transform_point3(glam::Vec3::new(v[0], v[1], v[2]) / 16.0); for poly in &part.polygons {
out.push(Vertex { let normal = poly.vertex_normal(normals);
normal, for v in poly.vertices {
pos: pos.to_array(), let pos = m.transform_point3(glam::Vec3::new(v[0], v[1], v[2]) / 16.0);
uv: [ out.push(Vertex {
uv[0] + (uv[2] - uv[0]) * v[3], normal,
uv[1] + (uv[3] - uv[1]) * v[4], pos: pos.to_array(),
], uv: [
layer: overlay, uv[0] + (uv[2] - uv[0]) * v[3],
color, uv[1] + (uv[3] - uv[1]) * v[4],
light, ],
}); layer: overlay,
color,
light,
});
}
} }
} }
for c in &part.children { for c in &part.children {