Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/depsgraph.cc
| Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | if (!id_node) { | ||||
| id_hash.add_new(id, id_node); | id_hash.add_new(id, id_node); | ||||
| id_nodes.append(id_node); | id_nodes.append(id_node); | ||||
| id_type_exist[BKE_idtype_idcode_to_index(GS(id->name))] = 1; | id_type_exist[BKE_idtype_idcode_to_index(GS(id->name))] = 1; | ||||
| } | } | ||||
| return id_node; | return id_node; | ||||
| } | } | ||||
| void Depsgraph::clear_id_nodes_conditional(const std::function<bool(ID_Type id_type)> &filter) | template<typename FilterFunc> | ||||
| static void clear_id_nodes_conditional(Depsgraph::IDDepsNodes *id_nodes, const FilterFunc &filter) | |||||
| { | { | ||||
| for (IDNode *id_node : id_nodes) { | for (IDNode *id_node : *id_nodes) { | ||||
| if (id_node->id_cow == nullptr) { | if (id_node->id_cow == nullptr) { | ||||
| /* This means builder "stole" ownership of the copy-on-written | /* This means builder "stole" ownership of the copy-on-written | ||||
| * datablock for her own dirty needs. */ | * datablock for her own dirty needs. */ | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (!deg_copy_on_write_is_expanded(id_node->id_cow)) { | if (!deg_copy_on_write_is_expanded(id_node->id_cow)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| const ID_Type id_type = GS(id_node->id_cow->name); | const ID_Type id_type = GS(id_node->id_cow->name); | ||||
| if (filter(id_type)) { | if (filter(id_type)) { | ||||
| id_node->destroy(); | id_node->destroy(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void Depsgraph::clear_id_nodes() | void Depsgraph::clear_id_nodes() | ||||
| { | { | ||||
| /* Free memory used by ID nodes. */ | /* Free memory used by ID nodes. */ | ||||
| /* Stupid workaround to ensure we free IDs in a proper order. */ | /* Stupid workaround to ensure we free IDs in a proper order. */ | ||||
| clear_id_nodes_conditional([](ID_Type id_type) { return id_type == ID_SCE; }); | clear_id_nodes_conditional(&id_nodes, [](ID_Type id_type) { return id_type == ID_SCE; }); | ||||
| clear_id_nodes_conditional([](ID_Type id_type) { return id_type != ID_PA; }); | clear_id_nodes_conditional(&id_nodes, [](ID_Type id_type) { return id_type != ID_PA; }); | ||||
| for (IDNode *id_node : id_nodes) { | for (IDNode *id_node : id_nodes) { | ||||
| delete id_node; | delete id_node; | ||||
| } | } | ||||
| /* Clear containers. */ | /* Clear containers. */ | ||||
| id_hash.clear(); | id_hash.clear(); | ||||
| id_nodes.clear(); | id_nodes.clear(); | ||||
| /* Clear physics relation caches. */ | /* Clear physics relation caches. */ | ||||
| ▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines | |||||