From 2b9ba2b957dbfd4f85580d8331fb48f9c381a363 Mon Sep 17 00:00:00 2001 From: Schmarni Date: Sun, 31 Aug 2025 05:34:12 +0200 Subject: [PATCH] fix(lines): make lines no longer crash the server on invalid input from clients Signed-off-by: Schmarni --- src/nodes/drawable/lines.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/nodes/drawable/lines.rs b/src/nodes/drawable/lines.rs index e6a48a2..06348b0 100644 --- a/src/nodes/drawable/lines.rs +++ b/src/nodes/drawable/lines.rs @@ -169,7 +169,8 @@ fn build_line_mesh( (Some(last), Some(next)) => last.lerp(next, 0.5), }; if !quat.is_finite() { - panic!("non finite quat: next: {next:?}, last: {last:?}, curr: {curr:?},"); + error!("non finite quat: next: {next:?}, last: {last:?}, curr: {curr:?},"); + break; } let normals = [ Vec3::X, @@ -182,7 +183,7 @@ fn build_line_mesh( Vec3::new(1., 0., -1.).normalize(), ] .map(Vec3::normalize) - .map(|v| (quat * v)); + .map(|v| quat * v); let points = normals.map(|v| (v * curr.thickness) + Vec3::from(curr.point)); vertex_normals.extend(normals); vertex_positions.extend(points); @@ -207,18 +208,6 @@ fn build_line_mesh( PrimitiveTopology::TriangleList, RenderAssetUsages::RENDER_WORLD, ); - if vertex_colors.iter().flatten().any(|v| !v.is_finite()) { - panic!("vertex colors contains non finite float: {vertex_colors:#?}",); - } - if vertex_normals.iter().any(|v| !v.is_finite()) { - panic!("normals contains non finite dir: {vertex_normals:#?}",); - } - if vertex_normals.iter().any(|v| !v.is_normalized()) { - panic!("normals contains non normalized dir: {vertex_normals:#?}",); - } - if vertex_positions.iter().any(|v| !v.is_finite()) { - panic!("vertex positions contains non finite pos: {vertex_positions:#?}",); - } mesh.insert_indices(Indices::U32(vertex_indices)); mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, vertex_positions.clone()); mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, vertex_normals);