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;
|
||||
|
||||
#[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.
|
||||
pub struct Coarena<T> {
|
||||
data: Vec<(u32, T)>,
|
||||
|
||||
@@ -38,7 +38,7 @@ impl PubSubCursor {
|
||||
|
||||
/// A pub-sub queue.
|
||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct PubSub<T> {
|
||||
deleted_messages: u32,
|
||||
deleted_offsets: u32,
|
||||
|
||||
@@ -29,6 +29,12 @@ pub struct CCDSolver {
|
||||
query_pipeline: QueryPipeline,
|
||||
}
|
||||
|
||||
impl Default for CCDSolver {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl CCDSolver {
|
||||
/// Initializes a new CCD solver
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::math::Real;
|
||||
/// Structure responsible for maintaining the set of active rigid-bodies, and
|
||||
/// putting non-moving rigid-bodies to sleep to save computation times.
|
||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct IslandManager {
|
||||
pub(crate) active_dynamic_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>;
|
||||
|
||||
#[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`.
|
||||
pub struct JointSet {
|
||||
rb_graph_ids: Coarena<RigidBodyGraphIndex>,
|
||||
|
||||
@@ -36,6 +36,12 @@ pub struct RigidBody {
|
||||
pub user_data: u128,
|
||||
}
|
||||
|
||||
impl Default for RigidBody {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl RigidBody {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -28,7 +28,7 @@ impl BodyPair {
|
||||
}
|
||||
|
||||
#[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.
|
||||
pub struct RigidBodySet {
|
||||
// NOTE: the pub(crate) are needed by the broad phase
|
||||
|
||||
@@ -19,6 +19,12 @@ pub struct IslandSolver {
|
||||
position_solver: PositionSolver,
|
||||
}
|
||||
|
||||
impl Default for IslandSolver {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl IslandSolver {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -133,6 +133,12 @@ pub struct ParallelIslandSolver {
|
||||
thread: ThreadContext,
|
||||
}
|
||||
|
||||
impl Default for ParallelIslandSolver {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl ParallelIslandSolver {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -116,6 +116,12 @@ pub struct BroadPhase {
|
||||
reporting: HashMap<(u32, u32), bool>, // Workspace
|
||||
}
|
||||
|
||||
impl Default for BroadPhase {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl BroadPhase {
|
||||
/// Create a new empty broad-phase.
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -87,6 +87,12 @@ pub struct SAPProxies {
|
||||
pub first_free: SAPProxyIndex,
|
||||
}
|
||||
|
||||
impl Default for SAPProxies {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SAPProxies {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::geometry::{ColliderChanges, ColliderHandle};
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
#[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`.
|
||||
pub struct ColliderSet {
|
||||
pub(crate) colliders: Arena<Collider>,
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct InteractionGraph<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> {
|
||||
/// Creates a new empty collection of collision objects.
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -62,6 +62,12 @@ pub struct NarrowPhase {
|
||||
|
||||
pub(crate) type ContactManifoldIndex = usize;
|
||||
|
||||
impl Default for NarrowPhase {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl NarrowPhase {
|
||||
/// Creates a new empty narrow-phase.
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -33,6 +33,12 @@ fn check_pipeline_send_sync() {
|
||||
do_test::<CollisionPipeline>();
|
||||
}
|
||||
|
||||
impl Default for CollisionPipeline {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl CollisionPipeline {
|
||||
/// Initializes a new physics pipeline.
|
||||
pub fn new() -> CollisionPipeline {
|
||||
|
||||
Reference in New Issue
Block a user