aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-06-02 16:00:23 +0200
committerCrozet Sébastien <developer@crozet.re>2021-06-02 16:00:23 +0200
commite0e341214c35347a30c3e76265d216396abc2cfb (patch)
tree4582f25275e233036efd5c703fb089340a8b341c
parent7153eb7779a29853289df90f28efaac738620386 (diff)
downloadrapier-e0e341214c35347a30c3e76265d216396abc2cfb.tar.gz
rapier-e0e341214c35347a30c3e76265d216396abc2cfb.tar.bz2
rapier-e0e341214c35347a30c3e76265d216396abc2cfb.zip
Update dependencies
-rw-r--r--Cargo.toml3
-rw-r--r--benchmarks2d/Cargo.toml2
-rw-r--r--benchmarks3d/Cargo.toml2
-rw-r--r--build/rapier2d-f64/Cargo.toml10
-rw-r--r--build/rapier2d/Cargo.toml10
-rw-r--r--build/rapier3d-f64/Cargo.toml10
-rw-r--r--build/rapier3d/Cargo.toml10
-rw-r--r--build/rapier_testbed2d/Cargo.toml11
-rw-r--r--build/rapier_testbed3d/Cargo.toml11
-rw-r--r--examples2d/Cargo.toml2
-rw-r--r--examples3d/Cargo.toml2
-rw-r--r--src_testbed/camera2d.rs (renamed from src_testbed/camera.rs)1
-rw-r--r--src_testbed/camera3d.rs121
-rw-r--r--src_testbed/lib.rs5
-rw-r--r--src_testbed/testbed.rs4
15 files changed, 162 insertions, 42 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 99e7b5b..7021ade 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,9 +18,6 @@ resolver = "2"
#parry3d-f64 = { path = "../parry/build/parry3d-f64" }
#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" }
#nalgebra = { git = "https://github.com/dimforge/nalgebra", branch = "dev" }
#parry2d = { git = "https://github.com/dimforge/parry", branch = "special_cases" }
diff --git a/benchmarks2d/Cargo.toml b/benchmarks2d/Cargo.toml
index fdb1690..92e2959 100644
--- a/benchmarks2d/Cargo.toml
+++ b/benchmarks2d/Cargo.toml
@@ -14,7 +14,7 @@ enhanced-determinism = [ "rapier2d/enhanced-determinism" ]
[dependencies]
rand = "0.8"
Inflector = "0.11"
-nalgebra = "0.26"
+nalgebra = "0.27"
[dependencies.rapier_testbed2d]
path = "../build/rapier_testbed2d"
diff --git a/benchmarks3d/Cargo.toml b/benchmarks3d/Cargo.toml
index a986136..8fca510 100644
--- a/benchmarks3d/Cargo.toml
+++ b/benchmarks3d/Cargo.toml
@@ -14,7 +14,7 @@ enhanced-determinism = [ "rapier3d/enhanced-determinism" ]
[dependencies]
rand = "0.8"
Inflector = "0.11"
-nalgebra = "0.26"
+nalgebra = "0.27"
[dependencies.rapier_testbed3d]
path = "../build/rapier_testbed3d"
diff --git a/build/rapier2d-f64/Cargo.toml b/build/rapier2d-f64/Cargo.toml
index d244d9b..cfa121e 100644
--- a/build/rapier2d-f64/Cargo.toml
+++ b/build/rapier2d-f64/Cargo.toml
@@ -44,13 +44,13 @@ required-features = [ "dim2", "f64" ]
vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ]}
num-traits = "0.2"
-nalgebra = "0.26"
-parry2d-f64 = "0.4"
-simba = "0.4"
-approx = "0.4"
+nalgebra = "0.27"
+parry2d-f64 = "0.5"
+simba = "0.5"
+approx = "0.5"
rayon = { version = "1", optional = true }
crossbeam = "0.8"
-arrayvec = "0.6"
+arrayvec = "0.7"
bit-vec = "0.6"
rustc-hash = "1"
serde = { version = "1", features = [ "derive" ], optional = true }
diff --git a/build/rapier2d/Cargo.toml b/build/rapier2d/Cargo.toml
index a149bd9..79135d4 100644
--- a/build/rapier2d/Cargo.toml
+++ b/build/rapier2d/Cargo.toml
@@ -44,13 +44,13 @@ required-features = [ "dim2", "f32" ]
vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ]}
num-traits = "0.2"
-nalgebra = "0.26"
-parry2d = "0.4"
-simba = "0.4"
-approx = "0.4"
+nalgebra = "0.27"
+parry2d = "0.5"
+simba = "0.5"
+approx = "0.5"
rayon = { version = "1", optional = true }
crossbeam = "0.8"
-arrayvec = "0.6"
+arrayvec = "0.7"
bit-vec = "0.6"
rustc-hash = "1"
serde = { version = "1", features = [ "derive" ], optional = true }
diff --git a/build/rapier3d-f64/Cargo.toml b/build/rapier3d-f64/Cargo.toml
index 4b6519c..cfbc836 100644
--- a/build/rapier3d-f64/Cargo.toml
+++ b/build/rapier3d-f64/Cargo.toml
@@ -44,13 +44,13 @@ required-features = [ "dim3", "f64" ]
vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ]}
num-traits = "0.2"
-nalgebra = "0.26"
-parry3d-f64 = "0.4"
-simba = "0.4"
-approx = "0.4"
+nalgebra = "0.27"
+parry3d-f64 = "0.5"
+simba = "0.5"
+approx = "0.5"
rayon = { version = "1", optional = true }
crossbeam = "0.8"
-arrayvec = "0.6"
+arrayvec = "0.7"
bit-vec = "0.6"
rustc-hash = "1"
serde = { version = "1", features = [ "derive" ], optional = true }
diff --git a/build/rapier3d/Cargo.toml b/build/rapier3d/Cargo.toml
index 8a3877b..1ddb201 100644
--- a/build/rapier3d/Cargo.toml
+++ b/build/rapier3d/Cargo.toml
@@ -44,13 +44,13 @@ required-features = [ "dim3", "f32" ]
vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ]}
num-traits = "0.2"
-nalgebra = "0.26"
-parry3d = "0.4"
-simba = "0.4"
-approx = "0.4"
+nalgebra = "0.27"
+parry3d = "0.5"
+simba = "0.5"
+approx = "0.5"
rayon = { version = "1", optional = true }
crossbeam = "0.8"
-arrayvec = "0.6"
+arrayvec = "0.7"
bit-vec = "0.6"
rustc-hash = "1"
serde = { version = "1", features = [ "derive" ], optional = true }
diff --git a/build/rapier_testbed2d/Cargo.toml b/build/rapier_testbed2d/Cargo.toml
index b501a1f..67fb07b 100644
--- a/build/rapier_testbed2d/Cargo.toml
+++ b/build/rapier_testbed2d/Cargo.toml
@@ -26,23 +26,22 @@ other-backends = [ "wrapped2d", "nphysics2d" ]
[dependencies]
-nalgebra = { version = "0.26", features = [ "rand" ] }
+nalgebra = { version = "0.27", features = [ "rand" ] }
rand = "0.8"
rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]}
bitflags = "1"
num_cpus = { version = "1", optional = true }
wrapped2d = { version = "0.4", optional = true }
-parry2d = "0.4"
-ncollide2d = "0.29"
-nphysics2d = { version = "0.21", optional = true }
+parry2d = "0.5"
+ncollide2d = "0.30"
+nphysics2d = { version = "0.22", optional = true }
crossbeam = "0.8"
bincode = "1"
Inflector = "0.11"
md5 = "0.7"
-bevy_egui = "0.4"
-bevy-orbit-controls = "2"
+bevy_egui = "0.5"
# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
diff --git a/build/rapier_testbed3d/Cargo.toml b/build/rapier_testbed3d/Cargo.toml
index 0038fa8..2dfdad7 100644
--- a/build/rapier_testbed3d/Cargo.toml
+++ b/build/rapier_testbed3d/Cargo.toml
@@ -25,16 +25,16 @@ parallel = [ "rapier3d/parallel", "num_cpus" ]
other-backends = [ "physx", "physx-sys", "glam", "nphysics3d" ]
[dependencies]
-nalgebra = { version = "0.26", features = [ "rand" ] }
+nalgebra = { version = "0.27", features = [ "rand" ] }
rand = "0.8"
rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]}
bitflags = "1"
glam = { version = "0.12", optional = true }
num_cpus = { version = "1", optional = true }
-parry3d = "0.4"
-ncollide3d = "0.29"
-nphysics3d = { version = "0.21", optional = true }
+parry3d = "0.5"
+ncollide3d = "0.30"
+nphysics3d = { version = "0.22", optional = true }
physx = { version = "0.11", optional = true }
physx-sys = { version = "0.4", optional = true }
crossbeam = "0.8"
@@ -43,8 +43,7 @@ md5 = "0.7"
Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] }
-bevy_egui = "0.4"
-bevy-orbit-controls = "2"
+bevy_egui = "0.5"
# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
diff --git a/examples2d/Cargo.toml b/examples2d/Cargo.toml
index b367ff8..6ade796 100644
--- a/examples2d/Cargo.toml
+++ b/examples2d/Cargo.toml
@@ -15,7 +15,7 @@ enhanced-determinism = [ "rapier2d/enhanced-determinism" ]
[dependencies]
rand = "0.8"
Inflector = "0.11"
-nalgebra = "0.26"
+nalgebra = "0.27"
lyon = "0.17"
usvg = "0.13"
diff --git a/examples3d/Cargo.toml b/examples3d/Cargo.toml
index 37c641f..a80f3dc 100644
--- a/examples3d/Cargo.toml
+++ b/examples3d/Cargo.toml
@@ -16,7 +16,7 @@ enhanced-determinism = [ "rapier3d/enhanced-determinism" ]
rand = "0.8"
getrandom = { version = "0.2", features = [ "js" ] }
Inflector = "0.11"
-nalgebra = "0.26"
+nalgebra = "0.27"
wasm-bindgen = "0.2"
obj-rs = { version = "0.6", default-features = false }
diff --git a/src_testbed/camera.rs b/src_testbed/camera2d.rs
index 529e6c7..81b3263 100644
--- a/src_testbed/camera.rs
+++ b/src_testbed/camera2d.rs
@@ -1,5 +1,6 @@
// NOTE: this is inspired from the `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;
diff --git a/src_testbed/camera3d.rs b/src_testbed/camera3d.rs
new file mode 100644
index 0000000..602ef31
--- /dev/null
+++ b/src_testbed/camera3d.rs
@@ -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());
+ }
+}
diff --git a/src_testbed/lib.rs b/src_testbed/lib.rs
index db362cc..c2c6797 100644
--- a/src_testbed/lib.rs
+++ b/src_testbed/lib.rs
@@ -31,7 +31,10 @@ pub use crate::testbed::{Testbed, TestbedApp, TestbedGraphics};
#[cfg(all(feature = "dim2", feature = "other-backends"))]
mod box2d_backend;
-mod camera;
+#[cfg(feature = "dim2")]
+mod camera2d;
+#[cfg(feature = "dim3")]
+mod camera3d;
mod graphics;
pub mod harness;
#[cfg(feature = "other-backends")]
diff --git a/src_testbed/testbed.rs b/src_testbed/testbed.rs
index ba09250..80d809c 100644
--- a/src_testbed/testbed.rs
+++ b/src_testbed/testbed.rs
@@ -32,9 +32,9 @@ use bevy::wgpu::{WgpuFeature, WgpuFeatures, WgpuOptions};
use bevy_egui::EguiContext;
#[cfg(feature = "dim2")]
-use crate::camera::{OrbitCamera, OrbitCameraPlugin};
+use crate::camera2d::{OrbitCamera, OrbitCameraPlugin};
#[cfg(feature = "dim3")]
-use bevy_orbit_controls::{OrbitCamera, OrbitCameraPlugin};
+use crate::camera3d::{OrbitCamera, OrbitCameraPlugin};
const RAPIER_BACKEND: usize = 0;
#[cfg(feature = "other-backends")]