@@ -343,7 +343,7 @@ namespace noodle {
343343 provider.node_create (kind, new_node);
344344
345345 CanvasGroup* cn = nullptr ;
346- if (group_node.id != ln_Node_null ().id && registry. valid (group_node. id ) )
346+ if (group_node.id != ln_Node_null ().id )
347347 {
348348 auto it = provider._canvasNodes .find (group_node);
349349 if (it != provider._canvasNodes .end ())
@@ -561,7 +561,6 @@ namespace noodle {
561561 for (auto en : cn.nodes )
562562 {
563563 provider.node_delete (en);
564- registry.destroy (en.id );
565564 }
566565 cn.nodes .clear ();
567566 }
@@ -580,7 +579,6 @@ namespace noodle {
580579 if (gnl != provider._nodeGraphics .end ())
581580 provider._nodeGraphics .erase (gnl);
582581
583- registry.destroy (input_node.id );
584582 edit.incr_work_epoch ();
585583 break ;
586584 }
@@ -597,33 +595,29 @@ namespace noodle {
597595 case WorkType::ClearScene:
598596 {
599597 for (auto & noodleNode : provider._noodleNodes ) {
600- entt::entity en = noodleNode.second .id .id ;
601- if (registry.valid (en)) {
602- auto cg = provider._canvasNodes .find (noodleNode.second .id );
603- if (cg != provider._canvasNodes .end ())
598+ auto cg = provider._canvasNodes .find (noodleNode.second .id );
599+ if (cg != provider._canvasNodes .end ())
600+ {
601+ // if it's canvas, clear the contained nodes
602+ for (auto en : cg->second .nodes )
604603 {
605- // if it's canvas, clear the contained nodes
606- for (auto en : cg->second .nodes )
607- {
608- provider.node_delete (en);
609- registry.destroy (en.id );
610- }
611- cg->second .nodes .clear ();
604+ provider.node_delete (en);
612605 }
613- else
606+ cg->second .nodes .clear ();
607+ }
608+ else
609+ {
610+ auto gnl = provider._nodeGraphics .find (noodleNode.second .id );
611+ if (gnl != provider._nodeGraphics .end () && gnl->second .parent_canvas )
614612 {
615- auto gnl = provider._nodeGraphics .find (noodleNode.second .id );
616- if (gnl != provider._nodeGraphics .end () && gnl->second .parent_canvas )
617- {
618- // if it's on a canvas, remove it.
619- // / @TODO it probably makes sense to recurse the graph and
620- // / delete from the leaves, rather than using this more complex algorithm
621- auto it = gnl->second .parent_canvas ->nodes .find (noodleNode.second .id );
622- if (it != gnl->second .parent_canvas ->nodes .end ())
623- gnl->second .parent_canvas ->nodes .erase (it);
624- }
625- provider.node_delete (noodleNode.second .id );
613+ // if it's on a canvas, remove it.
614+ // / @TODO it probably makes sense to recurse the graph and
615+ // / delete from the leaves, rather than using this more complex algorithm
616+ auto it = gnl->second .parent_canvas ->nodes .find (noodleNode.second .id );
617+ if (it != gnl->second .parent_canvas ->nodes .end ())
618+ gnl->second .parent_canvas ->nodes .erase (it);
626619 }
620+ provider.node_delete (noodleNode.second .id );
627621 }
628622 }
629623
@@ -720,8 +714,6 @@ namespace noodle {
720714 if (!pin_id.valid )
721715 return ;
722716
723- entt::registry& registry = provider.registry ();
724-
725717 auto pin_it = provider._noodlePins .find (pin_id);
726718 if (pin_it == provider._noodlePins .end ())
727719 return ;
@@ -907,17 +899,12 @@ namespace noodle {
907899
908900 void EditState::edit_node (Provider& provider, CanvasGroup& root, ln_Node node, std::vector<Work>& pending_work)
909901 {
910- entt::registry& reg = provider.registry ();
911- if (!reg.valid (node.id ))
912- {
902+ auto it = provider._noodleNodes .find (node);
903+ if (it == provider._noodleNodes .end ()) {
913904 selected_node = ln_Node_null ();
914905 return ;
915906 }
916907
917- auto it = provider._noodleNodes .find (node);
918- if (it == provider._noodleNodes .end ())
919- return ;
920-
921908 char buff[256 ];
922909 sprintf (buff, " %s Node" , it->second .name .c_str ());
923910 ImGui::OpenPopup (buff);
@@ -1041,8 +1028,6 @@ namespace noodle {
10411028
10421029 void lay_out_pins (Provider& provider)
10431030 {
1044- entt::registry& registry = provider.registry ();
1045-
10461031 // may the counting begin
10471032
10481033 for (auto & node : provider._noodleNodes )
@@ -1067,9 +1052,6 @@ namespace noodle {
10671052 // calculate column heights
10681053 for (const ln_Pin& entity : node.second .pins )
10691054 {
1070- if (!registry.valid (entity.id ))
1071- continue ;
1072-
10731055 auto pin_it = provider._noodlePins .find (entity);
10741056 if (pin_it == provider._noodlePins .end ())
10751057 continue ;
@@ -1169,8 +1151,6 @@ namespace noodle {
11691151
11701152 void ProviderHarness::State::update_hovers (Provider& provider)
11711153 {
1172- entt::registry& registry = provider.registry ();
1173-
11741154 // bool currently_hovered = _hover.node_id != ln_Node_null().id;
11751155
11761156 // refresh highlights if dragging a wire, or if a node is not being dragged
@@ -1451,15 +1431,12 @@ namespace noodle {
14511431 }
14521432 }
14531433
1454- entt::registry& registry = provider.registry ();
1455-
14561434 // / @TODO consolidate the redundant logic here for testing connections
14571435 if (mouse.dragging && mouse.dragging_wire )
14581436 {
14591437 // if dragging a wire, check for disallowed connections so they wire can turn red
14601438 hover.valid_connection = true ;
1461- if (hover.originating_pin_id .id != ln_Pin_null ().id && hover.pin_id .id != ln_Pin_null ().id &&
1462- registry.valid (hover.originating_pin_id .id ) && registry.valid (hover.pin_id .id ))
1439+ if (hover.originating_pin_id .id != ln_Pin_null ().id && hover.pin_id .id != ln_Pin_null ().id )
14631440 {
14641441 auto from_pin_it = provider._noodlePins .find (hover.originating_pin_id );
14651442 auto to_pin_it = provider._noodlePins .find (hover.pin_id );
@@ -1486,8 +1463,7 @@ namespace noodle {
14861463 else if (!mouse.dragging && mouse.dragging_wire )
14871464 {
14881465 hover.valid_connection = true ;
1489- if (hover.originating_pin_id .id != ln_Pin_null ().id && hover.pin_id .id != ln_Pin_null ().id &&
1490- registry.valid (hover.originating_pin_id .id ) && registry.valid (hover.pin_id .id ))
1466+ if (hover.originating_pin_id .id != ln_Pin_null ().id && hover.pin_id .id != ln_Pin_null ().id )
14911467 {
14921468 auto from_pin_it = provider._noodlePins .find (hover.originating_pin_id );
14931469 auto to_pin_it = provider._noodlePins .find (hover.pin_id );
@@ -1788,9 +1764,6 @@ namespace noodle {
17881764 // Node Body / Drawing / Profiler //
17891765 // /////////////////////////////////////
17901766
1791- if (!registry.valid (edit._device_node .id ))
1792- edit._device_node = ln_Node_null ();
1793-
17941767 total_profile_duration = provider.node_get_timing (edit._device_node );
17951768
17961769 for (auto & node: provider._noodleNodes )
@@ -2083,7 +2056,6 @@ namespace noodle {
20832056 return res;
20842057 };
20852058
2086- entt::registry& reg = provider.registry ();
20872059 std::ofstream file (path, std::ios::binary);
20882060
20892061 file << " // " << path;
@@ -2101,10 +2073,6 @@ void create_graph(lab::AudioContext& ctx)
21012073)" ;
21022074 for (auto & node : provider._noodleNodes )
21032075 {
2104- entt::entity node_entity = node.second .id .id ;
2105- if (!reg.valid (node_entity))
2106- continue ;
2107-
21082076 std::string node_name_clean = clean_name (node.second .name );
21092077 file << " \n //--------------------\n // Node: "
21102078 << node.second .name << " Kind: " << node.second .kind << " \n " ;
@@ -2121,9 +2089,6 @@ void create_graph(lab::AudioContext& ctx)
21212089 file << " // Pins:\n\n " ;
21222090 for (const ln_Pin& entity : node.second .pins )
21232091 {
2124- if (!reg.valid (entity.id ))
2125- continue ;
2126-
21272092 auto pin_it = provider._noodlePins .find (entity);
21282093 if (pin_it == provider._noodlePins .end ())
21292094 continue ;
@@ -2216,16 +2181,12 @@ void create_graph(lab::AudioContext& ctx)
22162181
22172182 // Note: this code uses \n because std::endl has other behaviors
22182183 using lab::noodle::NoodlePin;
2219- entt::registry& reg = provider. registry ();
2184+
22202185 std::ofstream file (path, std::ios::binary);
22212186 file << " #!LabSoundGraphToy\n " ;
22222187 file << " # " << path << " \n " ;
22232188 for (auto & node : provider._noodleNodes )
22242189 {
2225- entt::entity node_entity = node.second .id .id ;
2226- if (!reg.valid (node_entity))
2227- continue ;
2228-
22292190 file << " node: " << node.second .kind << " name: " << node.second .name << " \n " ;
22302191
22312192 auto gnl_it = provider._nodeGraphics .find (node.second .id );
@@ -2237,9 +2198,6 @@ void create_graph(lab::AudioContext& ctx)
22372198
22382199 for (const ln_Pin& entity : node.second .pins )
22392200 {
2240- if (!reg.valid (entity.id ))
2241- continue ;
2242-
22432201 auto pin_it = provider._noodlePins .find (entity);
22442202 if (pin_it == provider._noodlePins .end ())
22452203 continue ;
@@ -2312,8 +2270,6 @@ void create_graph(lab::AudioContext& ctx)
23122270 using StringBuffer = rapidjson::StringBuffer;
23132271 using Writer = rapidjson::Writer<StringBuffer>;
23142272
2315- entt::registry& reg = provider.registry ();
2316-
23172273 StringBuffer s;
23182274 Writer writer (s);
23192275 writer.StartObject ();
@@ -2324,10 +2280,6 @@ void create_graph(lab::AudioContext& ctx)
23242280
23252281 for (auto & node : provider._noodleNodes )
23262282 {
2327- entt::entity node_entity = node.second .id .id ;
2328- if (!reg.valid (node_entity))
2329- continue ;
2330-
23312283 writer.StartObject ();
23322284
23332285 writer.Key (" name" );
@@ -2350,9 +2302,6 @@ void create_graph(lab::AudioContext& ctx)
23502302 writer.StartArray ();
23512303 for (const ln_Pin& entity : node.second .pins )
23522304 {
2353- if (!reg.valid (entity.id ))
2354- continue ;
2355-
23562305 auto pin_it = provider._noodlePins .find (entity);
23572306 if (pin_it == provider._noodlePins .end ())
23582307 continue ;
0 commit comments