From 746dddc0673d7261f19b1e056e90e6e3a49ef33a Mon Sep 17 00:00:00 2001 From: reduz Date: Fri, 13 May 2022 15:04:37 +0200 Subject: Replace most uses of Map by HashMap * Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated! --- modules/raycast/lightmap_raycaster.cpp | 6 +++--- modules/raycast/lightmap_raycaster.h | 6 +++--- modules/raycast/raycast_occlusion_cull.cpp | 2 +- modules/raycast/raycast_occlusion_cull.h | 4 ++-- modules/raycast/static_raycaster.cpp | 6 +++--- modules/raycast/static_raycaster.h | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) (limited to 'modules/raycast') diff --git a/modules/raycast/lightmap_raycaster.cpp b/modules/raycast/lightmap_raycaster.cpp index ecc256bff9..7e7c3f9067 100644 --- a/modules/raycast/lightmap_raycaster.cpp +++ b/modules/raycast/lightmap_raycaster.cpp @@ -152,8 +152,8 @@ void LightmapRaycasterEmbree::commit() { rtcCommitScene(embree_scene); } -void LightmapRaycasterEmbree::set_mesh_filter(const Set &p_mesh_ids) { - for (Set::Element *E = p_mesh_ids.front(); E; E = E->next()) { +void LightmapRaycasterEmbree::set_mesh_filter(const RBSet &p_mesh_ids) { + for (RBSet::Element *E = p_mesh_ids.front(); E; E = E->next()) { rtcDisableGeometry(rtcGetGeometry(embree_scene, E->get())); } rtcCommitScene(embree_scene); @@ -161,7 +161,7 @@ void LightmapRaycasterEmbree::set_mesh_filter(const Set &p_mesh_ids) { } void LightmapRaycasterEmbree::clear_mesh_filter() { - for (Set::Element *E = filter_meshes.front(); E; E = E->next()) { + for (RBSet::Element *E = filter_meshes.front(); E; E = E->next()) { rtcEnableGeometry(rtcGetGeometry(embree_scene, E->get())); } rtcCommitScene(embree_scene); diff --git a/modules/raycast/lightmap_raycaster.h b/modules/raycast/lightmap_raycaster.h index c420e617e5..4c52758fd8 100644 --- a/modules/raycast/lightmap_raycaster.h +++ b/modules/raycast/lightmap_raycaster.h @@ -52,8 +52,8 @@ private: static void filter_function(const struct RTCFilterFunctionNArguments *p_args); - Map alpha_textures; - Set filter_meshes; + HashMap alpha_textures; + RBSet filter_meshes; public: virtual bool intersect(Ray &p_ray) override; @@ -64,7 +64,7 @@ public: virtual void set_mesh_alpha_texture(Ref p_alpha_texture, unsigned int p_id) override; virtual void commit() override; - virtual void set_mesh_filter(const Set &p_mesh_ids) override; + virtual void set_mesh_filter(const RBSet &p_mesh_ids) override; virtual void clear_mesh_filter() override; static LightmapRaycaster *create_embree_raycaster(); diff --git a/modules/raycast/raycast_occlusion_cull.cpp b/modules/raycast/raycast_occlusion_cull.cpp index f49cd08698..c165354c7b 100644 --- a/modules/raycast/raycast_occlusion_cull.cpp +++ b/modules/raycast/raycast_occlusion_cull.cpp @@ -223,7 +223,7 @@ void RaycastOcclusionCull::occluder_set_mesh(RID p_occluder, const PackedVector3 occluder->vertices = p_vertices; occluder->indices = p_indices; - for (Set::Element *E = occluder->users.front(); E; E = E->next()) { + for (RBSet::Element *E = occluder->users.front(); E; E = E->next()) { RID scenario_rid = E->get().scenario; RID instance_rid = E->get().instance; ERR_CONTINUE(!scenarios.has(scenario_rid)); diff --git a/modules/raycast/raycast_occlusion_cull.h b/modules/raycast/raycast_occlusion_cull.h index 8453c5341d..779f6fb3c4 100644 --- a/modules/raycast/raycast_occlusion_cull.h +++ b/modules/raycast/raycast_occlusion_cull.h @@ -101,7 +101,7 @@ private: struct Occluder { PackedVector3Array vertices; PackedInt32Array indices; - Set users; + RBSet users; }; struct OccluderInstance { @@ -136,7 +136,7 @@ private: int current_scene_idx = 0; HashMap instances; - Set dirty_instances; // To avoid duplicates + RBSet dirty_instances; // To avoid duplicates LocalVector dirty_instances_array; // To iterate and split into threads LocalVector removed_instances; diff --git a/modules/raycast/static_raycaster.cpp b/modules/raycast/static_raycaster.cpp index 9df6d5ff43..f2e944a82d 100644 --- a/modules/raycast/static_raycaster.cpp +++ b/modules/raycast/static_raycaster.cpp @@ -94,8 +94,8 @@ void StaticRaycasterEmbree::commit() { rtcCommitScene(embree_scene); } -void StaticRaycasterEmbree::set_mesh_filter(const Set &p_mesh_ids) { - for (Set::Element *E = p_mesh_ids.front(); E; E = E->next()) { +void StaticRaycasterEmbree::set_mesh_filter(const RBSet &p_mesh_ids) { + for (RBSet::Element *E = p_mesh_ids.front(); E; E = E->next()) { rtcDisableGeometry(rtcGetGeometry(embree_scene, E->get())); } rtcCommitScene(embree_scene); @@ -103,7 +103,7 @@ void StaticRaycasterEmbree::set_mesh_filter(const Set &p_mesh_ids) { } void StaticRaycasterEmbree::clear_mesh_filter() { - for (Set::Element *E = filter_meshes.front(); E; E = E->next()) { + for (RBSet::Element *E = filter_meshes.front(); E; E = E->next()) { rtcEnableGeometry(rtcGetGeometry(embree_scene, E->get())); } rtcCommitScene(embree_scene); diff --git a/modules/raycast/static_raycaster.h b/modules/raycast/static_raycaster.h index cce19ba60d..b52b5bccfc 100644 --- a/modules/raycast/static_raycaster.h +++ b/modules/raycast/static_raycaster.h @@ -41,7 +41,7 @@ private: static RTCDevice embree_device; RTCScene embree_scene; - Set filter_meshes; + RBSet filter_meshes; public: virtual bool intersect(Ray &p_ray) override; @@ -50,7 +50,7 @@ public: virtual void add_mesh(const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices, unsigned int p_id) override; virtual void commit() override; - virtual void set_mesh_filter(const Set &p_mesh_ids) override; + virtual void set_mesh_filter(const RBSet &p_mesh_ids) override; virtual void clear_mesh_filter() override; static StaticRaycaster *create_embree_raycaster(); -- cgit v1.2.3