Convert away from IdvStorage to mixture of VecStorage and DenseVecStorage

This commit is contained in:
Imbris 2022-08-08 00:38:20 -04:00
parent 1066553f21
commit d5b59c2bb7
45 changed files with 88 additions and 145 deletions

12
Cargo.lock generated
View File

@ -5643,14 +5643,6 @@ dependencies = [
"syn 1.0.98", "syn 1.0.98",
] ]
[[package]]
name = "specs-idvs"
version = "0.1.1"
source = "git+https://gitlab.com/veloren/specs-idvs.git?rev=c17abc638f23ef221ce7384c7dd77eef757b82f4#c17abc638f23ef221ce7384c7dd77eef757b82f4"
dependencies = [
"specs",
]
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.5.2" version = "0.5.2"
@ -6517,7 +6509,6 @@ dependencies = [
"slab", "slab",
"slotmap 1.0.6", "slotmap 1.0.6",
"specs", "specs",
"specs-idvs",
"spin_sleep", "spin_sleep",
"structopt", "structopt",
"strum", "strum",
@ -6587,7 +6578,6 @@ dependencies = [
"num-traits", "num-traits",
"serde", "serde",
"specs", "specs",
"specs-idvs",
"sum_type", "sum_type",
"tracing", "tracing",
"vek 0.15.8", "vek 0.15.8",
@ -6748,7 +6738,6 @@ dependencies = [
"serde_json", "serde_json",
"slab", "slab",
"specs", "specs",
"specs-idvs",
"strum", "strum",
"tokio", "tokio",
"tracing", "tracing",
@ -6842,7 +6831,6 @@ dependencies = [
"shaderc", "shaderc",
"slab", "slab",
"specs", "specs",
"specs-idvs",
"strum", "strum",
"tokio", "tokio",
"tracing", "tracing",

View File

@ -79,7 +79,6 @@ slab = "0.4.2"
# ECS # ECS
specs = { version = "0.18", features = ["serde", "storage-event-control", "nightly"] } specs = { version = "0.18", features = ["serde", "storage-event-control", "nightly"] }
specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "c17abc638f23ef221ce7384c7dd77eef757b82f4" }
[dev-dependencies] [dev-dependencies]
#bench #bench

View File

@ -26,7 +26,6 @@ hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] }
# ECS # ECS
specs = { version = "0.18", features = ["serde", "storage-event-control"] } specs = { version = "0.18", features = ["serde", "storage-event-control"] }
specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "c17abc638f23ef221ce7384c7dd77eef757b82f4" }
# Serde # Serde
serde = { version = "1.0.110", features = ["derive"] } serde = { version = "1.0.110", features = ["derive"] }

View File

@ -4,7 +4,6 @@
use super::InterpolatableComponent; use super::InterpolatableComponent;
use common::comp::{Ori, Pos, Vel}; use common::comp::{Ori, Pos, Vel};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use tracing::warn; use tracing::warn;
use vek::ops::{Lerp, Slerp}; use vek::ops::{Lerp, Slerp};
@ -53,7 +52,7 @@ impl<T: Clone> InterpBuffer<T> {
} }
impl<T: 'static + Send + Sync> Component for InterpBuffer<T> { impl<T: 'static + Send + Sync> Component for InterpBuffer<T> {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }
// 0 is pure physics, 1 is pure extrapolation // 0 is pure physics, 1 is pure extrapolation

View File

@ -29,7 +29,6 @@ use crate::{
use hashbrown::HashMap; use hashbrown::HashMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::{convert::TryFrom, time::Duration}; use std::{convert::TryFrom, time::Duration};
pub const MAX_ABILITIES: usize = 5; pub const MAX_ABILITIES: usize = 5;
@ -48,7 +47,7 @@ pub struct ActiveAbilities {
} }
impl Component for ActiveAbilities { impl Component for ActiveAbilities {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }
impl Default for ActiveAbilities { impl Default for ActiveAbilities {

View File

@ -1,6 +1,5 @@
use clap::arg_enum; use clap::arg_enum;
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
arg_enum! { arg_enum! {
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
@ -14,5 +13,5 @@ arg_enum! {
pub struct Admin(pub AdminRole); pub struct Admin(pub AdminRole);
impl Component for Admin { impl Component for Admin {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }

View File

@ -10,7 +10,6 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage, Entity as EcsEntity}; use specs::{Component, DerefFlaggedStorage, Entity as EcsEntity};
use specs_idvs::IdvStorage;
use std::{collections::VecDeque, fmt}; use std::{collections::VecDeque, fmt};
use strum::{EnumIter, IntoEnumIterator}; use strum::{EnumIter, IntoEnumIterator};
use vek::*; use vek::*;
@ -80,7 +79,7 @@ impl Alignment {
} }
impl Component for Alignment { impl Component for Alignment {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }
bitflags::bitflags! { bitflags::bitflags! {
@ -610,7 +609,7 @@ impl Agent {
} }
impl Component for Agent { impl Component for Agent {
type Storage = IdvStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,5 +1,4 @@
use specs::{Component, Entity}; use specs::{Component, Entity};
use specs_idvs::IdvStorage;
use vek::Vec2; use vek::Vec2;
/// This component exists in order to fix a bug that caused entities /// This component exists in order to fix a bug that caused entities
@ -16,5 +15,5 @@ pub enum Anchor {
} }
impl Component for Anchor { impl Component for Anchor {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }

View File

@ -5,8 +5,7 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use slotmap::{new_key_type, SlotMap}; use slotmap::{new_key_type, SlotMap};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage, VecStorage};
use specs_idvs::IdvStorage;
use std::time::Duration; use std::time::Duration;
new_key_type! { pub struct AuraKey; } new_key_type! { pub struct AuraKey; }
@ -154,5 +153,5 @@ impl AuraBuffConstructor {
} }
impl Component for Auras { impl Component for Auras {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }

View File

@ -1,7 +1,6 @@
use crate::{combat::Attack, uid::Uid}; use crate::{combat::Attack, uid::Uid};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::time::Duration; use std::time::Duration;
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
@ -26,7 +25,7 @@ pub struct BeamSegment {
} }
impl Component for BeamSegment { impl Component for BeamSegment {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::DenseVecStorage<Self>>;
} }
impl std::ops::Deref for BeamSegment { impl std::ops::Deref for BeamSegment {
@ -43,7 +42,7 @@ pub struct Beam {
} }
impl Component for Beam { impl Component for Beam {
type Storage = IdvStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]

View File

@ -24,7 +24,6 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use strum::Display; use strum::Display;
use vek::*; use vek::*;
@ -942,5 +941,5 @@ impl Body {
} }
impl Component for Body { impl Component for Body {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }

View File

@ -5,9 +5,7 @@ use core::{cmp::Ordering, time::Duration};
use hashbrown::HashMap; use hashbrown::HashMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage, VecStorage};
#[cfg(not(target_arch = "wasm32"))]
use specs_idvs::IdvStorage;
use strum::EnumIter; use strum::EnumIter;
/// De/buff Kind. /// De/buff Kind.
@ -529,5 +527,5 @@ pub type BuffId = u64;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
impl Component for Buffs { impl Component for Buffs {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }

View File

@ -13,7 +13,6 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use strum::Display; use strum::Display;
@ -401,5 +400,5 @@ impl Default for CharacterState {
} }
impl Component for CharacterState { impl Component for CharacterState {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }

View File

@ -3,8 +3,7 @@ use crate::{
uid::Uid, uid::Uid,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::{Component, DenseVecStorage};
use specs_idvs::IdvStorage;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
/// A player's current chat mode. These are chat types that can only be sent by /// A player's current chat mode. These are chat types that can only be sent by
@ -26,7 +25,7 @@ pub enum ChatMode {
} }
impl Component for ChatMode { impl Component for ChatMode {
type Storage = IdvStorage<Self>; type Storage = DenseVecStorage<Self>;
} }
impl ChatMode { impl ChatMode {
@ -257,7 +256,7 @@ impl<G> GenericChatMsg<G> {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Faction(pub String); pub struct Faction(pub String);
impl Component for Faction { impl Component for Faction {
type Storage = IdvStorage<Self>; type Storage = DenseVecStorage<Self>;
} }
impl From<String> for Faction { impl From<String> for Faction {
fn from(s: String) -> Self { Faction(s) } fn from(s: String) -> Self { Faction(s) }

View File

@ -1,6 +1,5 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage, VecStorage};
use specs_idvs::IdvStorage;
pub const COMBO_DECAY_START: f64 = 7.5; // seconds pub const COMBO_DECAY_START: f64 = 7.5; // seconds
@ -37,5 +36,5 @@ impl Combo {
} }
impl Component for Combo { impl Component for Combo {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }

View File

@ -14,7 +14,6 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use vek::*; use vek::*;
@ -319,5 +318,5 @@ impl Controller {
} }
impl Component for Controller { impl Component for Controller {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }

View File

@ -1,7 +1,6 @@
use crate::{comp, consts::ENERGY_PER_LEVEL}; use crate::{comp, consts::ENERGY_PER_LEVEL};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::ops::Mul; use std::ops::Mul;
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
@ -125,5 +124,5 @@ impl Energy {
} }
impl Component for Energy { impl Component for Energy {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }

View File

@ -3,7 +3,6 @@ use hashbrown::HashMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use slab::Slab; use slab::Slab;
use specs::{Component, DerefFlaggedStorage, Join}; use specs::{Component, DerefFlaggedStorage, Join};
use specs_idvs::IdvStorage;
use tracing::{error, warn}; use tracing::{error, warn};
// Primitive group system // Primitive group system
@ -25,7 +24,7 @@ pub const ENEMY: Group = Group(u32::MAX);
pub const NPC: Group = Group(u32::MAX - 1); pub const NPC: Group = Group(u32::MAX - 1);
impl Component for Group { impl Component for Group {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View File

@ -8,8 +8,6 @@ use std::convert::TryFrom;
use crate::{combat::DamageContributor, resources::Time}; use crate::{combat::DamageContributor, resources::Time};
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
#[cfg(not(target_arch = "wasm32"))]
use specs_idvs::IdvStorage;
use std::ops::Mul; use std::ops::Mul;
/// Specifies what and how much changed current health /// Specifies what and how much changed current health
@ -230,7 +228,7 @@ impl Health {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
impl Component for Health { impl Component for Health {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,8 +1,7 @@
use crate::depot::Id; use crate::depot::Id;
use hashbrown::HashSet; use hashbrown::HashSet;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DenseVecStorage, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use vek::geom::Aabb; use vek::geom::Aabb;
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
@ -11,5 +10,5 @@ pub struct CanBuild {
pub build_areas: HashSet<Id<Aabb<i32>>>, pub build_areas: HashSet<Id<Aabb<i32>>>,
} }
impl Component for CanBuild { impl Component for CanBuild {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, DenseVecStorage<Self>>;
} }

View File

@ -21,8 +21,7 @@ use core::{
}; };
use crossbeam_utils::atomic::AtomicCell; use crossbeam_utils::atomic::AtomicCell;
use serde::{de, Deserialize, Serialize, Serializer}; use serde::{de, Deserialize, Serialize, Serializer};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DenseVecStorage, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::{borrow::Cow, collections::hash_map::DefaultHasher, fmt, sync::Arc}; use std::{borrow::Cow, collections::hash_map::DefaultHasher, fmt, sync::Arc};
use strum::{EnumString, IntoStaticStr}; use strum::{EnumString, IntoStaticStr};
use tracing::error; use tracing::error;
@ -1211,14 +1210,14 @@ impl ItemDesc for ItemDef {
} }
impl Component for Item { impl Component for Item {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, DenseVecStorage<Self>>;
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ItemDrop(pub Item); pub struct ItemDrop(pub Item);
impl Component for ItemDrop { impl Component for ItemDrop {
type Storage = IdvStorage<Self>; type Storage = DenseVecStorage<Self>;
} }
impl<'a, T: ItemDesc + ?Sized> ItemDesc for &'a T { impl<'a, T: ItemDesc + ?Sized> ItemDesc for &'a T {

View File

@ -1,7 +1,6 @@
use core::ops::Not; use core::ops::Not;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::{convert::TryFrom, mem, ops::Range}; use std::{convert::TryFrom, mem, ops::Range};
use tracing::{debug, trace, warn}; use tracing::{debug, trace, warn};
use vek::Vec3; use vek::Vec3;
@ -820,7 +819,7 @@ impl Inventory {
} }
impl Component for Inventory { impl Component for Inventory {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
@ -871,5 +870,7 @@ impl InventoryUpdate {
} }
impl Component for InventoryUpdate { impl Component for InventoryUpdate {
type Storage = IdvStorage<Self>; // TODO: This could probabably be `DenseVecStorage` (except we call clear on
// this and that essentially leaks for `DenseVecStorage` atm afaict).
type Storage = specs::VecStorage<Self>;
} }

View File

@ -1,6 +1,5 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum InviteKind { pub enum InviteKind {
@ -20,12 +19,12 @@ pub struct Invite {
} }
impl Component for Invite { impl Component for Invite {
type Storage = IdvStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
/// Pending invites that an entity currently has sent out /// Pending invites that an entity currently has sent out
/// (invited entity, instant when invite times out) /// (invited entity, instant when invite times out)
pub struct PendingInvites(pub Vec<(specs::Entity, InviteKind, std::time::Instant)>); pub struct PendingInvites(pub Vec<(specs::Entity, InviteKind, std::time::Instant)>);
impl Component for PendingInvites { impl Component for PendingInvites {
type Storage = IdvStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }

View File

@ -1,10 +1,9 @@
use crate::{resources::Time, uid::Uid}; use crate::{resources::Time, uid::Uid};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use vek::*; use vek::*;
#[derive(Copy, Clone, Debug, Serialize, Deserialize)] #[derive(Copy, Clone, Debug)]
pub struct Waypoint { pub struct Waypoint {
pos: Vec3<f32>, pos: Vec3<f32>,
last_save: Time, last_save: Time,
@ -28,7 +27,7 @@ impl Waypoint {
} }
impl Component for Waypoint { impl Component for Waypoint {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
@ -39,7 +38,7 @@ impl WaypointArea {
} }
impl Component for WaypointArea { impl Component for WaypointArea {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }
impl Default for WaypointArea { impl Default for WaypointArea {
@ -48,11 +47,11 @@ impl Default for WaypointArea {
/// Marker on the map, used for sharing waypoint with group and /// Marker on the map, used for sharing waypoint with group and
/// persisting it server side. /// persisting it server side.
#[derive(Copy, Clone, Debug, Serialize, Deserialize)] #[derive(Copy, Clone, Debug)]
pub struct MapMarker(pub Vec2<i32>); pub struct MapMarker(pub Vec2<i32>);
impl Component for MapMarker { impl Component for MapMarker {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]

View File

@ -4,7 +4,6 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::{ use std::{
ops::Add, ops::Add,
time::{Duration, Instant}, time::{Duration, Instant},
@ -72,7 +71,7 @@ impl LootOwner {
} }
impl Component for LootOwner { impl Component for LootOwner {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::DenseVecStorage<Self>>;
} }
#[derive(Debug, Copy, Clone, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, Serialize, Deserialize)]

View File

@ -2,7 +2,6 @@ use super::item::Reagent;
use crate::uid::Uid; use crate::uid::Uid;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum Object { pub enum Object {
@ -16,5 +15,5 @@ pub enum Object {
} }
impl Component for Object { impl Component for Object {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }

View File

@ -2,7 +2,6 @@ use crate::util::{Dir, Plane, Projection};
use core::f32::consts::{FRAC_PI_2, PI, TAU}; use core::f32::consts::{FRAC_PI_2, PI, TAU};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use vek::{Quaternion, Vec2, Vec3}; use vek::{Quaternion, Vec2, Vec3};
// Orientation // Orientation
@ -435,7 +434,7 @@ impl From<Ori> for SerdeOri {
} }
impl Component for Ori { impl Component for Ori {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,15 +1,13 @@
use crate::comp::{body::Body, phys::Mass, quadruped_low, quadruped_medium, quadruped_small}; use crate::comp::{body::Body, phys::Mass, quadruped_low, quadruped_medium, quadruped_small};
use crossbeam_utils::atomic::AtomicCell; use crossbeam_utils::atomic::AtomicCell;
use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use std::{num::NonZeroU64, sync::Arc}; use std::{num::NonZeroU64, sync::Arc};
pub type PetId = AtomicCell<Option<NonZeroU64>>; pub type PetId = AtomicCell<Option<NonZeroU64>>;
#[derive(Clone, Debug, Serialize, Deserialize)] // TODO: move to server crate
#[derive(Clone, Debug)]
pub struct Pet { pub struct Pet {
#[serde(skip)]
database_id: Arc<PetId>, database_id: Arc<PetId>,
} }
@ -99,5 +97,8 @@ pub fn is_mountable(mount: &Body, rider: Option<&Body>) -> bool {
} }
impl Component for Pet { impl Component for Pet {
type Storage = IdvStorage<Self>; // Using `DenseVecStorage` has a u64 space overhead per entity and `Pet` just
// has an `Arc` pointer which is the same size on 64-bit platforms. So it
// isn't worth using `DenseVecStorage` here.
type Storage = specs::VecStorage<Self>;
} }

View File

@ -7,8 +7,7 @@ use crate::{
}; };
use hashbrown::HashSet; use hashbrown::HashSet;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage, NullStorage}; use specs::{Component, DerefFlaggedStorage, NullStorage, VecStorage};
use specs_idvs::IdvStorage;
use std::sync::Arc; use std::sync::Arc;
use vek::*; use vek::*;
@ -17,9 +16,7 @@ use vek::*;
pub struct Pos(pub Vec3<f32>); pub struct Pos(pub Vec3<f32>);
impl Component for Pos { impl Component for Pos {
// TODO: why not regular vec storage???? type Storage = VecStorage<Self>;
// TODO: component occupancy metrics
type Storage = IdvStorage<Self>;
} }
/// Velocity /// Velocity
@ -31,8 +28,7 @@ impl Vel {
} }
impl Component for Vel { impl Component for Vel {
// TODO: why not regular vec storage???? type Storage = VecStorage<Self>;
type Storage = IdvStorage<Self>;
} }
/// Used to defer writes to Pos/Vel in nested join loops /// Used to defer writes to Pos/Vel in nested join loops
@ -44,8 +40,7 @@ pub struct PosVelOriDefer {
} }
impl Component for PosVelOriDefer { impl Component for PosVelOriDefer {
// TODO: why not regular vec storage???? type Storage = VecStorage<Self>;
type Storage = IdvStorage<Self>;
} }
/// Cache of Velocity (of last tick) * dt (of curent tick) /// Cache of Velocity (of last tick) * dt (of curent tick)
@ -71,8 +66,7 @@ pub struct PreviousPhysCache {
} }
impl Component for PreviousPhysCache { impl Component for PreviousPhysCache {
// TODO: why not regular vec storage???? type Storage = VecStorage<Self>;
type Storage = IdvStorage<Self>;
} }
// Scale // Scale
@ -80,7 +74,7 @@ impl Component for PreviousPhysCache {
pub struct Scale(pub f32); pub struct Scale(pub f32);
impl Component for Scale { impl Component for Scale {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }
// Mass // Mass
@ -92,7 +86,7 @@ impl Default for Mass {
} }
impl Component for Mass { impl Component for Mass {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }
/// The average density (specific mass) of an entity. /// The average density (specific mass) of an entity.
@ -105,7 +99,7 @@ impl Default for Density {
} }
impl Component for Density { impl Component for Density {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }
// Collider // Collider
@ -159,7 +153,7 @@ impl Collider {
} }
impl Component for Collider { impl Component for Collider {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
@ -214,12 +208,12 @@ impl PhysicsState {
} }
impl Component for PhysicsState { impl Component for PhysicsState {
type Storage = IdvStorage<Self>; type Storage = VecStorage<Self>;
} }
/// Used to forcefully update the position, velocity, and orientation of the /// Used to forcefully update the position, velocity, and orientation of the
/// client /// client
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, Default)]
pub struct ForceUpdate; pub struct ForceUpdate;
impl Component for ForceUpdate { impl Component for ForceUpdate {

View File

@ -1,6 +1,5 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage, NullStorage}; use specs::{Component, DerefFlaggedStorage, NullStorage};
use specs_idvs::IdvStorage;
use uuid::Uuid; use uuid::Uuid;
use crate::resources::{BattleMode, Time}; use crate::resources::{BattleMode, Time};
@ -74,10 +73,10 @@ impl Player {
} }
impl Component for Player { impl Component for Player {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::DenseVecStorage<Self>>;
} }
#[derive(Clone, Debug, Default, Serialize, Deserialize)] #[derive(Clone, Debug, Default)]
pub struct Respawn; pub struct Respawn;
impl Component for Respawn { impl Component for Respawn {
type Storage = NullStorage<Self>; type Storage = NullStorage<Self>;

View File

@ -10,8 +10,7 @@ use crate::{
util::Dir, util::Dir,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage, VecStorage};
use specs_idvs::IdvStorage;
use std::{ops::Mul, time::Duration}; use std::{ops::Mul, time::Duration};
use vek::*; use vek::*;
@ -264,5 +263,5 @@ impl Poise {
} }
impl Component for Poise { impl Component for Poise {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }

View File

@ -9,7 +9,6 @@ use crate::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use std::time::Duration; use std::time::Duration;
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
@ -22,7 +21,7 @@ pub enum Effect {
Bonk, // Knock/dislodge/change objects on hit Bonk, // Knock/dislodge/change objects on hit
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug)]
pub struct Projectile { pub struct Projectile {
// TODO: use SmallVec for these effects // TODO: use SmallVec for these effects
pub hit_solid: Vec<Effect>, pub hit_solid: Vec<Effect>,
@ -40,7 +39,7 @@ pub struct Projectile {
} }
impl Component for Projectile { impl Component for Projectile {
type Storage = IdvStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]

View File

@ -1,7 +1,6 @@
use crate::{combat::Attack, uid::Uid}; use crate::{combat::Attack, uid::Uid};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::time::Duration; use std::time::Duration;
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
@ -27,7 +26,7 @@ pub struct Shockwave {
} }
impl Component for Shockwave { impl Component for Shockwave {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::DenseVecStorage<Self>>;
} }
impl std::ops::Deref for Shockwave { impl std::ops::Deref for Shockwave {
@ -36,13 +35,13 @@ impl std::ops::Deref for Shockwave {
fn deref(&self) -> &Properties { &self.properties } fn deref(&self) -> &Properties { &self.properties }
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq)]
pub struct ShockwaveHitEntities { pub struct ShockwaveHitEntities {
pub hit_entities: Vec<Uid>, pub hit_entities: Vec<Uid>,
} }
impl Component for ShockwaveHitEntities { impl Component for ShockwaveHitEntities {
type Storage = IdvStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]

View File

@ -10,7 +10,6 @@ use lazy_static::lazy_static;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::{collections::BTreeSet, hash::Hash}; use std::{collections::BTreeSet, hash::Hash};
use tracing::{trace, warn}; use tracing::{trace, warn};
@ -239,13 +238,14 @@ pub struct SkillSet {
skills: HashMap<Skill, u16>, skills: HashMap<Skill, u16>,
pub modify_health: bool, pub modify_health: bool,
pub modify_energy: bool, pub modify_energy: bool,
// TODO: why is this part of the component?
/// Used to indicate to the frontend that there was an error in loading the /// Used to indicate to the frontend that there was an error in loading the
/// skillset from the database /// skillset from the database
pub persistence_load_error: Option<SkillsPersistenceError>, pub persistence_load_error: Option<SkillsPersistenceError>,
} }
impl Component for SkillSet { impl Component for SkillSet {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }
impl Default for SkillSet { impl Default for SkillSet {

View File

@ -1,6 +1,5 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::{error::Error, fmt}; use std::{error::Error, fmt};
#[derive(Debug)] #[derive(Debug)]
@ -86,5 +85,5 @@ impl Stats {
} }
impl Component for Stats { impl Component for Stats {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }

View File

@ -1,6 +1,5 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage}; use specs::{Component, DenseVecStorage, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use vek::*; use vek::*;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -23,7 +22,7 @@ impl Default for LightEmitter {
} }
impl Component for LightEmitter { impl Component for LightEmitter {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, DenseVecStorage<Self>>;
} }
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -44,5 +43,5 @@ impl Default for LightAnimation {
} }
impl Component for LightAnimation { impl Component for LightAnimation {
type Storage = IdvStorage<Self>; type Storage = DenseVecStorage<Self>;
} }

View File

@ -1,6 +1,5 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage, SystemData}; use specs::{Component, DerefFlaggedStorage, SystemData};
use specs_idvs::IdvStorage;
use std::{ops::Deref, sync::Arc}; use std::{ops::Deref, sync::Arc};
pub trait Link: Sized + Send + Sync + 'static { pub trait Link: Sized + Send + Sync + 'static {
@ -49,7 +48,7 @@ impl<R: Role + 'static> Component for Is<R>
where where
R::Link: Send + Sync + 'static, R::Link: Send + Sync + 'static,
{ {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]

View File

@ -4,7 +4,6 @@
// module in `server`. // module in `server`.
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use vek::*; use vek::*;
use crate::comp::dialogue::MoodState; use crate::comp::dialogue::MoodState;
@ -15,7 +14,7 @@ pub type RtSimId = usize;
pub struct RtSimEntity(pub RtSimId); pub struct RtSimEntity(pub RtSimId);
impl Component for RtSimEntity { impl Component for RtSimEntity {
type Storage = IdvStorage<Self>; type Storage = specs::VecStorage<Self>;
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View File

@ -26,7 +26,6 @@ network = { package = "veloren-network", path = "../network", features = ["metri
#inline_tweak = "1.0.8" #inline_tweak = "1.0.8"
specs = { version = "0.18", features = ["shred-derive"] } specs = { version = "0.18", features = ["shred-derive"] }
specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "c17abc638f23ef221ce7384c7dd77eef757b82f4" }
strum = { version = "0.24", features = ["derive"] } strum = { version = "0.24", features = ["derive"] }
bincode = "1.3.2" bincode = "1.3.2"

View File

@ -2,7 +2,6 @@ use common_net::msg::{ClientType, ServerGeneral, ServerMsg};
use network::{Message, Participant, Stream, StreamError, StreamParams}; use network::{Message, Participant, Stream, StreamError, StreamParams};
use serde::{de::DeserializeOwned, Serialize}; use serde::{de::DeserializeOwned, Serialize};
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use std::sync::{atomic::AtomicBool, Mutex}; use std::sync::{atomic::AtomicBool, Mutex};
/// Client handles ALL network related information of everything that connects /// Client handles ALL network related information of everything that connects
@ -40,7 +39,7 @@ pub struct PreparedMsg {
} }
impl Component for Client { impl Component for Client {
type Storage = IdvStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
impl Client { impl Client {

View File

@ -5,7 +5,6 @@ use common::comp::AdminRole;
use common_net::msg::RegisterError; use common_net::msg::RegisterError;
use hashbrown::HashMap; use hashbrown::HashMap;
use specs::Component; use specs::Component;
use specs_idvs::IdvStorage;
use std::{str::FromStr, sync::Arc}; use std::{str::FromStr, sync::Arc};
use tokio::{runtime::Runtime, sync::oneshot}; use tokio::{runtime::Runtime, sync::oneshot};
use tracing::{error, info}; use tracing::{error, info};
@ -44,7 +43,7 @@ impl PendingLogin {
} }
impl Component for PendingLogin { impl Component for PendingLogin {
type Storage = IdvStorage<Self>; type Storage = specs::DenseVecStorage<Self>;
} }
pub struct LoginProvider { pub struct LoginProvider {

View File

@ -1,8 +1,7 @@
use common_net::msg::PresenceKind; use common_net::msg::PresenceKind;
use hashbrown::HashSet; use hashbrown::HashSet;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage, NullStorage}; use specs::{Component, DenseVecStorage, DerefFlaggedStorage, NullStorage, VecStorage};
use specs_idvs::IdvStorage;
use vek::*; use vek::*;
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
@ -23,7 +22,8 @@ impl Presence {
} }
impl Component for Presence { impl Component for Presence {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; // Presence seems <= 64 bits, so it isn't worth using DenseVecStorage.
type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
} }
// Distance from fuzzy_chunk before snapping to current chunk // Distance from fuzzy_chunk before snapping to current chunk
@ -38,7 +38,7 @@ pub struct RegionSubscription {
} }
impl Component for RegionSubscription { impl Component for RegionSubscription {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, DenseVecStorage<Self>>;
} }
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]

View File

@ -7,8 +7,7 @@ use common::{
}; };
use common_state::BlockChange; use common_state::BlockChange;
use hashbrown::HashMap; use hashbrown::HashMap;
use specs::{Component, Entity}; use specs::{Component, DenseVecStorage, Entity};
use specs_idvs::IdvStorage;
use tracing::warn; use tracing::warn;
use vek::{num_traits::ToPrimitive, Rgb, Vec3}; use vek::{num_traits::ToPrimitive, Rgb, Vec3};
@ -243,9 +242,9 @@ impl WireNode {
} }
impl Component for WiringElement { impl Component for WiringElement {
type Storage = IdvStorage<Self>; type Storage = DenseVecStorage<Self>;
} }
impl Component for Circuit { impl Component for Circuit {
type Storage = IdvStorage<Self>; type Storage = DenseVecStorage<Self>;
} }

View File

@ -80,7 +80,6 @@ egui_winit_platform = {version = "0.8", optional = true }
# ECS # ECS
specs = { version = "0.18", features = ["serde", "storage-event-control", "derive"] } specs = { version = "0.18", features = ["serde", "storage-event-control", "derive"] }
specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "c17abc638f23ef221ce7384c7dd77eef757b82f4" }
# Mathematics # Mathematics
vek = {version = "0.15.8", features = ["serde"]} vek = {version = "0.15.8", features = ["serde"]}

View File

@ -1,6 +1,5 @@
use common::{comp::Ori, outcome::HealthChangeInfo}; use common::{comp::Ori, outcome::HealthChangeInfo};
use specs::Component; use specs::{Component, VecStorage};
use specs_idvs::IdvStorage;
use vek::*; use vek::*;
// Floats over entity that has had a health change, rising up over time until it // Floats over entity that has had a health change, rising up over time until it
@ -24,7 +23,7 @@ pub struct HpFloaterList {
pub time_since_last_dmg_by_me: Option<f32>, pub time_since_last_dmg_by_me: Option<f32>,
} }
impl Component for HpFloaterList { impl Component for HpFloaterList {
type Storage = IdvStorage<Self>; type Storage = VecStorage<Self>;
} }
// Used for smooth interpolation of visual elements that are tied to entity // Used for smooth interpolation of visual elements that are tied to entity
@ -35,5 +34,5 @@ pub struct Interpolated {
pub ori: Ori, pub ori: Ori,
} }
impl Component for Interpolated { impl Component for Interpolated {
type Storage = IdvStorage<Self>; type Storage = VecStorage<Self>;
} }