From cdc1dcec369dcd0d689ac07fe511858a2ec69a36 Mon Sep 17 00:00:00 2001 From: yuni Date: Mon, 16 Sep 2024 04:07:36 +0200 Subject: [PATCH] fix crash in handle_wants_lookat/trans.up() when trans.translation is 0 --- src/actor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/actor.rs b/src/actor.rs index 81fb8d2..4c769bf 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -624,7 +624,12 @@ fn handle_wants_lookat( } else { continue; }; - rot.0 = look_at_quat(**pos, target_pos, trans.up().as_dvec3()); + let up = if trans.translation.length_squared() > 1e-6 { + trans.up() + } else { + Dir3::Y + }; + rot.0 = look_at_quat(**pos, target_pos, up.as_dvec3()); } }