diff --git a/include/edyn/parallel/island_coordinator.hpp b/include/edyn/parallel/island_coordinator.hpp index 5745891b..d5327221 100644 --- a/include/edyn/parallel/island_coordinator.hpp +++ b/include/edyn/parallel/island_coordinator.hpp @@ -43,7 +43,6 @@ class island_coordinator final { void refresh_dirty_entities(); bool should_split_island(entt::entity source_island_entity); void sync(); - void clear_dangling_non_procedural_nodes(); public: island_coordinator(island_coordinator const&) = delete; @@ -110,7 +109,6 @@ class island_coordinator final { std::vector m_new_graph_nodes; std::vector m_new_graph_edges; std::vector m_islands_to_split; - entt::sparse_set m_possibly_dangling_np_nodes; bool m_importing_delta {false}; double m_timestamp; diff --git a/include/edyn/parallel/island_worker.hpp b/include/edyn/parallel/island_worker.hpp index ba3f90ce..ac4ae870 100644 --- a/include/edyn/parallel/island_worker.hpp +++ b/include/edyn/parallel/island_worker.hpp @@ -61,7 +61,6 @@ class island_worker final { bool should_split(); void sync(); void sync_dirty(); - void clear_dangling_non_procedural_nodes(); void update(); public: @@ -126,8 +125,6 @@ class island_worker final { std::vector m_new_polyhedron_shapes; std::vector m_new_compound_shapes; - entt::sparse_set m_possibly_dangling_np_nodes; - bool m_clearing_dangling_np_nodes {false}; std::atomic m_reschedule_counter {0}; diff --git a/src/edyn/parallel/island_coordinator.cpp b/src/edyn/parallel/island_coordinator.cpp index 246206b7..6962b71d 100644 --- a/src/edyn/parallel/island_coordinator.cpp +++ b/src/edyn/parallel/island_coordinator.cpp @@ -89,15 +89,6 @@ void island_coordinator::on_destroy_graph_node(entt::registry ®istry, entt::e void island_coordinator::on_destroy_graph_edge(entt::registry ®istry, entt::entity entity) { auto &edge = registry.get(entity); auto &graph = registry.ctx(); - - auto nodes = graph.edge_node_entities(edge.edge_index); - - for (auto node : std::array{nodes.first, nodes.second}) { - if (!registry.any_of(node) && !m_possibly_dangling_np_nodes.contains(node)) { - m_possibly_dangling_np_nodes.emplace(node); - } - } - graph.remove_edge(edge.edge_index); } @@ -780,44 +771,6 @@ void island_coordinator::sync() { } } -void island_coordinator::clear_dangling_non_procedural_nodes() { - // Remove non-procedural entities from islands that have no procedural - // entities connecting to them. - auto &graph = m_registry->ctx(); - - for (auto entity : m_possibly_dangling_np_nodes) { - if (!m_registry->valid(entity)) { - continue; - } - - auto &resident = m_registry->get(entity); - auto node_index = m_registry->get(entity).node_index; - - for (auto island_entity : resident.island_entities) { - auto &island = m_registry->get(island_entity); - bool has_procedural_neighbor = false; - - for (auto node_entity : island.nodes) { - if (m_registry->any_of(node_entity) && - graph.has_adjacency(node_index, m_registry->get(node_entity).node_index)) { - has_procedural_neighbor = true; - break; - } - } - - if (!has_procedural_neighbor) { - island.nodes.remove(entity); - resident.island_entities.remove(island_entity); - - auto &ctx = m_island_ctx_map.at(island_entity); - ctx->m_entity_map.erase_loc(entity); - } - } - } - - m_possibly_dangling_np_nodes.clear(); -} - void island_coordinator::update() { m_timestamp = performance_time(); @@ -828,7 +781,6 @@ void island_coordinator::update() { init_new_nodes_and_edges(); refresh_dirty_entities(); sync(); - clear_dangling_non_procedural_nodes(); split_islands(); } diff --git a/src/edyn/parallel/island_worker.cpp b/src/edyn/parallel/island_worker.cpp index 65f150c5..3bbb6647 100644 --- a/src/edyn/parallel/island_worker.cpp +++ b/src/edyn/parallel/island_worker.cpp @@ -171,8 +171,7 @@ void island_worker::on_destroy_graph_node(entt::registry ®istry, entt::entity graph.remove_node(node.node_index); if (!m_importing_delta && - !m_splitting.load(std::memory_order_relaxed) && - !m_clearing_dangling_np_nodes) { + !m_splitting.load(std::memory_order_relaxed)) { m_delta_builder->destroyed(entity); } @@ -183,23 +182,14 @@ void island_worker::on_destroy_graph_node(entt::registry ®istry, entt::entity void island_worker::on_destroy_graph_edge(entt::registry ®istry, entt::entity entity) { auto &graph = registry.ctx(); - auto &edge = registry.get(entity); - auto nodes = graph.edge_node_entities(edge.edge_index); - - for (auto node : std::array{nodes.first, nodes.second}) { - if (!registry.any_of(node) && !m_possibly_dangling_np_nodes.contains(node)) { - m_possibly_dangling_np_nodes.emplace(node); - } - } if (!m_destroying_node) { graph.remove_edge(edge.edge_index); } if (!m_importing_delta && - !m_splitting.load(std::memory_order_relaxed) && - !m_clearing_dangling_np_nodes) { + !m_splitting.load(std::memory_order_relaxed)) { m_delta_builder->destroyed(entity); } @@ -377,38 +367,6 @@ void island_worker::sync_dirty() { m_registry.clear(); } -void island_worker::clear_dangling_non_procedural_nodes() { - m_clearing_dangling_np_nodes = true; - - auto &graph = m_registry.ctx(); - auto node_view = m_registry.view(); - auto proc_view = m_registry.view(); - - for (auto entity : m_possibly_dangling_np_nodes) { - if (!m_registry.valid(entity)) { - continue; - } - - auto node_index = node_view.get(entity).node_index; - bool has_procedural_neighbor = false; - - for (auto node_entity : m_registry.view()) { - if (proc_view.contains(node_entity) && - graph.has_adjacency(node_index, node_view.get(node_entity).node_index)) { - has_procedural_neighbor = true; - break; - } - } - - if (!has_procedural_neighbor) { - m_registry.destroy(entity); - } - } - - m_possibly_dangling_np_nodes.clear(); - m_clearing_dangling_np_nodes = false; -} - void island_worker::update() { switch (m_state) { case state::init: @@ -617,7 +575,6 @@ void island_worker::finish_step() { (*settings.external_system_post_step)(m_registry); } - clear_dangling_non_procedural_nodes(); sync(); m_state = state::step;