Impl Default for a few structs
This commit is contained in:
committed by
Sébastien Crozet
parent
936f655c67
commit
7aa94e994f
@@ -1,7 +1,7 @@
|
|||||||
use crate::data::arena::Index;
|
use crate::data::arena::Index;
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, Default)]
|
||||||
/// A container for data associated to item existing into another Arena.
|
/// A container for data associated to item existing into another Arena.
|
||||||
pub struct Coarena<T> {
|
pub struct Coarena<T> {
|
||||||
data: Vec<(u32, T)>,
|
data: Vec<(u32, T)>,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ impl PubSubCursor {
|
|||||||
|
|
||||||
/// A pub-sub queue.
|
/// A pub-sub queue.
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Default)]
|
||||||
pub struct PubSub<T> {
|
pub struct PubSub<T> {
|
||||||
deleted_messages: u32,
|
deleted_messages: u32,
|
||||||
deleted_offsets: u32,
|
deleted_offsets: u32,
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ pub struct CCDSolver {
|
|||||||
query_pipeline: QueryPipeline,
|
query_pipeline: QueryPipeline,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for CCDSolver {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CCDSolver {
|
impl CCDSolver {
|
||||||
/// Initializes a new CCD solver
|
/// Initializes a new CCD solver
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::math::Real;
|
|||||||
/// Structure responsible for maintaining the set of active rigid-bodies, and
|
/// Structure responsible for maintaining the set of active rigid-bodies, and
|
||||||
/// putting non-moving rigid-bodies to sleep to save computation times.
|
/// putting non-moving rigid-bodies to sleep to save computation times.
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Default)]
|
||||||
pub struct IslandManager {
|
pub struct IslandManager {
|
||||||
pub(crate) active_dynamic_set: Vec<RigidBodyHandle>,
|
pub(crate) active_dynamic_set: Vec<RigidBodyHandle>,
|
||||||
pub(crate) active_kinematic_set: Vec<RigidBodyHandle>,
|
pub(crate) active_kinematic_set: Vec<RigidBodyHandle>,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ pub(crate) type JointIndex = usize;
|
|||||||
pub(crate) type JointGraphEdge = crate::data::graph::Edge<Joint>;
|
pub(crate) type JointGraphEdge = crate::data::graph::Edge<Joint>;
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Default)]
|
||||||
/// A set of joints that can be handled by a physics `World`.
|
/// A set of joints that can be handled by a physics `World`.
|
||||||
pub struct JointSet {
|
pub struct JointSet {
|
||||||
rb_graph_ids: Coarena<RigidBodyGraphIndex>,
|
rb_graph_ids: Coarena<RigidBodyGraphIndex>,
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ pub struct RigidBody {
|
|||||||
pub user_data: u128,
|
pub user_data: u128,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for RigidBody {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl RigidBody {
|
impl RigidBody {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ impl BodyPair {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Default)]
|
||||||
/// A set of rigid bodies that can be handled by a physics pipeline.
|
/// A set of rigid bodies that can be handled by a physics pipeline.
|
||||||
pub struct RigidBodySet {
|
pub struct RigidBodySet {
|
||||||
// NOTE: the pub(crate) are needed by the broad phase
|
// NOTE: the pub(crate) are needed by the broad phase
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ pub struct IslandSolver {
|
|||||||
position_solver: PositionSolver,
|
position_solver: PositionSolver,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for IslandSolver {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl IslandSolver {
|
impl IslandSolver {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -133,6 +133,12 @@ pub struct ParallelIslandSolver {
|
|||||||
thread: ThreadContext,
|
thread: ThreadContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for ParallelIslandSolver {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ParallelIslandSolver {
|
impl ParallelIslandSolver {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -116,6 +116,12 @@ pub struct BroadPhase {
|
|||||||
reporting: HashMap<(u32, u32), bool>, // Workspace
|
reporting: HashMap<(u32, u32), bool>, // Workspace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for BroadPhase {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BroadPhase {
|
impl BroadPhase {
|
||||||
/// Create a new empty broad-phase.
|
/// Create a new empty broad-phase.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
|||||||
@@ -87,6 +87,12 @@ pub struct SAPProxies {
|
|||||||
pub first_free: SAPProxyIndex,
|
pub first_free: SAPProxyIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for SAPProxies {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SAPProxies {
|
impl SAPProxies {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::geometry::{ColliderChanges, ColliderHandle};
|
|||||||
use std::ops::{Index, IndexMut};
|
use std::ops::{Index, IndexMut};
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Default)]
|
||||||
/// A set of colliders that can be handled by a physics `World`.
|
/// A set of colliders that can be handled by a physics `World`.
|
||||||
pub struct ColliderSet {
|
pub struct ColliderSet {
|
||||||
pub(crate) colliders: Arena<Collider>,
|
pub(crate) colliders: Arena<Collider>,
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ pub struct InteractionGraph<N, E> {
|
|||||||
pub(crate) graph: Graph<N, E>,
|
pub(crate) graph: Graph<N, E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N: Copy, E> Default for InteractionGraph<N, E> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<N: Copy, E> InteractionGraph<N, E> {
|
impl<N: Copy, E> InteractionGraph<N, E> {
|
||||||
/// Creates a new empty collection of collision objects.
|
/// Creates a new empty collection of collision objects.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ pub struct NarrowPhase {
|
|||||||
|
|
||||||
pub(crate) type ContactManifoldIndex = usize;
|
pub(crate) type ContactManifoldIndex = usize;
|
||||||
|
|
||||||
|
impl Default for NarrowPhase {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl NarrowPhase {
|
impl NarrowPhase {
|
||||||
/// Creates a new empty narrow-phase.
|
/// Creates a new empty narrow-phase.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ fn check_pipeline_send_sync() {
|
|||||||
do_test::<CollisionPipeline>();
|
do_test::<CollisionPipeline>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for CollisionPipeline {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CollisionPipeline {
|
impl CollisionPipeline {
|
||||||
/// Initializes a new physics pipeline.
|
/// Initializes a new physics pipeline.
|
||||||
pub fn new() -> CollisionPipeline {
|
pub fn new() -> CollisionPipeline {
|
||||||
|
|||||||
Reference in New Issue
Block a user