Depsgraph: Remove object-level visibility from geometry builders
Continuation of the D13404 which finished the design of not having geometry-level nodes dependent on object-level. Differential Revision: https://developer.blender.org/D13405
This commit is contained in:
@@ -199,9 +199,7 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
|
|||||||
nullptr, OperationCode::OPERATION, "", -1);
|
nullptr, OperationCode::OPERATION, "", -1);
|
||||||
/* Pin the node so that it and its relations are preserved by the unused nodes/relations
|
/* Pin the node so that it and its relations are preserved by the unused nodes/relations
|
||||||
* deletion. This is mainly to make it easier to debug visibility. */
|
* deletion. This is mainly to make it easier to debug visibility. */
|
||||||
/* NOTE: Keep un-pinned for the 3.0 release. This way we are more sure that side effects of the
|
visibility_operation->flag |= OperationFlag::DEPSOP_FLAG_PINNED;
|
||||||
* change is minimal outside of the dependency graph area. */
|
|
||||||
// visibility_operation->flag |= OperationFlag::DEPSOP_FLAG_PINNED;
|
|
||||||
graph_->operations.append(visibility_operation);
|
graph_->operations.append(visibility_operation);
|
||||||
}
|
}
|
||||||
return id_node;
|
return id_node;
|
||||||
@@ -589,11 +587,7 @@ void DepsgraphNodeBuilder::build_id(ID *id)
|
|||||||
case ID_HA:
|
case ID_HA:
|
||||||
case ID_PT:
|
case ID_PT:
|
||||||
case ID_VO:
|
case ID_VO:
|
||||||
/* TODO(sergey): Get visibility from a "parent" somehow.
|
build_object_data_geometry_datablock(id);
|
||||||
*
|
|
||||||
* NOTE: Similarly to above, we don't want false-positives on
|
|
||||||
* visibility. */
|
|
||||||
build_object_data_geometry_datablock(id, false);
|
|
||||||
break;
|
break;
|
||||||
case ID_SPK:
|
case ID_SPK:
|
||||||
build_speaker((Speaker *)id);
|
build_speaker((Speaker *)id);
|
||||||
@@ -769,32 +763,28 @@ void DepsgraphNodeBuilder::build_object(int base_index,
|
|||||||
if (object->modifiers.first != nullptr) {
|
if (object->modifiers.first != nullptr) {
|
||||||
BuilderWalkUserData data;
|
BuilderWalkUserData data;
|
||||||
data.builder = this;
|
data.builder = this;
|
||||||
data.is_parent_visible = is_visible;
|
|
||||||
BKE_modifiers_foreach_ID_link(object, modifier_walk, &data);
|
BKE_modifiers_foreach_ID_link(object, modifier_walk, &data);
|
||||||
}
|
}
|
||||||
/* Grease Pencil Modifiers. */
|
/* Grease Pencil Modifiers. */
|
||||||
if (object->greasepencil_modifiers.first != nullptr) {
|
if (object->greasepencil_modifiers.first != nullptr) {
|
||||||
BuilderWalkUserData data;
|
BuilderWalkUserData data;
|
||||||
data.builder = this;
|
data.builder = this;
|
||||||
data.is_parent_visible = is_visible;
|
|
||||||
BKE_gpencil_modifiers_foreach_ID_link(object, modifier_walk, &data);
|
BKE_gpencil_modifiers_foreach_ID_link(object, modifier_walk, &data);
|
||||||
}
|
}
|
||||||
/* Shader FX. */
|
/* Shader FX. */
|
||||||
if (object->shader_fx.first != nullptr) {
|
if (object->shader_fx.first != nullptr) {
|
||||||
BuilderWalkUserData data;
|
BuilderWalkUserData data;
|
||||||
data.builder = this;
|
data.builder = this;
|
||||||
data.is_parent_visible = is_visible;
|
|
||||||
BKE_shaderfx_foreach_ID_link(object, modifier_walk, &data);
|
BKE_shaderfx_foreach_ID_link(object, modifier_walk, &data);
|
||||||
}
|
}
|
||||||
/* Constraints. */
|
/* Constraints. */
|
||||||
if (object->constraints.first != nullptr) {
|
if (object->constraints.first != nullptr) {
|
||||||
BuilderWalkUserData data;
|
BuilderWalkUserData data;
|
||||||
data.builder = this;
|
data.builder = this;
|
||||||
data.is_parent_visible = is_visible;
|
|
||||||
BKE_constraints_id_loop(&object->constraints, constraint_walk, &data);
|
BKE_constraints_id_loop(&object->constraints, constraint_walk, &data);
|
||||||
}
|
}
|
||||||
/* Object data. */
|
/* Object data. */
|
||||||
build_object_data(object, is_visible);
|
build_object_data(object);
|
||||||
/* Parameters, used by both drivers/animation and also to inform dependency
|
/* Parameters, used by both drivers/animation and also to inform dependency
|
||||||
* from object's data. */
|
* from object's data. */
|
||||||
build_parameters(&object->id);
|
build_parameters(&object->id);
|
||||||
@@ -897,7 +887,7 @@ void DepsgraphNodeBuilder::build_object_instance_collection(Object *object, bool
|
|||||||
is_parent_collection_visible_ = is_current_parent_collection_visible;
|
is_parent_collection_visible_ = is_current_parent_collection_visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphNodeBuilder::build_object_data(Object *object, bool is_object_visible)
|
void DepsgraphNodeBuilder::build_object_data(Object *object)
|
||||||
{
|
{
|
||||||
if (object->data == nullptr) {
|
if (object->data == nullptr) {
|
||||||
return;
|
return;
|
||||||
@@ -914,14 +904,14 @@ void DepsgraphNodeBuilder::build_object_data(Object *object, bool is_object_visi
|
|||||||
case OB_HAIR:
|
case OB_HAIR:
|
||||||
case OB_POINTCLOUD:
|
case OB_POINTCLOUD:
|
||||||
case OB_VOLUME:
|
case OB_VOLUME:
|
||||||
build_object_data_geometry(object, is_object_visible);
|
build_object_data_geometry(object);
|
||||||
break;
|
break;
|
||||||
case OB_ARMATURE:
|
case OB_ARMATURE:
|
||||||
if (ID_IS_LINKED(object) && object->proxy_from != nullptr) {
|
if (ID_IS_LINKED(object) && object->proxy_from != nullptr) {
|
||||||
build_proxy_rig(object, is_object_visible);
|
build_proxy_rig(object);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
build_rig(object, is_object_visible);
|
build_rig(object);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OB_LAMP:
|
case OB_LAMP:
|
||||||
@@ -1472,7 +1462,7 @@ void DepsgraphNodeBuilder::build_shapekeys(Key *key)
|
|||||||
|
|
||||||
/* ObData Geometry Evaluation */
|
/* ObData Geometry Evaluation */
|
||||||
/* XXX: what happens if the datablock is shared! */
|
/* XXX: what happens if the datablock is shared! */
|
||||||
void DepsgraphNodeBuilder::build_object_data_geometry(Object *object, bool is_object_visible)
|
void DepsgraphNodeBuilder::build_object_data_geometry(Object *object)
|
||||||
{
|
{
|
||||||
OperationNode *op_node;
|
OperationNode *op_node;
|
||||||
Scene *scene_cow = get_cow_datablock(scene_);
|
Scene *scene_cow = get_cow_datablock(scene_);
|
||||||
@@ -1494,7 +1484,7 @@ void DepsgraphNodeBuilder::build_object_data_geometry(Object *object, bool is_ob
|
|||||||
/* Point caches. */
|
/* Point caches. */
|
||||||
build_object_pointcache(object);
|
build_object_pointcache(object);
|
||||||
/* Geometry. */
|
/* Geometry. */
|
||||||
build_object_data_geometry_datablock((ID *)object->data, is_object_visible);
|
build_object_data_geometry_datablock((ID *)object->data);
|
||||||
build_dimensions(object);
|
build_dimensions(object);
|
||||||
/* Batch cache. */
|
/* Batch cache. */
|
||||||
add_operation_node(
|
add_operation_node(
|
||||||
@@ -1504,7 +1494,7 @@ void DepsgraphNodeBuilder::build_object_data_geometry(Object *object, bool is_ob
|
|||||||
[object_cow](::Depsgraph *depsgraph) { BKE_object_select_update(depsgraph, object_cow); });
|
[object_cow](::Depsgraph *depsgraph) { BKE_object_select_update(depsgraph, object_cow); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool is_object_visible)
|
void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata)
|
||||||
{
|
{
|
||||||
if (built_map_.checkIsBuiltAndTag(obdata)) {
|
if (built_map_.checkIsBuiltAndTag(obdata)) {
|
||||||
return;
|
return;
|
||||||
@@ -1548,17 +1538,15 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool
|
|||||||
BKE_curve_eval_geometry(depsgraph, (Curve *)obdata_cow);
|
BKE_curve_eval_geometry(depsgraph, (Curve *)obdata_cow);
|
||||||
});
|
});
|
||||||
op_node->set_as_entry();
|
op_node->set_as_entry();
|
||||||
/* Make sure objects used for bevel.taper are in the graph.
|
|
||||||
* NOTE: This objects might be not linked to the scene. */
|
|
||||||
Curve *cu = (Curve *)obdata;
|
Curve *cu = (Curve *)obdata;
|
||||||
if (cu->bevobj != nullptr) {
|
if (cu->bevobj != nullptr) {
|
||||||
build_object(-1, cu->bevobj, DEG_ID_LINKED_INDIRECTLY, is_object_visible);
|
build_object(-1, cu->bevobj, DEG_ID_LINKED_INDIRECTLY, false);
|
||||||
}
|
}
|
||||||
if (cu->taperobj != nullptr) {
|
if (cu->taperobj != nullptr) {
|
||||||
build_object(-1, cu->taperobj, DEG_ID_LINKED_INDIRECTLY, is_object_visible);
|
build_object(-1, cu->taperobj, DEG_ID_LINKED_INDIRECTLY, false);
|
||||||
}
|
}
|
||||||
if (cu->textoncurve != nullptr) {
|
if (cu->textoncurve != nullptr) {
|
||||||
build_object(-1, cu->textoncurve, DEG_ID_LINKED_INDIRECTLY, is_object_visible);
|
build_object(-1, cu->textoncurve, DEG_ID_LINKED_INDIRECTLY, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2121,10 +2109,7 @@ void DepsgraphNodeBuilder::modifier_walk(void *user_data,
|
|||||||
}
|
}
|
||||||
switch (GS(id->name)) {
|
switch (GS(id->name)) {
|
||||||
case ID_OB:
|
case ID_OB:
|
||||||
/* Special case for object, so we take owner visibility into
|
data->builder->build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY, false);
|
||||||
* account. */
|
|
||||||
data->builder->build_object(
|
|
||||||
-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY, data->is_parent_visible);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
data->builder->build_id(id);
|
data->builder->build_id(id);
|
||||||
@@ -2144,10 +2129,7 @@ void DepsgraphNodeBuilder::constraint_walk(bConstraint * /*con*/,
|
|||||||
}
|
}
|
||||||
switch (GS(id->name)) {
|
switch (GS(id->name)) {
|
||||||
case ID_OB:
|
case ID_OB:
|
||||||
/* Special case for object, so we take owner visibility into
|
data->builder->build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY, false);
|
||||||
* account. */
|
|
||||||
data->builder->build_object(
|
|
||||||
-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY, data->is_parent_visible);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
data->builder->build_id(id);
|
data->builder->build_id(id);
|
||||||
|
|||||||
@@ -186,20 +186,17 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
|
|||||||
virtual void build_object_flags(int base_index,
|
virtual void build_object_flags(int base_index,
|
||||||
Object *object,
|
Object *object,
|
||||||
eDepsNode_LinkedState_Type linked_state);
|
eDepsNode_LinkedState_Type linked_state);
|
||||||
virtual void build_object_data(Object *object, bool is_object_visible);
|
virtual void build_object_data(Object *object);
|
||||||
virtual void build_object_data_camera(Object *object);
|
virtual void build_object_data_camera(Object *object);
|
||||||
virtual void build_object_data_geometry(Object *object, bool is_object_visible);
|
virtual void build_object_data_geometry(Object *object);
|
||||||
virtual void build_object_data_geometry_datablock(ID *obdata, bool is_object_visible);
|
virtual void build_object_data_geometry_datablock(ID *obdata);
|
||||||
virtual void build_object_data_light(Object *object);
|
virtual void build_object_data_light(Object *object);
|
||||||
virtual void build_object_data_lightprobe(Object *object);
|
virtual void build_object_data_lightprobe(Object *object);
|
||||||
virtual void build_object_data_speaker(Object *object);
|
virtual void build_object_data_speaker(Object *object);
|
||||||
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_pose_constraints(Object *object,
|
virtual void build_pose_constraints(Object *object, bPoseChannel *pchan, int pchan_index);
|
||||||
bPoseChannel *pchan,
|
|
||||||
int pchan_index,
|
|
||||||
bool is_object_visible);
|
|
||||||
virtual void build_rigidbody(Scene *scene);
|
virtual void build_rigidbody(Scene *scene);
|
||||||
virtual void build_particle_systems(Object *object, bool is_object_visible);
|
virtual void build_particle_systems(Object *object, bool is_object_visible);
|
||||||
virtual void build_particle_settings(ParticleSettings *part);
|
virtual void build_particle_settings(ParticleSettings *part);
|
||||||
@@ -227,8 +224,8 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
|
|||||||
virtual void build_dimensions(Object *object);
|
virtual void build_dimensions(Object *object);
|
||||||
virtual void build_ik_pose(Object *object, bPoseChannel *pchan, bConstraint *con);
|
virtual void build_ik_pose(Object *object, bPoseChannel *pchan, bConstraint *con);
|
||||||
virtual void build_splineik_pose(Object *object, bPoseChannel *pchan, bConstraint *con);
|
virtual void build_splineik_pose(Object *object, bPoseChannel *pchan, bConstraint *con);
|
||||||
virtual void build_rig(Object *object, bool is_object_visible);
|
virtual void build_rig(Object *object);
|
||||||
virtual void build_proxy_rig(Object *object, bool is_object_visible);
|
virtual void build_proxy_rig(Object *object);
|
||||||
virtual void build_armature(bArmature *armature);
|
virtual void build_armature(bArmature *armature);
|
||||||
virtual void build_armature_bones(ListBase *bones);
|
virtual void build_armature_bones(ListBase *bones);
|
||||||
virtual void build_shapekeys(Key *key);
|
virtual void build_shapekeys(Key *key);
|
||||||
@@ -284,8 +281,6 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
|
|||||||
|
|
||||||
struct BuilderWalkUserData {
|
struct BuilderWalkUserData {
|
||||||
DepsgraphNodeBuilder *builder;
|
DepsgraphNodeBuilder *builder;
|
||||||
/* Denotes whether object the walk is invoked from is visible. */
|
|
||||||
bool is_parent_visible;
|
|
||||||
};
|
};
|
||||||
static void modifier_walk(void *user_data,
|
static void modifier_walk(void *user_data,
|
||||||
struct Object *object,
|
struct Object *object,
|
||||||
|
|||||||
@@ -58,13 +58,11 @@ namespace blender::deg {
|
|||||||
|
|
||||||
void DepsgraphNodeBuilder::build_pose_constraints(Object *object,
|
void DepsgraphNodeBuilder::build_pose_constraints(Object *object,
|
||||||
bPoseChannel *pchan,
|
bPoseChannel *pchan,
|
||||||
int pchan_index,
|
int pchan_index)
|
||||||
bool is_object_visible)
|
|
||||||
{
|
{
|
||||||
/* Pull indirect dependencies via constraints. */
|
/* Pull indirect dependencies via constraints. */
|
||||||
BuilderWalkUserData data;
|
BuilderWalkUserData data;
|
||||||
data.builder = this;
|
data.builder = this;
|
||||||
data.is_parent_visible = is_object_visible;
|
|
||||||
BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data);
|
BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data);
|
||||||
|
|
||||||
/* Create node for constraint stack. */
|
/* Create node for constraint stack. */
|
||||||
@@ -147,7 +145,7 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Pose/Armature Bones Graph */
|
/* Pose/Armature Bones Graph */
|
||||||
void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible)
|
void DepsgraphNodeBuilder::build_rig(Object *object)
|
||||||
{
|
{
|
||||||
bArmature *armature = (bArmature *)object->data;
|
bArmature *armature = (bArmature *)object->data;
|
||||||
Scene *scene_cow = get_cow_datablock(scene_);
|
Scene *scene_cow = get_cow_datablock(scene_);
|
||||||
@@ -272,7 +270,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible)
|
|||||||
}
|
}
|
||||||
/* Build constraints. */
|
/* Build constraints. */
|
||||||
if (pchan->constraints.first != nullptr) {
|
if (pchan->constraints.first != nullptr) {
|
||||||
build_pose_constraints(object, pchan, pchan_index, is_object_visible);
|
build_pose_constraints(object, pchan, pchan_index);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* IK Solvers.
|
* IK Solvers.
|
||||||
@@ -301,14 +299,14 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible)
|
|||||||
}
|
}
|
||||||
/* Custom shape. */
|
/* Custom shape. */
|
||||||
if (pchan->custom != nullptr) {
|
if (pchan->custom != nullptr) {
|
||||||
/* TODO(sergey): Use own visibility. */
|
/* NOTE: The relation builder will ensure visibility of the custom shape object. */
|
||||||
build_object(-1, pchan->custom, DEG_ID_LINKED_INDIRECTLY, is_object_visible);
|
build_object(-1, pchan->custom, DEG_ID_LINKED_INDIRECTLY, false);
|
||||||
}
|
}
|
||||||
pchan_index++;
|
pchan_index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visible)
|
void DepsgraphNodeBuilder::build_proxy_rig(Object *object)
|
||||||
{
|
{
|
||||||
bArmature *armature = (bArmature *)object->data;
|
bArmature *armature = (bArmature *)object->data;
|
||||||
OperationNode *op_node;
|
OperationNode *op_node;
|
||||||
@@ -356,7 +354,8 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visibl
|
|||||||
|
|
||||||
/* Custom shape. */
|
/* Custom shape. */
|
||||||
if (pchan->custom != nullptr) {
|
if (pchan->custom != nullptr) {
|
||||||
build_object(-1, pchan->custom, DEG_ID_LINKED_INDIRECTLY, is_object_visible);
|
/* NOTE: The relation builder will ensure visibility of the custom shape object. */
|
||||||
|
build_object(-1, pchan->custom, DEG_ID_LINKED_INDIRECTLY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pchan_index++;
|
pchan_index++;
|
||||||
|
|||||||
@@ -112,11 +112,11 @@ enum class NodeType {
|
|||||||
* which simplifies common algorithms which are dealing with relations and visibility.
|
* which simplifies common algorithms which are dealing with relations and visibility.
|
||||||
*
|
*
|
||||||
* The fact that the visibility operates on the ID level basically means that all components in
|
* The fact that the visibility operates on the ID level basically means that all components in
|
||||||
* NodeA will be considered as affecting directly visible when NodeB's visibility is
|
* the NodeA will be considered as affecting directly visible when NodeB's visibility is
|
||||||
* affecting directly visible ID.
|
* affecting directly visible ID.
|
||||||
*
|
*
|
||||||
* This is the way to ensure objects needed for visualization without any actual data dependency
|
* This is the way to ensure objects needed for visualization without any actual data dependency
|
||||||
* are properly evaluated. Example of this is custom shapes for bones. */
|
* properly evaluated. Example of this is custom shapes for bones. */
|
||||||
VISIBILITY,
|
VISIBILITY,
|
||||||
|
|
||||||
/* **** Evaluation-Related Outer Types (with Subdata) **** */
|
/* **** Evaluation-Related Outer Types (with Subdata) **** */
|
||||||
|
|||||||
Reference in New Issue
Block a user