Fix gizmo depth sorting (#46)

Small patch for the `GizmoMaterial` that fixes depth sorting for
non-translucent elements by setting their blend mode to
`AlphaMode::Opaque`
This commit is contained in:
Danny McGee
2024-02-19 19:15:06 -05:00
committed by GitHub
parent c4c778cde9
commit f1d6461393
3 changed files with 17 additions and 7 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ impl From<Color> for GizmoMaterial {
fn from(color: Color) -> Self {
GizmoMaterial {
color,
blend_mode: AlphaMode::Blend,
blend_mode: AlphaMode::Opaque,
}
}
}
+5 -1
View File
@@ -102,9 +102,13 @@ pub(super) fn init_resources(
let rotate_x = ra_mats.add(design_system::Color::RED.into());
let rotate_y = ra_mats.add(design_system::Color::GREEN.into());
let rotate_z = ra_mats.add(design_system::Color::BLUE.into());
let rotate_trackball = ra_mats.add(Color::WHITE.with_a(0.0).into());
let rotate_ss = ra_mats.add(Color::WHITE.into());
let rotate_trackball = ra_mats.add(GizmoMaterial {
color: Color::WHITE.with_a(0.0),
blend_mode: AlphaMode::Blend,
});
cmd.insert_resource(GizmoMats {
translate_x,
translate_y,
+11 -5
View File
@@ -239,11 +239,17 @@ pub(super) fn on_rotate(
q_widget: Query<&RotationWidget>,
) {
// Components from the gizmo root (the entity being transformed)
let (mut xform, parent, init_xform, init_point, mut last_point, mut last_rotation) =
q_root.single_mut();
let gizmo_xform = q_gizmo.single();
let (cam, cam_xform) = q_camera.single();
let Ok((mut xform, parent, init_xform, init_point, mut last_point, mut last_rotation)) =
q_root.get_single_mut()
else {
return;
};
let Ok(gizmo_xform) = q_gizmo.get_single() else {
return;
};
let Ok((cam, cam_xform)) = q_camera.get_single() else {
return;
};
// `Transform::rotate_axis` takes an axis vector relative to the transform's
// _parent_. We'll use the gizmo root's parent's global transform (if it