mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'master' of gitlab.com:veloren/veloren
Former-commit-id: 83dc38d485fbe06bcef86849e14f0b6755b05219
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2289,9 +2289,9 @@ dependencies = [
|
|||||||
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"shred 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"specs 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"specs 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"sphynx 0.1.0 (git+https://gitlab.com/veloren/sphynx.git)",
|
"sphynx 0.1.0 (git+https://gitlab.com/veloren/sphynx.git)",
|
||||||
"threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
Submodule assets/voxygen updated: cff10b010d...7ebb1a9205
@ -7,8 +7,7 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
sphynx = { git = "https://gitlab.com/veloren/sphynx.git", features = ["serde1"] }
|
sphynx = { git = "https://gitlab.com/veloren/sphynx.git", features = ["serde1"] }
|
||||||
|
|
||||||
specs = { version = "0.14", features = ["serde"] }
|
specs = { version = "0.14", features = ["serde", "nightly"] }
|
||||||
shred = { version = "0.7", features = ["nightly"] }
|
|
||||||
vek = { version = "0.9", features = ["serde"] }
|
vek = { version = "0.9", features = ["serde"] }
|
||||||
dot_vox = "4.0"
|
dot_vox = "4.0"
|
||||||
threadpool = "1.7"
|
threadpool = "1.7"
|
||||||
@ -19,3 +18,4 @@ serde_derive = "1.0"
|
|||||||
bincode = "1.0"
|
bincode = "1.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rand = "0.5"
|
rand = "0.5"
|
||||||
|
rayon = "1.0"
|
||||||
|
@ -7,14 +7,15 @@ use crate::{
|
|||||||
sys,
|
sys,
|
||||||
terrain::{TerrainChunk, TerrainMap},
|
terrain::{TerrainChunk, TerrainMap},
|
||||||
};
|
};
|
||||||
use shred::{Fetch, FetchMut};
|
use rayon::{ThreadPool, ThreadPoolBuilder};
|
||||||
use specs::{
|
use specs::{
|
||||||
saveload::{MarkedBuilder, MarkerAllocator},
|
saveload::{MarkedBuilder, MarkerAllocator},
|
||||||
|
shred::{Fetch, FetchMut},
|
||||||
storage::{MaskedStorage as EcsMaskedStorage, Storage as EcsStorage},
|
storage::{MaskedStorage as EcsMaskedStorage, Storage as EcsStorage},
|
||||||
Builder, Component, DispatcherBuilder, Entity as EcsEntity, EntityBuilder as EcsEntityBuilder,
|
Builder, Component, DispatcherBuilder, Entity as EcsEntity, EntityBuilder as EcsEntityBuilder,
|
||||||
};
|
};
|
||||||
use sphynx;
|
use sphynx;
|
||||||
use std::{collections::HashSet, time::Duration};
|
use std::{collections::HashSet, sync::Arc, time::Duration};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
/// How much faster should an in-game day be compared to a real day?
|
/// How much faster should an in-game day be compared to a real day?
|
||||||
@ -57,6 +58,8 @@ impl Changes {
|
|||||||
/// things like entity components, terrain data, and global state like weather, time of day, etc.
|
/// things like entity components, terrain data, and global state like weather, time of day, etc.
|
||||||
pub struct State {
|
pub struct State {
|
||||||
ecs: sphynx::World<EcsPacket>,
|
ecs: sphynx::World<EcsPacket>,
|
||||||
|
// Avoid lifetime annotation by storing a thread pool instead of the whole dispatcher
|
||||||
|
thread_pool: Arc<ThreadPool>,
|
||||||
changes: Changes,
|
changes: Changes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +68,7 @@ impl State {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
ecs: sphynx::World::new(specs::World::new(), Self::setup_sphynx_world),
|
ecs: sphynx::World::new(specs::World::new(), Self::setup_sphynx_world),
|
||||||
|
thread_pool: Arc::new(ThreadPoolBuilder::new().build().unwrap()),
|
||||||
changes: Changes::default(),
|
changes: Changes::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,6 +81,7 @@ impl State {
|
|||||||
Self::setup_sphynx_world,
|
Self::setup_sphynx_world,
|
||||||
state_package,
|
state_package,
|
||||||
),
|
),
|
||||||
|
thread_pool: Arc::new(ThreadPoolBuilder::new().build().unwrap()),
|
||||||
changes: Changes::default(),
|
changes: Changes::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,7 +202,7 @@ impl State {
|
|||||||
self.ecs.write_resource::<DeltaTime>().0 = dt.as_secs_f64();
|
self.ecs.write_resource::<DeltaTime>().0 = dt.as_secs_f64();
|
||||||
|
|
||||||
// Create and run dispatcher for ecs systems
|
// Create and run dispatcher for ecs systems
|
||||||
let mut dispatch_builder = DispatcherBuilder::new();
|
let mut dispatch_builder = DispatcherBuilder::new().with_pool(self.thread_pool.clone());
|
||||||
sys::add_local_systems(&mut dispatch_builder);
|
sys::add_local_systems(&mut dispatch_builder);
|
||||||
// This dispatches all the systems in parallel
|
// This dispatches all the systems in parallel
|
||||||
dispatch_builder.build().dispatch(&self.ecs.res);
|
dispatch_builder.build().dispatch(&self.ecs.res);
|
||||||
|
Reference in New Issue
Block a user