Skip to content

Commit

Permalink
Can run with latest amethyst. Currently needs old Rand
Browse files Browse the repository at this point in the history
  • Loading branch information
trsoluti committed Feb 14, 2019
1 parent 47bb004 commit 8b4fdc2
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 48 deletions.
15 changes: 15 additions & 0 deletions .idea/amethyst-rhusics.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "amethyst-rhusics"
version = "0.3.1"
version = "0.3.2"
authors = ["Simon Rönnberg <[email protected]>"]
edition = "2018"

repository = "https://github.com/amethyst/amethyst-rhusics.git"
homepage = "https://github.com/amethyst/amethyst-rhusics.git"
Expand All @@ -14,16 +15,18 @@ description = "Integration of `amethyst` and `rhusics`"
keywords = ["gamedev", "amethyst", "physics"]

[dependencies]
amethyst_core = { version = "0.4", git = "https://github.com/amethyst/amethyst" }
amethyst_renderer = { version = "0.9", git = "https://github.com/amethyst/amethyst" }
rhusics-ecs = { version = "0.7", features = ["serde"] }
rhusics-core = { version = "0.7", features = ["specs", "serde"] }
shrev = "1.0"
amethyst_error = { git = "https://github.com/amethyst/amethyst"}
amethyst_core = { git = "https://github.com/amethyst/amethyst"}
amethyst_renderer = { git = "https://github.com/amethyst/amethyst"}
rhusics-ecs = { version = "*", features = ["serde"] }
rhusics-core = { version = "*", features = ["specs", "serde"] }
shrev = "*"
collision = { version = "0.18", features = ["serde"]}
nalgebra = "*"
cgmath = "0.16.1"

[dev-dependencies]
amethyst = { version = "0.9", git = "https://github.com/amethyst/amethyst" }
amethyst = { git = "https://github.com/amethyst/amethyst" }
genmesh = "0.5"
rand = "0.3"
shred = "0.7"
Expand Down
5 changes: 3 additions & 2 deletions examples/boxes/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::fmt::Debug;
use std::marker;

use amethyst::core::nalgebra as na;
use amethyst::core::{Result, SystemBundle};
use amethyst_error::Error;
use amethyst::core::{SystemBundle};
use amethyst::ecs::prelude::DispatcherBuilder;
use amethyst_rhusics::Convert;
use cgmath::{Array, EuclideanSpace, InnerSpace, Rotation, Zero};
Expand Down Expand Up @@ -52,7 +53,7 @@ where
A: Clone + Copy + Zero + Send + Sync + 'static,
I: Inertia + Send + Sync + 'static,
{
fn build(self, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<()> {
fn build(self, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
dispatcher.add(
EmissionSystem::<P, B, R, A, I>::new(self.primitive),
"emission_system",
Expand Down
2 changes: 1 addition & 1 deletion examples/boxes/deletion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ where
collisions.0 += 1;
match (objects.get(contact.bodies.0), objects.get(contact.bodies.1)) {
(Some(_), Some(_)) => {
let mut chance = rand::thread_rng().gen_range(0., 1.);
let chance = rand::thread_rng().gen_range(0., 1.);
if chance <= kill_rate.0 {
match entities.delete(contact.bodies.0) {
Err(e) => println!("Error: {:?}", e),
Expand Down
1 change: 1 addition & 0 deletions examples/boxes/emission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use amethyst::core::{GlobalTransform, Transform};
use amethyst::ecs::prelude::{Entities, Entity, Join, ReadExpect, System, WriteStorage};
use amethyst::renderer::{Material, Mesh};
use amethyst_rhusics::{AsTransform, Convert};
use shred_derive::SystemData;
use cgmath::{Array, EuclideanSpace, InnerSpace, Rotation, Zero};
use collision::{Bound, ComputeBound, Primitive, Union};
use rand::Rand;
Expand Down
18 changes: 10 additions & 8 deletions examples/boxes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
pub use self::bundle::BoxSimulationBundle;
pub use self::default::{BoxSimulationBundle2, BoxSimulationBundle3};
pub use self::deletion::BoxDeletionSystem;
pub use self::emission::EmissionSystem;
pub use self::ui::*;

//! Boxes module, Rust 2018 style
mod bundle;
mod default;
mod deletion;
mod emission;
mod ui;

pub use self::bundle::BoxSimulationBundle;
pub use self::default::{BoxSimulationBundle2, BoxSimulationBundle3};
pub use self::deletion::BoxDeletionSystem;
pub use self::emission::EmissionSystem;

pub use self::ui::*;

use std::time::{Duration, Instant};

use amethyst::assets::Handle;
Expand Down Expand Up @@ -59,8 +61,8 @@ pub struct Emitter<P> {
}

impl<P> Component for Emitter<P>
where
P: Send + Sync + 'static,
where
P: Send + Sync + 'static,
{
type Storage = DenseVecStorage<Self>;
}
Expand Down
3 changes: 0 additions & 3 deletions examples/boxes/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub fn create_ui(world: &mut World) -> (Entity, Entity, Entity) {
1.,
200.,
50.,
0,
)).with(UiText::new(
font.clone(),
"N/A".to_string(),
Expand All @@ -41,7 +40,6 @@ pub fn create_ui(world: &mut World) -> (Entity, Entity, Entity) {
1.,
200.,
50.,
0,
)).with(UiText::new(
font.clone(),
"N/A".to_string(),
Expand All @@ -61,7 +59,6 @@ pub fn create_ui(world: &mut World) -> (Entity, Entity, Entity) {
1.,
200.,
50.,
0,
)).with(UiText::new(
font.clone(),
"N/A".to_string(),
Expand Down
21 changes: 5 additions & 16 deletions examples/boxes2d.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
extern crate amethyst;
extern crate amethyst_rhusics;
extern crate cgmath;
extern crate collision;
extern crate genmesh;
extern crate rand;
extern crate rhusics_core;
extern crate rhusics_ecs;
extern crate shred;
#[macro_use]
extern crate shred_derive;

use std::time::{Duration, Instant};

Expand All @@ -34,7 +23,7 @@ use collision::Aabb2;
use rhusics_core::CollisionShape;
use rhusics_ecs::physics2d::BodyPose2;

use self::boxes::{
use crate::boxes::{
create_ui, update_ui, BoxSimulationBundle2, Emitter, Graphics, KillRate, ObjectType,
};

Expand All @@ -49,8 +38,8 @@ pub struct Emitting {

pub type Shape = CollisionShape<Primitive2<f32>, BodyPose2<f32>, Aabb2<f32>, ObjectType>;

impl<'a, 'b> SimpleState<'a, 'b> for Emitting {
fn on_start(&mut self, data: StateData<GameData>) {
impl SimpleState for Emitting {
fn on_start(&mut self, data: StateData<'_, GameData<'_, '_>>) {
let StateData { world, .. } = data;
world.write_resource::<KillRate>().0 = 0.01;
initialise_camera(world);
Expand All @@ -77,7 +66,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Emitting {
initialise_emitters(world);
}

fn handle_event(&mut self, _: StateData<GameData>, event: StateEvent) -> SimpleTrans<'a, 'b> {
fn handle_event(&mut self, _: StateData<GameData>, event: StateEvent) -> SimpleTrans {
match event {
StateEvent::Window(ref event)
if is_close_requested(&event) || is_key_down(&event, VirtualKeyCode::Escape) =>
Expand All @@ -88,7 +77,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Emitting {
}
}

fn update(&mut self, data: &mut StateData<GameData>) -> SimpleTrans<'a, 'b> {
fn update(&mut self, data: &mut StateData<GameData>) -> SimpleTrans {
time_sync(&data.world);
update_ui::<Point2<f32>>(
data.world,
Expand Down
10 changes: 5 additions & 5 deletions examples/boxes3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern crate rand;
extern crate rhusics_core;
extern crate rhusics_ecs;
extern crate shred;
#[macro_use]
//#[macro_use] // TOD: in Rust 2018 you import the macros explicitly.
extern crate shred_derive;

use std::time::{Duration, Instant};
Expand Down Expand Up @@ -49,8 +49,8 @@ pub struct Emitting {

pub type Shape = CollisionShape<Primitive3<f32>, BodyPose3<f32>, Aabb3<f32>, ObjectType>;

impl<'a, 'b> SimpleState<'a, 'b> for Emitting {
fn on_start(&mut self, data: StateData<GameData>) {
impl SimpleState for Emitting {
fn on_start(&mut self, data: StateData<'_, GameData<'_, '_>>) {
let StateData { world, .. } = data;
world.write_resource::<KillRate>().0 = 0.;
initialise_camera(world);
Expand Down Expand Up @@ -80,7 +80,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Emitting {
initialise_emitters(world);
}

fn handle_event(&mut self, _: StateData<GameData>, event: StateEvent) -> SimpleTrans<'a, 'b> {
fn handle_event(&mut self, _: StateData<GameData>, event: StateEvent) -> SimpleTrans {
match event {
StateEvent::Window(ref event)
if is_close_requested(&event) || is_key_down(&event, VirtualKeyCode::Escape) =>
Expand All @@ -91,7 +91,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Emitting {
}
}

fn update(&mut self, data: &mut StateData<GameData>) -> SimpleTrans<'a, 'b> {
fn update(&mut self, data: &mut StateData<GameData>) -> SimpleTrans {
time_sync(&data.world);
update_ui::<Point3<f32>>(
data.world,
Expand Down
9 changes: 5 additions & 4 deletions src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::fmt::Debug;
use std::marker;

use amethyst_core::specs::prelude::{DispatcherBuilder, Entity};
use amethyst_core::{Result, SystemBundle};
use amethyst_error::Error;
use amethyst_core::{SystemBundle};
use cgmath::{Basis2, Point2, Point3, Quaternion};
use collision::algorithm::broad_phase::{SweepAndPrune2, SweepAndPrune3};
use collision::dbvt::TreeValueWrapped;
Expand All @@ -12,7 +13,7 @@ use rhusics_ecs::physics2d::{setup_dispatch_2d, GJK2};
use rhusics_ecs::physics3d::{setup_dispatch_3d, GJK3};
use rhusics_ecs::DeltaTime;

use default::{PoseTransformSyncSystem2, PoseTransformSyncSystem3};
use crate::default::{PoseTransformSyncSystem2, PoseTransformSyncSystem3};

/// Bundle for configuring 2D physics.
///
Expand Down Expand Up @@ -60,7 +61,7 @@ where
+ 'static,
Y: Default + Collider + Send + Sync + 'static,
{
fn build(self, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<()> {
fn build(self, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
setup_dispatch_2d::<
f32,
P,
Expand Down Expand Up @@ -132,7 +133,7 @@ where
+ 'static,
Y: Default + Collider + Send + Sync + 'static,
{
fn build(self, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<()> {
fn build(self, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
setup_dispatch_3d::<
f32,
P,
Expand Down
4 changes: 2 additions & 2 deletions src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use cgmath::{Basis2, Point2, Point3, Quaternion};
use collision::primitive::{Primitive2, Primitive3};
use collision::{Aabb2, Aabb3};

use bundle::{PhysicsBundle2, PhysicsBundle3};
use sync::PoseTransformSyncSystem;
use crate::bundle::{PhysicsBundle2, PhysicsBundle3};
use crate::sync::PoseTransformSyncSystem;

/// Utility type for a 2D sync system (from `BodyPose` to `Transform`).
pub type PoseTransformSyncSystem2 = PoseTransformSyncSystem<Point2<f32>, Basis2<f32>>;
Expand Down

0 comments on commit 8b4fdc2

Please sign in to comment.