Update dependencies

This commit is contained in:
Crozet Sébastien
2021-06-02 16:00:23 +02:00
parent 7153eb7779
commit e0e341214c
15 changed files with 162 additions and 42 deletions

View File

@@ -18,9 +18,6 @@ resolver = "2"
#parry3d-f64 = { path = "../parry/build/parry3d-f64" } #parry3d-f64 = { path = "../parry/build/parry3d-f64" }
#nalgebra = { path = "../nalgebra" } #nalgebra = { path = "../nalgebra" }
#bevy-orbit-controls = { path = "../bevy-orbit-controls" }
bevy-orbit-controls = { git = "https://github.com/sebcrozet/bevy-orbit-controls" }
#kiss3d = { git = "https://github.com/sebcrozet/kiss3d" } #kiss3d = { git = "https://github.com/sebcrozet/kiss3d" }
#nalgebra = { git = "https://github.com/dimforge/nalgebra", branch = "dev" } #nalgebra = { git = "https://github.com/dimforge/nalgebra", branch = "dev" }
#parry2d = { git = "https://github.com/dimforge/parry", branch = "special_cases" } #parry2d = { git = "https://github.com/dimforge/parry", branch = "special_cases" }

View File

@@ -14,7 +14,7 @@ enhanced-determinism = [ "rapier2d/enhanced-determinism" ]
[dependencies] [dependencies]
rand = "0.8" rand = "0.8"
Inflector = "0.11" Inflector = "0.11"
nalgebra = "0.26" nalgebra = "0.27"
[dependencies.rapier_testbed2d] [dependencies.rapier_testbed2d]
path = "../build/rapier_testbed2d" path = "../build/rapier_testbed2d"

View File

@@ -14,7 +14,7 @@ enhanced-determinism = [ "rapier3d/enhanced-determinism" ]
[dependencies] [dependencies]
rand = "0.8" rand = "0.8"
Inflector = "0.11" Inflector = "0.11"
nalgebra = "0.26" nalgebra = "0.27"
[dependencies.rapier_testbed3d] [dependencies.rapier_testbed3d]
path = "../build/rapier_testbed3d" path = "../build/rapier_testbed3d"

View File

@@ -44,13 +44,13 @@ required-features = [ "dim2", "f64" ]
vec_map = { version = "0.8", optional = true } vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ]} instant = { version = "0.1", features = [ "now" ]}
num-traits = "0.2" num-traits = "0.2"
nalgebra = "0.26" nalgebra = "0.27"
parry2d-f64 = "0.4" parry2d-f64 = "0.5"
simba = "0.4" simba = "0.5"
approx = "0.4" approx = "0.5"
rayon = { version = "1", optional = true } rayon = { version = "1", optional = true }
crossbeam = "0.8" crossbeam = "0.8"
arrayvec = "0.6" arrayvec = "0.7"
bit-vec = "0.6" bit-vec = "0.6"
rustc-hash = "1" rustc-hash = "1"
serde = { version = "1", features = [ "derive" ], optional = true } serde = { version = "1", features = [ "derive" ], optional = true }

View File

@@ -44,13 +44,13 @@ required-features = [ "dim2", "f32" ]
vec_map = { version = "0.8", optional = true } vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ]} instant = { version = "0.1", features = [ "now" ]}
num-traits = "0.2" num-traits = "0.2"
nalgebra = "0.26" nalgebra = "0.27"
parry2d = "0.4" parry2d = "0.5"
simba = "0.4" simba = "0.5"
approx = "0.4" approx = "0.5"
rayon = { version = "1", optional = true } rayon = { version = "1", optional = true }
crossbeam = "0.8" crossbeam = "0.8"
arrayvec = "0.6" arrayvec = "0.7"
bit-vec = "0.6" bit-vec = "0.6"
rustc-hash = "1" rustc-hash = "1"
serde = { version = "1", features = [ "derive" ], optional = true } serde = { version = "1", features = [ "derive" ], optional = true }

View File

@@ -44,13 +44,13 @@ required-features = [ "dim3", "f64" ]
vec_map = { version = "0.8", optional = true } vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ]} instant = { version = "0.1", features = [ "now" ]}
num-traits = "0.2" num-traits = "0.2"
nalgebra = "0.26" nalgebra = "0.27"
parry3d-f64 = "0.4" parry3d-f64 = "0.5"
simba = "0.4" simba = "0.5"
approx = "0.4" approx = "0.5"
rayon = { version = "1", optional = true } rayon = { version = "1", optional = true }
crossbeam = "0.8" crossbeam = "0.8"
arrayvec = "0.6" arrayvec = "0.7"
bit-vec = "0.6" bit-vec = "0.6"
rustc-hash = "1" rustc-hash = "1"
serde = { version = "1", features = [ "derive" ], optional = true } serde = { version = "1", features = [ "derive" ], optional = true }

View File

@@ -44,13 +44,13 @@ required-features = [ "dim3", "f32" ]
vec_map = { version = "0.8", optional = true } vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ]} instant = { version = "0.1", features = [ "now" ]}
num-traits = "0.2" num-traits = "0.2"
nalgebra = "0.26" nalgebra = "0.27"
parry3d = "0.4" parry3d = "0.5"
simba = "0.4" simba = "0.5"
approx = "0.4" approx = "0.5"
rayon = { version = "1", optional = true } rayon = { version = "1", optional = true }
crossbeam = "0.8" crossbeam = "0.8"
arrayvec = "0.6" arrayvec = "0.7"
bit-vec = "0.6" bit-vec = "0.6"
rustc-hash = "1" rustc-hash = "1"
serde = { version = "1", features = [ "derive" ], optional = true } serde = { version = "1", features = [ "derive" ], optional = true }

View File

@@ -26,23 +26,22 @@ other-backends = [ "wrapped2d", "nphysics2d" ]
[dependencies] [dependencies]
nalgebra = { version = "0.26", features = [ "rand" ] } nalgebra = { version = "0.27", features = [ "rand" ] }
rand = "0.8" rand = "0.8"
rand_pcg = "0.3" rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]} instant = { version = "0.1", features = [ "web-sys", "now" ]}
bitflags = "1" bitflags = "1"
num_cpus = { version = "1", optional = true } num_cpus = { version = "1", optional = true }
wrapped2d = { version = "0.4", optional = true } wrapped2d = { version = "0.4", optional = true }
parry2d = "0.4" parry2d = "0.5"
ncollide2d = "0.29" ncollide2d = "0.30"
nphysics2d = { version = "0.21", optional = true } nphysics2d = { version = "0.22", optional = true }
crossbeam = "0.8" crossbeam = "0.8"
bincode = "1" bincode = "1"
Inflector = "0.11" Inflector = "0.11"
md5 = "0.7" md5 = "0.7"
bevy_egui = "0.4" bevy_egui = "0.5"
bevy-orbit-controls = "2"
# Dependencies for native only. # Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]

View File

@@ -25,16 +25,16 @@ parallel = [ "rapier3d/parallel", "num_cpus" ]
other-backends = [ "physx", "physx-sys", "glam", "nphysics3d" ] other-backends = [ "physx", "physx-sys", "glam", "nphysics3d" ]
[dependencies] [dependencies]
nalgebra = { version = "0.26", features = [ "rand" ] } nalgebra = { version = "0.27", features = [ "rand" ] }
rand = "0.8" rand = "0.8"
rand_pcg = "0.3" rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]} instant = { version = "0.1", features = [ "web-sys", "now" ]}
bitflags = "1" bitflags = "1"
glam = { version = "0.12", optional = true } glam = { version = "0.12", optional = true }
num_cpus = { version = "1", optional = true } num_cpus = { version = "1", optional = true }
parry3d = "0.4" parry3d = "0.5"
ncollide3d = "0.29" ncollide3d = "0.30"
nphysics3d = { version = "0.21", optional = true } nphysics3d = { version = "0.22", optional = true }
physx = { version = "0.11", optional = true } physx = { version = "0.11", optional = true }
physx-sys = { version = "0.4", optional = true } physx-sys = { version = "0.4", optional = true }
crossbeam = "0.8" crossbeam = "0.8"
@@ -43,8 +43,7 @@ md5 = "0.7"
Inflector = "0.11" Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] } serde = { version = "1", features = [ "derive" ] }
bevy_egui = "0.4" bevy_egui = "0.5"
bevy-orbit-controls = "2"
# Dependencies for native only. # Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]

View File

@@ -15,7 +15,7 @@ enhanced-determinism = [ "rapier2d/enhanced-determinism" ]
[dependencies] [dependencies]
rand = "0.8" rand = "0.8"
Inflector = "0.11" Inflector = "0.11"
nalgebra = "0.26" nalgebra = "0.27"
lyon = "0.17" lyon = "0.17"
usvg = "0.13" usvg = "0.13"

View File

@@ -16,7 +16,7 @@ enhanced-determinism = [ "rapier3d/enhanced-determinism" ]
rand = "0.8" rand = "0.8"
getrandom = { version = "0.2", features = [ "js" ] } getrandom = { version = "0.2", features = [ "js" ] }
Inflector = "0.11" Inflector = "0.11"
nalgebra = "0.26" nalgebra = "0.27"
wasm-bindgen = "0.2" wasm-bindgen = "0.2"
obj-rs = { version = "0.6", default-features = false } obj-rs = { version = "0.6", default-features = false }

View File

@@ -1,5 +1,6 @@
// NOTE: this is inspired from the `bevy-orbit-controls` projects but // NOTE: this is inspired from the `bevy-orbit-controls` projects but
// with some modifications like Panning, and 2D support. // with some modifications like Panning, and 2D support.
// Most of these modifications have been contributed upstream.
use bevy::input::mouse::MouseMotion; use bevy::input::mouse::MouseMotion;
use bevy::input::mouse::MouseScrollUnit::{Line, Pixel}; use bevy::input::mouse::MouseScrollUnit::{Line, Pixel};
use bevy::input::mouse::MouseWheel; use bevy::input::mouse::MouseWheel;

121
src_testbed/camera3d.rs Normal file
View File

@@ -0,0 +1,121 @@
// NOTE: this is mostly taken from the `iMplode-nZ/bevy-orbit-controls` projects but
// with some modifications like Panning, and 2D support.
// Most of these modifications have been contributed upstream.
use bevy::input::mouse::MouseMotion;
use bevy::input::mouse::MouseScrollUnit::{Line, Pixel};
use bevy::input::mouse::MouseWheel;
use bevy::prelude::*;
use bevy::render::camera::Camera;
use std::ops::RangeInclusive;
const LINE_TO_PIXEL_RATIO: f32 = 0.1;
pub struct OrbitCamera {
pub x: f32,
pub y: f32,
pub pitch_range: RangeInclusive<f32>,
pub distance: f32,
pub center: Vec3,
pub rotate_sensitivity: f32,
pub pan_sensitivity: f32,
pub zoom_sensitivity: f32,
pub rotate_button: MouseButton,
pub pan_button: MouseButton,
pub enabled: bool,
}
impl Default for OrbitCamera {
fn default() -> Self {
OrbitCamera {
x: 0.0,
y: std::f32::consts::FRAC_PI_2,
pitch_range: 0.01..=3.13,
distance: 5.0,
center: Vec3::ZERO,
rotate_sensitivity: 1.0,
pan_sensitivity: 1.0,
zoom_sensitivity: 0.8,
rotate_button: MouseButton::Left,
pan_button: MouseButton::Right,
enabled: true,
}
}
}
pub struct OrbitCameraPlugin;
impl OrbitCameraPlugin {
fn update_transform_system(
mut query: Query<(&OrbitCamera, &mut Transform), (Changed<OrbitCamera>, With<Camera>)>,
) {
for (camera, mut transform) in query.iter_mut() {
if camera.enabled {
let rot = Quat::from_axis_angle(Vec3::Y, camera.x)
* Quat::from_axis_angle(-Vec3::X, camera.y);
transform.translation = (rot * Vec3::Y) * camera.distance + camera.center;
transform.look_at(camera.center, Vec3::Y);
}
}
}
fn mouse_motion_system(
time: Res<Time>,
mut mouse_motion_events: EventReader<MouseMotion>,
mouse_button_input: Res<Input<MouseButton>>,
mut query: Query<(&mut OrbitCamera, &mut Transform, &mut Camera)>,
) {
let mut delta = Vec2::ZERO;
for event in mouse_motion_events.iter() {
delta += event.delta;
}
for (mut camera, transform, _) in query.iter_mut() {
if !camera.enabled {
continue;
}
if mouse_button_input.pressed(camera.rotate_button) {
camera.x -= delta.x * camera.rotate_sensitivity * time.delta_seconds();
camera.y -= delta.y * camera.rotate_sensitivity * time.delta_seconds();
camera.y = camera
.y
.max(*camera.pitch_range.start())
.min(*camera.pitch_range.end());
}
if mouse_button_input.pressed(camera.pan_button) {
let right_dir = transform.rotation * -Vec3::X;
let up_dir = transform.rotation * Vec3::Y;
let pan_vector = (delta.x * right_dir + delta.y * up_dir)
* camera.pan_sensitivity
* time.delta_seconds();
camera.center += pan_vector;
}
}
}
fn zoom_system(
mut mouse_wheel_events: EventReader<MouseWheel>,
mut query: Query<&mut OrbitCamera, With<Camera>>,
) {
let mut total = 0.0;
for event in mouse_wheel_events.iter() {
total += event.y
* match event.unit {
Line => 1.0,
Pixel => LINE_TO_PIXEL_RATIO,
};
}
for mut camera in query.iter_mut() {
if camera.enabled {
camera.distance *= camera.zoom_sensitivity.powf(total);
}
}
}
}
impl Plugin for OrbitCameraPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_system(Self::mouse_motion_system.system())
.add_system(Self::zoom_system.system())
.add_system(Self::update_transform_system.system());
}
}

View File

@@ -31,7 +31,10 @@ pub use crate::testbed::{Testbed, TestbedApp, TestbedGraphics};
#[cfg(all(feature = "dim2", feature = "other-backends"))] #[cfg(all(feature = "dim2", feature = "other-backends"))]
mod box2d_backend; mod box2d_backend;
mod camera; #[cfg(feature = "dim2")]
mod camera2d;
#[cfg(feature = "dim3")]
mod camera3d;
mod graphics; mod graphics;
pub mod harness; pub mod harness;
#[cfg(feature = "other-backends")] #[cfg(feature = "other-backends")]

View File

@@ -32,9 +32,9 @@ use bevy::wgpu::{WgpuFeature, WgpuFeatures, WgpuOptions};
use bevy_egui::EguiContext; use bevy_egui::EguiContext;
#[cfg(feature = "dim2")] #[cfg(feature = "dim2")]
use crate::camera::{OrbitCamera, OrbitCameraPlugin}; use crate::camera2d::{OrbitCamera, OrbitCameraPlugin};
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]
use bevy_orbit_controls::{OrbitCamera, OrbitCameraPlugin}; use crate::camera3d::{OrbitCamera, OrbitCameraPlugin};
const RAPIER_BACKEND: usize = 0; const RAPIER_BACKEND: usize = 0;
#[cfg(feature = "other-backends")] #[cfg(feature = "other-backends")]