diff options
author | reduz <reduzio@gmail.com> | 2022-05-19 17:00:06 +0200 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2022-05-20 22:40:38 +0200 |
commit | 45af29da8095af16729955117a165d23e77cd740 (patch) | |
tree | 0436c59187702466a73d05caf9688a58e5935afd /servers/physics_2d | |
parent | 410893ad0fb6f0d7d774b6529581d886defd6cf0 (diff) |
Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
Diffstat (limited to 'servers/physics_2d')
-rw-r--r-- | servers/physics_2d/godot_area_2d.h | 4 | ||||
-rw-r--r-- | servers/physics_2d/godot_physics_server_2d.cpp | 2 | ||||
-rw-r--r-- | servers/physics_2d/godot_physics_server_2d.h | 2 | ||||
-rw-r--r-- | servers/physics_2d/godot_space_2d.cpp | 2 | ||||
-rw-r--r-- | servers/physics_2d/godot_space_2d.h | 4 |
5 files changed, 7 insertions, 7 deletions
diff --git a/servers/physics_2d/godot_area_2d.h b/servers/physics_2d/godot_area_2d.h index b825ea5cdb..35dad9d2c3 100644 --- a/servers/physics_2d/godot_area_2d.h +++ b/servers/physics_2d/godot_area_2d.h @@ -93,7 +93,7 @@ class GodotArea2D : public GodotCollisionObject2D { HashMap<BodyKey, BodyState, BodyKey> monitored_bodies; HashMap<BodyKey, BodyState, BodyKey> monitored_areas; - RBSet<GodotConstraint2D *> constraints; + HashSet<GodotConstraint2D *> constraints; virtual void _shapes_changed() override; void _queue_monitor_update(); @@ -142,7 +142,7 @@ public: _FORCE_INLINE_ void add_constraint(GodotConstraint2D *p_constraint) { constraints.insert(p_constraint); } _FORCE_INLINE_ void remove_constraint(GodotConstraint2D *p_constraint) { constraints.erase(p_constraint); } - _FORCE_INLINE_ const RBSet<GodotConstraint2D *> &get_constraints() const { return constraints; } + _FORCE_INLINE_ const HashSet<GodotConstraint2D *> &get_constraints() const { return constraints; } _FORCE_INLINE_ void clear_constraints() { constraints.clear(); } void set_monitorable(bool p_monitorable); diff --git a/servers/physics_2d/godot_physics_server_2d.cpp b/servers/physics_2d/godot_physics_server_2d.cpp index cb829e5d91..99e68de07c 100644 --- a/servers/physics_2d/godot_physics_server_2d.cpp +++ b/servers/physics_2d/godot_physics_server_2d.cpp @@ -1212,7 +1212,7 @@ void GodotPhysicsServer2D::free(RID p_rid) { GodotSpace2D *space = space_owner.get_or_null(p_rid); while (space->get_objects().size()) { - GodotCollisionObject2D *co = static_cast<GodotCollisionObject2D *>(space->get_objects().front()->get()); + GodotCollisionObject2D *co = static_cast<GodotCollisionObject2D *>(*space->get_objects().begin()); co->set_space(nullptr); } diff --git a/servers/physics_2d/godot_physics_server_2d.h b/servers/physics_2d/godot_physics_server_2d.h index 55a7b39b9e..2af6e5c97c 100644 --- a/servers/physics_2d/godot_physics_server_2d.h +++ b/servers/physics_2d/godot_physics_server_2d.h @@ -56,7 +56,7 @@ class GodotPhysicsServer2D : public PhysicsServer2D { bool flushing_queries = false; GodotStep2D *stepper = nullptr; - RBSet<const GodotSpace2D *> active_spaces; + HashSet<const GodotSpace2D *> active_spaces; mutable RID_PtrOwner<GodotShape2D, true> shape_owner; mutable RID_PtrOwner<GodotSpace2D, true> space_owner; diff --git a/servers/physics_2d/godot_space_2d.cpp b/servers/physics_2d/godot_space_2d.cpp index 0a7859d86a..166ec3049e 100644 --- a/servers/physics_2d/godot_space_2d.cpp +++ b/servers/physics_2d/godot_space_2d.cpp @@ -1073,7 +1073,7 @@ void GodotSpace2D::remove_object(GodotCollisionObject2D *p_object) { objects.erase(p_object); } -const RBSet<GodotCollisionObject2D *> &GodotSpace2D::get_objects() const { +const HashSet<GodotCollisionObject2D *> &GodotSpace2D::get_objects() const { return objects; } diff --git a/servers/physics_2d/godot_space_2d.h b/servers/physics_2d/godot_space_2d.h index e8b05fa4f9..b6fc48bd70 100644 --- a/servers/physics_2d/godot_space_2d.h +++ b/servers/physics_2d/godot_space_2d.h @@ -92,7 +92,7 @@ private: static void *_broadphase_pair(GodotCollisionObject2D *A, int p_subindex_A, GodotCollisionObject2D *B, int p_subindex_B, void *p_self); static void _broadphase_unpair(GodotCollisionObject2D *A, int p_subindex_A, GodotCollisionObject2D *B, int p_subindex_B, void *p_data, void *p_self); - RBSet<GodotCollisionObject2D *> objects; + HashSet<GodotCollisionObject2D *> objects; GodotArea2D *area = nullptr; @@ -156,7 +156,7 @@ public: void add_object(GodotCollisionObject2D *p_object); void remove_object(GodotCollisionObject2D *p_object); - const RBSet<GodotCollisionObject2D *> &get_objects() const; + const HashSet<GodotCollisionObject2D *> &get_objects() const; _FORCE_INLINE_ int get_solver_iterations() const { return solver_iterations; } _FORCE_INLINE_ real_t get_contact_recycle_radius() const { return contact_recycle_radius; } |