Running again after weak_ptr refactoring. No connecting of nodes atm. Copy/Paste might not work, too.
This commit is contained in:
+8
-10
@@ -22,7 +22,7 @@ namespace VISEQ::SIGNAL {
|
||||
|
||||
public:
|
||||
SignalManager() {}
|
||||
SignalManager(GraphManager *gm, std::mutex *mutex) : mutex(mutex), gm(gm) {}
|
||||
SignalManager(std::shared_ptr<GraphManager> gm, std::mutex *mutex) : mutex(mutex), gm(gm) {}
|
||||
|
||||
std::shared_ptr<SignalManager> getPtr(){
|
||||
return shared_from_this();
|
||||
@@ -31,7 +31,7 @@ namespace VISEQ::SIGNAL {
|
||||
VISEQ::MIDI::Midi midi;
|
||||
|
||||
std::mutex *mutex;
|
||||
GraphManager *gm;
|
||||
std::shared_ptr<GraphManager> gm;
|
||||
|
||||
VEC_SPTR_Signal signals;
|
||||
|
||||
@@ -79,16 +79,16 @@ namespace VISEQ::SIGNAL {
|
||||
signals.back()->start = node;
|
||||
}
|
||||
|
||||
void rerouteSignal(VEC_SPTR_Node nodes, VEC_SPTR_Node adjacent_nodes){
|
||||
void rerouteSignal(VEC_SPTR_Node nodes, VEC_WPTR_Node adjacent_nodes){
|
||||
auto reroute_signals = signals | RANGE_FILTER([nodes](SIGNAL::SPTR_Signal s){return std::ranges::contains(nodes, s->next.lock());});
|
||||
|
||||
for(auto s : reroute_signals){
|
||||
float dist = 10000000;
|
||||
SPTR_Node next_node;
|
||||
for(auto n : adjacent_nodes){
|
||||
if(n->position.dist(s->position) < dist) {
|
||||
dist = n->position.dist(s->position);
|
||||
next_node = n;
|
||||
if(n.lock()->position.dist(s->position) < dist) {
|
||||
dist = n.lock()->position.dist(s->position);
|
||||
next_node = n.lock();
|
||||
}
|
||||
}
|
||||
s->next = next_node;
|
||||
@@ -158,10 +158,8 @@ namespace VISEQ::SIGNAL {
|
||||
}
|
||||
mutex->unlock();
|
||||
}
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(SignalManager, signals)
|
||||
|
||||
};
|
||||
|
||||
inline void to_json(json& j, const SignalManager& G){
|
||||
j = json{{"signals", G.signals}};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user