getRestructuredMobjectList method
Implementation
List<Mobject> getRestructuredMobjectList(
List<Mobject> mobjects, List<Mobject> toRemove) {
var newMobjects = <Mobject>[];
void addSafeMobjectsFromList(
List<Mobject> mobjects, Set<Mobject> setToRemove) {
for (var mob in mobjects) {
if (setToRemove.contains(mob)) {
continue;
}
var intersect = setToRemove.intersection(mob.getFamily().toSet());
if (intersect.isNotEmpty) {
addSafeMobjectsFromList(mob.submobjects, intersect);
} else {
newMobjects.add(mob);
}
}
}
addSafeMobjectsFromList(mobjects, toRemove.toSet());
return newMobjects;
}