Skip to content

Commit

Permalink
Catch real camera
Browse files Browse the repository at this point in the history
  • Loading branch information
rewin123 committed May 23, 2024
1 parent 2bb6d67 commit d8bb9b1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions crates/editor_ui/src/tools/gizmo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,27 @@ impl EditorTool for GizmoTool {

let (cam_transform, cam_proj) = {
let mut cam_query =
world.query_filtered::<(&GlobalTransform, &Projection), With<EditorCameraMarker>>();
let Ok((ref_tr, ref_cam)) = cam_query.get_single(world) else {
return;
world.query_filtered::<(&GlobalTransform, &Projection, &Camera), With<EditorCameraMarker>>();
let Ok((ref_tr, ref_cam, ref_cam_state)) = cam_query.get_single(world) else {
return; //if we havent editor cameras in world, so its wrong using of space_editor

Check warning on line 163 in crates/editor_ui/src/tools/gizmo.rs

View check run for this annotation

Codecov / codecov/patch

crates/editor_ui/src/tools/gizmo.rs#L161-L163

Added lines #L161 - L163 were not covered by tests
};
(*ref_tr, ref_cam.clone())
if ref_cam_state.is_active {
(*ref_tr, ref_cam.clone()) //we have active editor camera

Check warning on line 166 in crates/editor_ui/src/tools/gizmo.rs

View check run for this annotation

Codecov / codecov/patch

crates/editor_ui/src/tools/gizmo.rs#L165-L166

Added lines #L165 - L166 were not covered by tests
} else { //if we havent, so its game mode and we can try to find active game camera
let mut cam_query =
world.query::<(&GlobalTransform, &Projection, &Camera)>();
let mut ret = None;
for (ref_tr, ref_cam, ref_cam_state) in cam_query.iter(world) {
if ref_cam_state.is_active {
ret = Some((*ref_tr, ref_cam.clone()));
break;
}

Check warning on line 175 in crates/editor_ui/src/tools/gizmo.rs

View check run for this annotation

Codecov / codecov/patch

crates/editor_ui/src/tools/gizmo.rs#L168-L175

Added lines #L168 - L175 were not covered by tests
}
if ret.is_none() {
return;
}
ret.unwrap()

Check warning on line 180 in crates/editor_ui/src/tools/gizmo.rs

View check run for this annotation

Codecov / codecov/patch

crates/editor_ui/src/tools/gizmo.rs#L177-L180

Added lines #L177 - L180 were not covered by tests
}
};

let selected = world
Expand Down

0 comments on commit d8bb9b1

Please sign in to comment.