Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe

## Unreleased

### Changed

- Removed `OglePancamSettings.drag_speed`, since mouse drag now mirrors the device projection drag.

## 0.5.0

### Changed
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ impl Default for OgleSettings {

#[derive(Debug, Clone, PartialEq)]
pub struct OglePancamSettings {
/// Speed for mouse drag movement
pub drag_speed: f32,
/// Speed for keyboard movement
pub keyboard_speed: f32,
/// Mouse buttons for dragging the pancam
Expand All @@ -112,7 +110,6 @@ impl Default for OglePancamSettings {
const LEFT_KEYS: [KeyCode; 2] = [KeyCode::ArrowLeft, KeyCode::KeyA];
const RIGHT_KEYS: [KeyCode; 2] = [KeyCode::ArrowRight, KeyCode::KeyD];
Self {
drag_speed: 10.0,
keyboard_speed: 1000.0,
grab_buttons: GRAB_BUTTONS.to_vec(),
up_keys: UP_KEYS.to_vec(),
Expand Down
10 changes: 7 additions & 3 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub fn do_pancam_movement(
continue;
};
let proj_area_size = projection.area.size();
let viewport_size = camera.logical_viewport_size().unwrap_or(window_size);

let mouse_delta = if !ogle_cam
.settings
Expand All @@ -109,9 +110,7 @@ pub fn do_pancam_movement(
{
Vec2::ZERO
} else {
let viewport_size = camera.logical_viewport_size().unwrap_or(window_size);
ogle_cam.settings.pancam.drag_speed * delta_device_pixels * proj_area_size
/ viewport_size
delta_device_pixels * proj_area_size * projection.scale / viewport_size
};

// Keyboard delta
Expand Down Expand Up @@ -217,6 +216,11 @@ pub fn commit_camera_changes(
};
// Apply final transform update
cam.rig.update(time.delta_secs());
if cam.mode == OgleMode::Pancam {
let driver_pos = cam.rig.driver::<Position>().position;
cam.rig.final_transform.position.x = driver_pos.x;
cam.rig.final_transform.position.y = driver_pos.y;
}
camera_transform.translation = Vec3::new(
cam.rig.final_transform.position.x,
cam.rig.final_transform.position.y,
Expand Down
Loading