Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hhhxiao/BedrockOptimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhxiao committed Sep 5, 2022
2 parents 4d887c6 + d346166 commit 0c9c53b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/opts/RedstoneOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,25 @@ void optPendingRemoves(CircuitSceneGraph *graph) {
auto updateComponent = allComp.second.get();

// 不是消费者才尝试移除
// updateComponent->removeSource(pos, targetComp);
// 这里可以对中继器和比较器做一些特判,不是这些原件可以吧remove source挪动到后面
// 中继器的不能挪到后面是因为中继器的这个函数还会移除侧边原件,这些原件不是信号源
// 暂时先这么写,有空再优化
updateComponent->removeSource(pos, targetComp);
auto &ss = dAccess<std::vector<ComponentItem>, 8>(updateComponent);
auto ssit = ss.begin();
size_t res = 0;
while (ssit != ss.end()) {
if (ssit->mPos == pos || ssit->mComponent == targetComp) {
graph->scheduleRelationshipUpdate(allComp.first, updateComponent);
ss.erase(ssit);
++res;
} else {
++ssit;
++res;
}
}
if (res != 0) {
updateComponent->removeSource(pos, targetComp);
}
// if (res != 0) {
// updateComponent->removeSource(pos, targetComp);
// }
}
}

Expand Down

0 comments on commit 0c9c53b

Please sign in to comment.