Skip to content

Commit

Permalink
0.14.1 (staging): Upgraded to Amethyst 0.15. Compiles and gravity exa…
Browse files Browse the repository at this point in the history
…mple runs, but boxes examples don't yet show boxes.
  • Loading branch information
trsoluti committed Aug 1, 2020
1 parent 382a871 commit 1f90b0b
Show file tree
Hide file tree
Showing 16 changed files with 547 additions and 504 deletions.
6 changes: 0 additions & 6 deletions .idea/misc.xml

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

33 changes: 19 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "amethyst-rhusics"
version = "0.3.3"
version = "0.4.1"
authors = [
"Simon Rönnberg <[email protected]>",
"Thomas O'Dell <[email protected]>"
Expand All @@ -18,20 +18,25 @@ description = "Integration of `amethyst` and `rhusics`"
keywords = ["gamedev", "amethyst", "physics"]

[dependencies]
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 = "0.8", git = "https://github.com/trsoluti/rhusics", features = ["serde"] }
rhusics-core = { version = "0.8", git = "https://github.com/trsoluti/rhusics", features = ["specs", "serde"] }
shrev = "*"
# collision = { git = "https://github.com/rustgd/collision-rs", features = ["serde"]}
amethyst_error = "0.5.0"
amethyst_core = "0.10.0"
rhusics-ecs = { version = "0.9", git = "https://github.com/trsoluti/rhusics", features = ["serializable"] }
rhusics-core = { version = "0.9", git = "https://github.com/trsoluti/rhusics", features = ["specs", "serializable"] }
shrev = "1.1"
collision = { version = "0.20", features = ["serde"] }
nalgebra = "0.17"
nalgebra = "0.21"
cgmath = "0.17"

[dev-dependencies]
amethyst = { git = "https://github.com/amethyst/amethyst" }
genmesh = "*"
rand = "*"
shred = "*"
shred-derive = "*"
# Note: cargo currently does not allow you to set features that affect dev dependencies
# if you do you get an error:
# the package <your package> depends on `amethyst-rhusics`, with features: `amethyst`
# but `amethyst-rhusics` does not have these features.
# (Bug #6915)
# You'll have to hand-modify this configuration file for your own environment.
amethyst = { version = "0.15", features = ["metal"] }
log = { version = "0.4.8", features = ["serde"] }
genmesh = "0.6"
rand = "0.6.5" # same version of rand used by cgmath
shred = { version = "0.10", features = ["shred-derive"] }
shred-derive = "0.6"
4 changes: 3 additions & 1 deletion examples/boxes/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use rand::distributions::Standard;
use rhusics_core::Inertia;

use super::{BoxDeletionSystem, EmissionSystem};
use amethyst_core::ecs::World;

/// Bundle for box simulation.
///
Expand All @@ -32,6 +33,7 @@ pub struct BoxSimulationBundle<P, B, R, A, I> {
}

impl<P, B, R, A, I> BoxSimulationBundle<P, B, R, A, I> {
#[allow(unused)]
pub fn new(primitive: P) -> Self {
Self {
primitive,
Expand All @@ -56,7 +58,7 @@ where
I: Inertia + Send + Sync + 'static,
Standard: Distribution<<P::Point as EuclideanSpace>::Diff>,
{
fn build(self, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
fn build(self, _world: &mut World, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
dispatcher.add(
EmissionSystem::<P, B, R, A, I>::new(self.primitive),
"emission_system",
Expand Down
4 changes: 2 additions & 2 deletions examples/boxes/deletion.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Debug;

use amethyst::ecs::prelude::{Entities, Entity, Read, ReadStorage, Resources, System, Write};
use amethyst::ecs::prelude::{Entities, Entity, Read, ReadStorage, World, System, Write};
use amethyst::shrev::{EventChannel, ReaderId};
use cgmath::EuclideanSpace;
use rand;
Expand Down Expand Up @@ -73,7 +73,7 @@ where
}
}

fn setup(&mut self, res: &mut Resources) {
fn setup(&mut self, res: &mut World) {
use amethyst::ecs::prelude::SystemData;
Self::SystemData::setup(res);
self.contact_reader = Some(
Expand Down
28 changes: 16 additions & 12 deletions examples/boxes/emission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ use std::time::Instant;

use amethyst::assets::Handle;
use amethyst::core::math as na;
use amethyst::core::{GlobalTransform, Transform};
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 shred_derive::SystemData;
use shred::SystemData;
use shred::World;
use shred::ResourceId;
use cgmath::{Array, EuclideanSpace, InnerSpace, Rotation, Zero};
use collision::{Bound, ComputeBound, Primitive, Union};
//use rand::Rand;
Expand Down Expand Up @@ -102,29 +105,30 @@ fn emit_box<P, B, R, A, I>(
I: Inertia + Send + Sync + 'static,
Standard: Distribution<<P::Point as EuclideanSpace>::Diff>,
{
use rand;
use rand::Rng;
/*use rand;*/
/*use rand::Rng;*/
/*use rand::rngs::StdRng;*/

let offset:<P::Point as EuclideanSpace>::Diff =
SmallRng::from_entropy().sample(Standard);
StdRng::from_entropy().sample(Standard);
let speed: <P::Point as EuclideanSpace>::Scalar =
rand::thread_rng().gen_range(-10.0, 10.0);

let position = emitter.location + offset;
let pose = BodyPose::new(position, R::one());
let mut transform = pose.as_transform();
transform.set_scale(0.05, 0.05, 0.05);
transform.set_scale([0.05, 0.05, 0.05].into());

parts.object_type.insert(entity, ObjectType::Box).unwrap();
parts.mesh.insert(entity, mesh).unwrap();
parts
.material
.insert(entity, emitter.material.clone())
.unwrap();
parts
.global
.insert(entity, GlobalTransform::default())
.unwrap();
// parts
// .global
// .insert(entity, /*Global*/Transform::default())
// .unwrap();
parts.local.insert(entity, transform).unwrap();
parts
.physical_entity
Expand Down Expand Up @@ -157,8 +161,8 @@ where
{
pub object_type: WriteStorage<'a, ObjectType>,
pub mesh: WriteStorage<'a, Handle<Mesh>>,
pub material: WriteStorage<'a, Material>,
pub global: WriteStorage<'a, GlobalTransform>,
pub material: WriteStorage<'a, Handle<Material>>,
/*pub global: WriteStorage<'a, GlobalTransform>,*/
pub local: WriteStorage<'a, Transform>,
pub physical_entity: PhysicalEntityParts<
'a,
Expand Down
2 changes: 1 addition & 1 deletion examples/boxes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct Emitter<P> {
pub location: P,
pub last_emit: Instant,
pub emission_interval: Duration,
pub material: Material,
pub material: Handle<Material>,
pub emitted: u64,
}

Expand Down
14 changes: 9 additions & 5 deletions examples/boxes/ui.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
use super::{Collisions, Emitter};
use amethyst::assets::Loader;
use amethyst::core::{Parent, Time};
use amethyst::ecs::prelude::{Builder, Entity, Join, World};
use amethyst::ecs::prelude::{Builder, Entity, Join, World, WorldExt};
use amethyst::ui::{Anchor, TtfFormat, UiText, UiTransform};
use amethyst::utils::fps_counter::FPSCounter;
use amethyst::utils::fps_counter::FpsCounter;

#[allow(unused)]
pub fn create_ui(world: &mut World) -> (Entity, Entity, Entity) {
let font = world.read_resource::<Loader>().load(
"examples/resources/font/square.ttf",
"font/square.ttf",
TtfFormat,
(),
(),
&world.read_resource(),
);
let num_display = world
.create_entity()
.with(UiTransform::new(
"num".to_string(),
Anchor::TopLeft,
Anchor::Middle,
100.,
25.,
1.,
Expand All @@ -35,6 +36,7 @@ pub fn create_ui(world: &mut World) -> (Entity, Entity, Entity) {
.with(UiTransform::new(
"fps".to_string(),
Anchor::BottomLeft,
Anchor::Middle,
100.,
0.,
1.,
Expand All @@ -54,6 +56,7 @@ pub fn create_ui(world: &mut World) -> (Entity, Entity, Entity) {
.with(UiTransform::new(
"collisions".to_string(),
Anchor::BottomLeft,
Anchor::Middle,
100.,
0.,
1.,
Expand All @@ -70,6 +73,7 @@ pub fn create_ui(world: &mut World) -> (Entity, Entity, Entity) {
(num_display, fps_display, collisions_display)
}

#[allow(unused)]
pub fn update_ui<P>(
world: &mut World,
num_entity: Entity,
Expand All @@ -79,7 +83,7 @@ pub fn update_ui<P>(
P: Send + Sync + 'static,
{
let frame_number = world.read_resource::<Time>().frame_number();
let fps = world.read_resource::<FPSCounter>().sampled_fps();
let fps = world.read_resource::<FpsCounter>().sampled_fps();

if frame_number % 20 == 0 {
if let Some(fps_display) = world.write_storage::<UiText>().get_mut(fps_entity) {
Expand Down
Loading

0 comments on commit 1f90b0b

Please sign in to comment.