Simulation: improve depsgraph integration
A simulation data block has an embedded node tree, which requires special handling in a couple of places. Some of those places were missing beforehand. This also adds a relation to make sure that the simulation is evaluated after animations on the embedded node tree are evaluated.
This commit is contained in:
parent
921c95ab5e
commit
750899fd31
|
@ -57,6 +57,7 @@
|
|||
#include "DNA_packedFile_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_sequence_types.h"
|
||||
#include "DNA_simulation_types.h"
|
||||
#include "DNA_world_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
@ -3240,6 +3241,12 @@ static void image_walk_id_all_users(
|
|||
if (scene->nodetree && scene->use_nodes && !skip_nested_nodes) {
|
||||
image_walk_ntree_all_users(scene->nodetree, &scene->id, customdata, callback);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_SIM: {
|
||||
Simulation *simulation = (Simulation *)id;
|
||||
image_walk_ntree_all_users(simulation->nodetree, &simulation->id, customdata, callback);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -412,6 +412,8 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
|
|||
return ELEM(id_type_used, ID_MA);
|
||||
case ID_VO:
|
||||
return ELEM(id_type_used, ID_MA);
|
||||
case ID_SIM:
|
||||
return ELEM(id_type_used, ID_OB, ID_IM);
|
||||
case ID_IM:
|
||||
case ID_VF:
|
||||
case ID_TXT:
|
||||
|
@ -422,7 +424,6 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
|
|||
case ID_PAL:
|
||||
case ID_PC:
|
||||
case ID_CF:
|
||||
case ID_SIM:
|
||||
/* Those types never use/reference other IDs... */
|
||||
return false;
|
||||
case ID_IP:
|
||||
|
|
|
@ -2493,6 +2493,7 @@ ID *BKE_node_tree_find_owner_ID(Main *bmain, struct bNodeTree *ntree)
|
|||
&bmain->textures,
|
||||
&bmain->scenes,
|
||||
&bmain->linestyles,
|
||||
&bmain->simulations,
|
||||
NULL};
|
||||
|
||||
for (int i = 0; lists[i] != NULL; i++) {
|
||||
|
|
|
@ -1780,8 +1780,10 @@ void DepsgraphNodeBuilder::build_simulation(Simulation *simulation)
|
|||
return;
|
||||
}
|
||||
add_id_node(&simulation->id);
|
||||
build_idproperties(simulation->id.properties);
|
||||
build_animdata(&simulation->id);
|
||||
build_parameters(&simulation->id);
|
||||
build_nodetree(simulation->nodetree);
|
||||
|
||||
Simulation *simulation_cow = get_cow_datablock(simulation);
|
||||
Scene *scene_cow = get_cow_datablock(scene_);
|
||||
|
|
|
@ -2601,13 +2601,21 @@ void DepsgraphRelationBuilder::build_simulation(Simulation *simulation)
|
|||
if (built_map_.checkIsBuiltAndTag(simulation)) {
|
||||
return;
|
||||
}
|
||||
build_idproperties(simulation->id.properties);
|
||||
build_animdata(&simulation->id);
|
||||
build_parameters(&simulation->id);
|
||||
|
||||
OperationKey simulation_update_key(
|
||||
build_nodetree(simulation->nodetree);
|
||||
build_nested_nodetree(&simulation->id, simulation->nodetree);
|
||||
|
||||
OperationKey simulation_eval_key(
|
||||
&simulation->id, NodeType::SIMULATION, OperationCode::SIMULATION_EVAL);
|
||||
TimeSourceKey time_src_key;
|
||||
add_relation(time_src_key, simulation_update_key, "TimeSrc -> Simulation");
|
||||
add_relation(time_src_key, simulation_eval_key, "TimeSrc -> Simulation");
|
||||
|
||||
OperationKey nodetree_key(
|
||||
&simulation->nodetree->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT);
|
||||
add_relation(nodetree_key, simulation_eval_key, "NodeTree -> Simulation", 0);
|
||||
}
|
||||
|
||||
void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
|
||||
|
|
|
@ -786,6 +786,7 @@ void DEG_graph_id_type_tag(Depsgraph *depsgraph, short id_type)
|
|||
DEG_graph_id_type_tag(depsgraph, ID_LA);
|
||||
DEG_graph_id_type_tag(depsgraph, ID_WO);
|
||||
DEG_graph_id_type_tag(depsgraph, ID_SCE);
|
||||
DEG_graph_id_type_tag(depsgraph, ID_SIM);
|
||||
}
|
||||
const int id_type_index = BKE_idtype_idcode_to_index(id_type);
|
||||
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
|
||||
|
|
|
@ -120,6 +120,7 @@ union NestedIDHackTempStorage {
|
|||
Scene scene;
|
||||
Tex tex;
|
||||
World world;
|
||||
Simulation simulation;
|
||||
};
|
||||
|
||||
/* Set nested owned ID pointers to nullptr. */
|
||||
|
@ -137,6 +138,7 @@ void nested_id_hack_discard_pointers(ID *id_cow)
|
|||
SPECIAL_CASE(ID_MA, Material, nodetree)
|
||||
SPECIAL_CASE(ID_TE, Tex, nodetree)
|
||||
SPECIAL_CASE(ID_WO, World, nodetree)
|
||||
SPECIAL_CASE(ID_SIM, Simulation, nodetree)
|
||||
|
||||
SPECIAL_CASE(ID_CU, Curve, key)
|
||||
SPECIAL_CASE(ID_LT, Lattice, key)
|
||||
|
@ -185,6 +187,7 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
|
|||
SPECIAL_CASE(ID_MA, Material, nodetree, material)
|
||||
SPECIAL_CASE(ID_TE, Tex, nodetree, tex)
|
||||
SPECIAL_CASE(ID_WO, World, nodetree, world)
|
||||
SPECIAL_CASE(ID_SIM, Simulation, nodetree, simulation)
|
||||
|
||||
SPECIAL_CASE(ID_CU, Curve, key, curve)
|
||||
SPECIAL_CASE(ID_LT, Lattice, key, lattice)
|
||||
|
@ -224,6 +227,7 @@ void nested_id_hack_restore_pointers(const ID *old_id, ID *new_id)
|
|||
SPECIAL_CASE(ID_SCE, Scene, nodetree)
|
||||
SPECIAL_CASE(ID_TE, Tex, nodetree)
|
||||
SPECIAL_CASE(ID_WO, World, nodetree)
|
||||
SPECIAL_CASE(ID_SIM, Simulation, nodetree)
|
||||
|
||||
SPECIAL_CASE(ID_CU, Curve, key)
|
||||
SPECIAL_CASE(ID_LT, Lattice, key)
|
||||
|
@ -261,6 +265,7 @@ void ntree_hack_remap_pointers(const Depsgraph *depsgraph, ID *id_cow)
|
|||
SPECIAL_CASE(ID_SCE, Scene, nodetree, bNodeTree)
|
||||
SPECIAL_CASE(ID_TE, Tex, nodetree, bNodeTree)
|
||||
SPECIAL_CASE(ID_WO, World, nodetree, bNodeTree)
|
||||
SPECIAL_CASE(ID_SIM, Simulation, nodetree, bNodeTree)
|
||||
|
||||
SPECIAL_CASE(ID_CU, Curve, key, Key)
|
||||
SPECIAL_CASE(ID_LT, Lattice, key, Key)
|
||||
|
|
|
@ -108,8 +108,7 @@ void update_simulation_in_depsgraph(Depsgraph *depsgraph,
|
|||
SimulationInfluences influences;
|
||||
RequiredStates required_states;
|
||||
|
||||
/* TODO: Use simulation_cow, but need to add depsgraph relations before that. */
|
||||
collect_simulation_influences(*simulation_orig, resources, influences, required_states);
|
||||
collect_simulation_influences(*simulation_cow, resources, influences, required_states);
|
||||
|
||||
if (current_frame == 1) {
|
||||
reinitialize_empty_simulation_states(simulation_orig, required_states);
|
||||
|
|
Loading…
Reference in New Issue