Core: Add ObjectRuntime::last_update transform, geometry and shading #115196
@ -452,6 +452,8 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob);
|
|||||||
void BKE_object_eval_uber_transform(Depsgraph *depsgraph, Object *object);
|
void BKE_object_eval_uber_transform(Depsgraph *depsgraph, Object *object);
|
||||||
void BKE_object_eval_uber_data(Depsgraph *depsgraph, Scene *scene, Object *ob);
|
void BKE_object_eval_uber_data(Depsgraph *depsgraph, Scene *scene, Object *ob);
|
||||||
|
|
||||||
|
void BKE_object_eval_shading(Depsgraph *depsgraph, Object *ob);
|
||||||
|
|
||||||
void BKE_object_eval_light_linking(Depsgraph *depsgraph, Object *object);
|
void BKE_object_eval_light_linking(Depsgraph *depsgraph, Object *object);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,6 +121,11 @@ struct ObjectRuntime {
|
|||||||
|
|
||||||
Array<float3x3, 0> crazyspace_deform_imats;
|
Array<float3x3, 0> crazyspace_deform_imats;
|
||||||
Array<float3, 0> crazyspace_deform_cos;
|
Array<float3, 0> crazyspace_deform_cos;
|
||||||
|
|
||||||
|
/* The Depsgraph::update_count when this object was last updated. */
|
||||||
|
uint64_t last_update_transform = 0;
|
||||||
|
uint64_t last_update_geometry = 0;
|
||||||
|
uint64_t last_update_shading = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace blender::bke
|
} // namespace blender::bke
|
||||||
|
@ -137,6 +137,8 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob)
|
|||||||
else {
|
else {
|
||||||
ob->transflag &= ~OB_NEG_SCALE;
|
ob->transflag &= ~OB_NEG_SCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ob->runtime->last_update_transform = DEG_get_update_count(depsgraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
|
void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
|
||||||
@ -339,6 +341,8 @@ void BKE_object_eval_uber_data(Depsgraph *depsgraph, Scene *scene, Object *ob)
|
|||||||
BLI_assert(ob->type != OB_ARMATURE);
|
BLI_assert(ob->type != OB_ARMATURE);
|
||||||
BKE_object_handle_data_update(depsgraph, scene, ob);
|
BKE_object_handle_data_update(depsgraph, scene, ob);
|
||||||
BKE_object_batch_cache_dirty_tag(ob);
|
BKE_object_batch_cache_dirty_tag(ob);
|
||||||
|
|
||||||
|
ob->runtime->last_update_geometry = DEG_get_update_count(depsgraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_object_eval_ptcache_reset(Depsgraph *depsgraph, Scene *scene, Object *object)
|
void BKE_object_eval_ptcache_reset(Depsgraph *depsgraph, Scene *scene, Object *object)
|
||||||
@ -458,3 +462,10 @@ void BKE_object_eval_light_linking(Depsgraph *depsgraph, Object *object)
|
|||||||
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
|
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
|
||||||
deg::light_linking::eval_runtime_data(depsgraph, *object);
|
deg::light_linking::eval_runtime_data(depsgraph, *object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BKE_object_eval_shading(Depsgraph *depsgraph, Object *object)
|
||||||
|
{
|
||||||
|
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
|
||||||
|
|
||||||
|
object->runtime->last_update_shading = DEG_get_update_count(depsgraph);
|
||||||
|
}
|
||||||
|
@ -211,6 +211,9 @@ bool DEG_is_active(const Depsgraph *depsgraph);
|
|||||||
void DEG_make_active(Depsgraph *depsgraph);
|
void DEG_make_active(Depsgraph *depsgraph);
|
||||||
void DEG_make_inactive(Depsgraph *depsgraph);
|
void DEG_make_inactive(Depsgraph *depsgraph);
|
||||||
|
|
||||||
|
/* Returns the number of times the graph has been evaluated. */
|
||||||
|
uint64_t DEG_get_update_count(const Depsgraph *depsgraph);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable the visibility optimization making it so IDs which affect hidden objects or disabled
|
* Disable the visibility optimization making it so IDs which affect hidden objects or disabled
|
||||||
* modifiers are still evaluated.
|
* modifiers are still evaluated.
|
||||||
|
@ -842,6 +842,8 @@ void DepsgraphNodeBuilder::build_object(int base_index,
|
|||||||
|
|
||||||
build_object_light_linking(object);
|
build_object_light_linking(object);
|
||||||
|
|
||||||
|
build_object_shading(object);
|
||||||
|
|
||||||
/* Synchronization back to original object. */
|
/* Synchronization back to original object. */
|
||||||
add_operation_node(&object->id,
|
add_operation_node(&object->id,
|
||||||
NodeType::SYNCHRONIZATION,
|
NodeType::SYNCHRONIZATION,
|
||||||
@ -1168,6 +1170,16 @@ void DepsgraphNodeBuilder::build_light_linking_collection(Collection *collection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DepsgraphNodeBuilder::build_object_shading(Object *object)
|
||||||
|
{
|
||||||
|
Object *object_cow = get_cow_datablock(object);
|
||||||
|
add_operation_node(
|
||||||
|
&object->id,
|
||||||
|
NodeType::SHADING,
|
||||||
|
OperationCode::SHADING,
|
||||||
|
[object_cow](::Depsgraph *depsgraph) { BKE_object_eval_shading(depsgraph, object_cow); });
|
||||||
|
}
|
||||||
|
|
||||||
void DepsgraphNodeBuilder::build_animdata(ID *id)
|
void DepsgraphNodeBuilder::build_animdata(ID *id)
|
||||||
{
|
{
|
||||||
/* Special handling for animated images/sequences. */
|
/* Special handling for animated images/sequences. */
|
||||||
@ -1652,6 +1664,9 @@ void DepsgraphNodeBuilder::build_object_data_geometry(Object *object)
|
|||||||
NodeType::BATCH_CACHE,
|
NodeType::BATCH_CACHE,
|
||||||
OperationCode::GEOMETRY_SELECT_UPDATE,
|
OperationCode::GEOMETRY_SELECT_UPDATE,
|
||||||
[object_cow](::Depsgraph *depsgraph) { BKE_object_select_update(depsgraph, object_cow); });
|
[object_cow](::Depsgraph *depsgraph) { BKE_object_select_update(depsgraph, object_cow); });
|
||||||
|
/* Shading (No-Op).
|
||||||
|
* Needed to allow the Material shading updates reach the Object. */
|
||||||
|
add_operation_node((ID *)object->data, NodeType::SHADING, OperationCode::SHADING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata)
|
void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata)
|
||||||
|
@ -195,6 +195,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
|
|||||||
virtual void build_object_transform(Object *object);
|
virtual void build_object_transform(Object *object);
|
||||||
virtual void build_object_constraints(Object *object);
|
virtual void build_object_constraints(Object *object);
|
||||||
virtual void build_object_pointcache(Object *object);
|
virtual void build_object_pointcache(Object *object);
|
||||||
|
virtual void build_object_shading(Object *object);
|
||||||
|
|
||||||
virtual void build_object_light_linking(Object *object);
|
virtual void build_object_light_linking(Object *object);
|
||||||
virtual void build_light_linking_collection(Collection *collection);
|
virtual void build_light_linking_collection(Collection *collection);
|
||||||
|
@ -1014,7 +1014,8 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
|
|||||||
Material ***materials_ptr = BKE_object_material_array_p(object);
|
Material ***materials_ptr = BKE_object_material_array_p(object);
|
||||||
if (materials_ptr != nullptr) {
|
if (materials_ptr != nullptr) {
|
||||||
short *num_materials_ptr = BKE_object_material_len_p(object);
|
short *num_materials_ptr = BKE_object_material_len_p(object);
|
||||||
build_materials(*materials_ptr, *num_materials_ptr);
|
ID *obdata = (ID *)object->data;
|
||||||
|
build_materials(obdata, *materials_ptr, *num_materials_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1034,6 +1035,8 @@ void DepsgraphRelationBuilder::build_object_data_light(Object *object)
|
|||||||
ComponentKey lamp_parameters_key(&lamp->id, NodeType::PARAMETERS);
|
ComponentKey lamp_parameters_key(&lamp->id, NodeType::PARAMETERS);
|
||||||
ComponentKey object_parameters_key(&object->id, NodeType::PARAMETERS);
|
ComponentKey object_parameters_key(&object->id, NodeType::PARAMETERS);
|
||||||
add_relation(lamp_parameters_key, object_parameters_key, "Light -> Object");
|
add_relation(lamp_parameters_key, object_parameters_key, "Light -> Object");
|
||||||
|
OperationKey object_shading_key(&object->id, NodeType::SHADING, OperationCode::SHADING);
|
||||||
|
add_relation(lamp_parameters_key, object_shading_key, "Light -> Object Shading");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object)
|
void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object)
|
||||||
@ -1043,6 +1046,8 @@ void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object)
|
|||||||
OperationKey probe_key(&probe->id, NodeType::PARAMETERS, OperationCode::LIGHT_PROBE_EVAL);
|
OperationKey probe_key(&probe->id, NodeType::PARAMETERS, OperationCode::LIGHT_PROBE_EVAL);
|
||||||
OperationKey object_key(&object->id, NodeType::PARAMETERS, OperationCode::LIGHT_PROBE_EVAL);
|
OperationKey object_key(&object->id, NodeType::PARAMETERS, OperationCode::LIGHT_PROBE_EVAL);
|
||||||
add_relation(probe_key, object_key, "LightProbe Update");
|
add_relation(probe_key, object_key, "LightProbe Update");
|
||||||
|
OperationKey object_shading_key(&object->id, NodeType::SHADING, OperationCode::SHADING);
|
||||||
|
add_relation(probe_key, object_shading_key, "LightProbe -> Object Shading");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_object_data_speaker(Object *object)
|
void DepsgraphRelationBuilder::build_object_data_speaker(Object *object)
|
||||||
@ -2499,7 +2504,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Materials. */
|
/* Materials. */
|
||||||
build_materials(object->mat, object->totcol);
|
build_materials(&object->id, object->mat, object->totcol);
|
||||||
/* Geometry collision. */
|
/* Geometry collision. */
|
||||||
if (ELEM(object->type, OB_MESH, OB_CURVES_LEGACY, OB_LATTICE)) {
|
if (ELEM(object->type, OB_MESH, OB_CURVES_LEGACY, OB_LATTICE)) {
|
||||||
// add geometry collider relations
|
// add geometry collider relations
|
||||||
@ -2564,6 +2569,10 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
|
|||||||
add_relation(object_data_select_key, object_select_key, "Data Selection -> Object Selection");
|
add_relation(object_data_select_key, object_select_key, "Data Selection -> Object Selection");
|
||||||
add_relation(
|
add_relation(
|
||||||
geom_key, object_select_key, "Object Geometry -> Select Update", RELATION_FLAG_NO_FLUSH);
|
geom_key, object_select_key, "Object Geometry -> Select Update", RELATION_FLAG_NO_FLUSH);
|
||||||
|
/* Shading. */
|
||||||
|
ComponentKey geometry_shading_key(obdata, NodeType::SHADING);
|
||||||
|
OperationKey object_shading_key(&object->id, NodeType::SHADING, OperationCode::SHADING);
|
||||||
|
add_relation(geometry_shading_key, object_shading_key, "Geometry Shading -> Object Shading");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
|
void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
|
||||||
@ -2953,8 +2962,14 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Recursively build graph for material */
|
/* Recursively build graph for material */
|
||||||
void DepsgraphRelationBuilder::build_material(Material *material)
|
void DepsgraphRelationBuilder::build_material(Material *material, ID *owner)
|
||||||
{
|
{
|
||||||
|
if (owner) {
|
||||||
|
ComponentKey material_key(&material->id, NodeType::SHADING);
|
||||||
|
OperationKey owner_shading_key(owner, NodeType::SHADING, OperationCode::SHADING);
|
||||||
|
add_relation(material_key, owner_shading_key, "Material -> Owner Shading");
|
||||||
|
}
|
||||||
|
|
||||||
if (built_map_.checkIsBuiltAndTag(material)) {
|
if (built_map_.checkIsBuiltAndTag(material)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2981,13 +2996,13 @@ void DepsgraphRelationBuilder::build_material(Material *material)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_materials(Material **materials, int num_materials)
|
void DepsgraphRelationBuilder::build_materials(ID *owner, Material **materials, int num_materials)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < num_materials; i++) {
|
for (int i = 0; i < num_materials; i++) {
|
||||||
if (materials[i] == nullptr) {
|
if (materials[i] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
build_material(materials[i]);
|
build_material(materials[i], owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,8 +231,8 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
|
|||||||
virtual void build_light(Light *lamp);
|
virtual void build_light(Light *lamp);
|
||||||
virtual void build_nodetree(bNodeTree *ntree);
|
virtual void build_nodetree(bNodeTree *ntree);
|
||||||
virtual void build_nodetree_socket(bNodeSocket *socket);
|
virtual void build_nodetree_socket(bNodeSocket *socket);
|
||||||
virtual void build_material(Material *ma);
|
virtual void build_material(Material *ma, ID *owner = nullptr);
|
||||||
virtual void build_materials(Material **materials, int num_materials);
|
virtual void build_materials(ID *owner, Material **materials, int num_materials);
|
||||||
virtual void build_freestyle_lineset(FreestyleLineSet *fls);
|
virtual void build_freestyle_lineset(FreestyleLineSet *fls);
|
||||||
virtual void build_freestyle_linestyle(FreestyleLineStyle *linestyle);
|
virtual void build_freestyle_linestyle(FreestyleLineStyle *linestyle);
|
||||||
virtual void build_texture(Tex *tex);
|
virtual void build_texture(Tex *tex);
|
||||||
|
@ -62,7 +62,8 @@ Depsgraph::Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluati
|
|||||||
use_visibility_optimization(true),
|
use_visibility_optimization(true),
|
||||||
is_evaluating(false),
|
is_evaluating(false),
|
||||||
is_render_pipeline_depsgraph(false),
|
is_render_pipeline_depsgraph(false),
|
||||||
use_editors_update(false)
|
use_editors_update(false),
|
||||||
|
update_count(0)
|
||||||
{
|
{
|
||||||
BLI_spin_init(&lock);
|
BLI_spin_init(&lock);
|
||||||
memset(id_type_updated, 0, sizeof(id_type_updated));
|
memset(id_type_updated, 0, sizeof(id_type_updated));
|
||||||
@ -344,3 +345,9 @@ void DEG_disable_visibility_optimization(Depsgraph *depsgraph)
|
|||||||
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
|
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
|
||||||
deg_graph->use_visibility_optimization = false;
|
deg_graph->use_visibility_optimization = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t DEG_get_update_count(const Depsgraph *depsgraph)
|
||||||
|
{
|
||||||
|
const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(depsgraph);
|
||||||
|
return deg_graph->update_count;
|
||||||
|
}
|
||||||
|
@ -171,6 +171,9 @@ struct Depsgraph {
|
|||||||
|
|
||||||
light_linking::Cache light_linking_cache;
|
light_linking::Cache light_linking_cache;
|
||||||
|
|
||||||
|
/* The number of times this graph has been evaluated. */
|
||||||
|
uint64_t update_count;
|
||||||
|
|
||||||
MEM_CXX_CLASS_ALLOC_FUNCS("Depsgraph");
|
MEM_CXX_CLASS_ALLOC_FUNCS("Depsgraph");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -387,6 +387,8 @@ void deg_evaluate_on_refresh(Depsgraph *graph)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
graph->update_count++;
|
||||||
|
|
||||||
graph->debug.begin_graph_evaluation();
|
graph->debug.begin_graph_evaluation();
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
|
Loading…
Reference in New Issue
Block a user