better solution for thruster particle crash
This commit is contained in:
parent
b5105ff4c5
commit
4d19495ab5
29
src/actor.rs
29
src/actor.rs
|
@ -696,7 +696,16 @@ fn handle_wants_maxvelocity(
|
|||
}
|
||||
|
||||
fn handle_wants_lookat(
|
||||
mut query: Query<(&Position, &mut Rotation, &WantsToLookAt), Without<Camera>>,
|
||||
mut query: Query<
|
||||
(
|
||||
&Position,
|
||||
&mut Rotation,
|
||||
&Transform,
|
||||
&WantsToLookAt,
|
||||
Option<&visual::IsEffect>,
|
||||
),
|
||||
Without<Camera>,
|
||||
>,
|
||||
q_playercam: Query<&Position, With<PlayerCamera>>,
|
||||
q_cam: Query<&Transform, With<Camera>>,
|
||||
id2pos: Res<game::Id2Pos>,
|
||||
|
@ -713,7 +722,7 @@ fn handle_wants_lookat(
|
|||
};
|
||||
|
||||
// TODO: use ExternalTorque rather than hard-resetting the rotation
|
||||
for (pos, mut rot, target_id) in &mut query {
|
||||
for (pos, mut rot, trans, target_id, is_effect) in &mut query {
|
||||
let target_pos: DVec3 = if target_id.0 == cmd::ID_SPECIAL_PLAYERCAM {
|
||||
cam_pos
|
||||
} else if let Some(target_pos) = id2pos.0.get(&target_id.0) {
|
||||
|
@ -721,12 +730,16 @@ fn handle_wants_lookat(
|
|||
} else {
|
||||
continue;
|
||||
};
|
||||
//let up = if trans.translation.length_squared() > 1e-6 {
|
||||
// trans.up()
|
||||
//} else {
|
||||
// Dir3::Y
|
||||
//};
|
||||
let up = Dir3::Y; // TODO: the above code seems to be buggy, this is a workaround
|
||||
let up = if is_effect.is_some() {
|
||||
// trans.up() sometimes crashes with thruster particle effects
|
||||
Dir3::Y
|
||||
} else {
|
||||
if trans.translation.length_squared() > 1e-6 {
|
||||
trans.up()
|
||||
} else {
|
||||
Dir3::Y
|
||||
}
|
||||
};
|
||||
rot.0 = look_at_quat(**pos, target_pos, up.as_dvec3());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue