Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-03-07 13:13:40 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-03-07 13:29:50 +0300
commitab0bc65c24bdf68c356adb2566f3669153c931ea (patch)
tree23909478874a13d84e504a905809eb211e62a9e2 /source/blender/depsgraph/intern
parentcee53160d2bd9067a3d43cc862ce61e36ff70454 (diff)
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc., 'simply' do the same for the mask flags we use all around Blender code to request some data, or limit some operation to some layers, etc. Reason we need this is that some cddata types (like Normals) are actually shared between verts/polys/loops, and we don’t want to generate clnors everytime we request vnors! As a side note, this also does final fix to T59338, which was the trigger for this patch (need to request computed loop normals for another mesh than evaluated one). Reviewers: brecht, campbellbarton, sergey Differential Revision: https://developer.blender.org/D4407
Diffstat (limited to 'source/blender/depsgraph/intern')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc8
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc20
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc4
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc13
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.cc12
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.h92
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.cc4
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.h4
12 files changed, 145 insertions, 25 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index ca454610f1e..b6e516ee9b4 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -203,7 +203,7 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
}
/* Tag rebuild if the custom data mask changed. */
- if (id_node->customdata_mask != id_node->previous_customdata_mask) {
+ if (id_node->customdata_masks != id_node->previous_customdata_masks) {
flag |= ID_RECALC_GEOMETRY;
}
if (!deg_copy_on_write_is_expanded(id_node->id_cow)) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 463f4fa0935..dbf6b1d1451 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -154,14 +154,14 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
ID *id_cow = NULL;
IDComponentsMask previously_visible_components_mask = 0;
uint32_t previous_eval_flags = 0;
- uint64_t previous_customdata_mask = 0;
+ DEGCustomDataMeshMasks previous_customdata_masks;
IDInfo *id_info = (IDInfo *)BLI_ghash_lookup(id_info_hash_, id);
if (id_info != NULL) {
id_cow = id_info->id_cow;
previously_visible_components_mask =
id_info->previously_visible_components_mask;
previous_eval_flags = id_info->previous_eval_flags;
- previous_customdata_mask = id_info->previous_customdata_mask;
+ previous_customdata_masks = id_info->previous_customdata_masks;
/* Tag ID info to not free the CoW ID pointer. */
id_info->id_cow = NULL;
}
@@ -169,7 +169,7 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
id_node->previously_visible_components_mask =
previously_visible_components_mask;
id_node->previous_eval_flags = previous_eval_flags;
- id_node->previous_customdata_mask = previous_customdata_mask;
+ id_node->previous_customdata_masks = previous_customdata_masks;
/* Currently all ID nodes are supposed to have copy-on-write logic.
*
* NOTE: Zero number of components indicates that ID node was just created. */
@@ -339,7 +339,7 @@ void DepsgraphNodeBuilder::begin_build()
id_info->previously_visible_components_mask =
id_node->visible_components_mask;
id_info->previous_eval_flags = id_node->eval_flags;
- id_info->previous_customdata_mask = id_node->customdata_mask;
+ id_info->previous_customdata_masks = id_node->customdata_masks;
BLI_ghash_insert(id_info_hash_, id_node->id_orig, id_info);
id_node->id_cow = NULL;
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 0bf4c13d515..d5d1ac2d33a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -230,7 +230,7 @@ public:
/* Special evaluation flag mask from the previous depsgraph. */
uint32_t previous_eval_flags;
/* Mesh CustomData mask from the previous depsgraph. */
- uint64_t previous_customdata_mask;
+ DEGCustomDataMeshMasks previous_customdata_masks;
};
protected:
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 9aab90f88cf..161d0a9cd9f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -309,16 +309,18 @@ void DepsgraphRelationBuilder::add_modifier_to_transform_relation(
transform_operation_node, geometry_operation_node, description);
}
-void DepsgraphRelationBuilder::add_customdata_mask(Object *object, uint64_t mask)
+void DepsgraphRelationBuilder::add_customdata_mask(
+ Object *object,
+ const DEGCustomDataMeshMasks &customdata_masks)
{
- if (mask != 0 && object != NULL && object->type == OB_MESH) {
+ if (customdata_masks != DEGCustomDataMeshMasks() && object != NULL && object->type == OB_MESH) {
DEG::IDNode *id_node = graph_->find_id_node(&object->id);
if (id_node == NULL) {
BLI_assert(!"ID should always be valid");
}
else {
- id_node->customdata_mask |= mask;
+ id_node->customdata_masks |= customdata_masks;
}
}
}
@@ -864,7 +866,11 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
* TODO(sergey): This optimization got lost at 2.8, so either verify
* we can get rid of this mask here, or bring the optimization
* back. */
- add_customdata_mask(object->parent, CD_MASK_ORIGINDEX);
+ add_customdata_mask(object->parent,
+ DEGCustomDataMeshMasks::MaskVert(CD_MASK_ORIGINDEX) |
+ DEGCustomDataMeshMasks::MaskEdge(CD_MASK_ORIGINDEX) |
+ DEGCustomDataMeshMasks::MaskFace(CD_MASK_ORIGINDEX) |
+ DEGCustomDataMeshMasks::MaskPoly(CD_MASK_ORIGINDEX));
ComponentKey transform_key(parent_id, NodeType::TRANSFORM);
add_relation(transform_key, ob_key, "Vertex Parent TFM");
break;
@@ -1118,7 +1124,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
target_transform_key, constraint_op_key, cti->name);
add_relation(
target_geometry_key, constraint_op_key, cti->name);
- add_customdata_mask(ct->tar, CD_MASK_MDEFORMVERT);
+ add_customdata_mask(ct->tar, DEGCustomDataMeshMasks::MaskVert(CD_MASK_MDEFORMVERT));
}
else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
@@ -1131,7 +1137,9 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
if (ct->tar->type == OB_MESH && scon->shrinkType != MOD_SHRINKWRAP_NEAREST_VERTEX) {
bool track = (scon->flag & CON_SHRINKWRAP_TRACK_NORMAL) != 0;
if (track || BKE_shrinkwrap_needs_normals(scon->shrinkType, scon->shrinkMode)) {
- add_customdata_mask(ct->tar, CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL);
+ add_customdata_mask(ct->tar,
+ DEGCustomDataMeshMasks::MaskVert(CD_MASK_NORMAL) |
+ DEGCustomDataMeshMasks::MaskLoop(CD_MASK_CUSTOMLOOPNORMAL));
}
if (scon->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
add_special_eval_flag(&ct->tar->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index fb76b469572..250593eeda0 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -204,7 +204,8 @@ public:
void add_modifier_to_transform_relation(const DepsNodeHandle *handle,
const char *description);
- void add_customdata_mask(Object *object, uint64_t mask);
+ void add_customdata_mask(Object *object,
+ const DEGCustomDataMeshMasks &customdata_masks);
void add_special_eval_flag(ID *object, uint32_t flag);
void build_id(ID *id);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index 8742dc43651..fe88b532dca 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -130,7 +130,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
* separately. */
ComponentKey target_key(&data->tar->id, NodeType::GEOMETRY);
add_relation(target_key, solver_key, con->name);
- add_customdata_mask(data->tar, CD_MASK_MDEFORMVERT);
+ add_customdata_mask(data->tar, DEGCustomDataMeshMasks::MaskVert(CD_MASK_MDEFORMVERT));
}
else {
/* Standard Object Target. */
@@ -160,7 +160,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
* separately. */
ComponentKey target_key(&data->poletar->id, NodeType::GEOMETRY);
add_relation(target_key, solver_key, con->name);
- add_customdata_mask(data->poletar, CD_MASK_MDEFORMVERT);
+ add_customdata_mask(data->poletar, DEGCustomDataMeshMasks::MaskVert(CD_MASK_MDEFORMVERT));
}
else {
ComponentKey target_key(&data->poletar->id, NodeType::TRANSFORM);
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 8480f152709..ffd0f9da31a 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -211,10 +211,12 @@ void DEG_add_special_eval_flag(struct DepsNodeHandle *node_handle,
void DEG_add_customdata_mask(struct DepsNodeHandle *node_handle,
struct Object *object,
- uint64_t mask)
+ const CustomData_MeshMasks *masks)
{
DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
- deg_node_handle->builder->add_customdata_mask(object, mask);
+ deg_node_handle->builder->add_customdata_mask(
+ object,
+ DEG::DEGCustomDataMeshMasks(masks));
}
struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle)
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index a366b9b6568..3b7f19e9916 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -29,6 +29,7 @@ extern "C" {
#include <string.h> // XXX: memcpy
#include "BLI_utildefines.h"
+#include "BKE_customdata.h"
#include "BKE_idcode.h"
#include "BKE_main.h"
#include "BLI_listbase.h"
@@ -114,7 +115,7 @@ uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
return id_node->eval_flags;
}
-uint64_t DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *ob)
+void DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *ob, CustomData_MeshMasks *r_mask)
{
if (graph == NULL) {
/* Happens when converting objects to mesh from a python script
@@ -122,17 +123,21 @@ uint64_t DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *ob)
*
* Currently harmless because it's only called for temporary
* objects which are out of the DAG anyway. */
- return 0;
+ return;
}
const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
const DEG::IDNode *id_node = deg_graph->find_id_node(DEG_get_original_id(&ob->id));
if (id_node == NULL) {
/* TODO(sergey): Does it mean we need to check set scene? */
- return 0;
+ return;
}
- return id_node->customdata_mask;
+ r_mask->vmask |= id_node->customdata_masks.vert_mask;
+ r_mask->emask |= id_node->customdata_masks.edge_mask;
+ r_mask->fmask |= id_node->customdata_masks.face_mask;
+ r_mask->lmask |= id_node->customdata_masks.loop_mask;
+ r_mask->pmask |= id_node->customdata_masks.poly_mask;
}
Scene *DEG_get_evaluated_scene(const Depsgraph *graph)
diff --git a/source/blender/depsgraph/intern/depsgraph_type.cc b/source/blender/depsgraph/intern/depsgraph_type.cc
index 28d93cb9194..5be2cae10d7 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type.cc
@@ -29,8 +29,11 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
+#include "DNA_customdata_types.h"
+
#include "DEG_depsgraph.h"
+#include "intern/depsgraph_type.h"
#include "intern/node/deg_node.h"
#include "intern/node/deg_node_component.h"
#include "intern/node/deg_node_factory.h"
@@ -49,3 +52,12 @@ void DEG_register_node_types(void)
void DEG_free_node_types(void)
{
}
+
+DEG::DEGCustomDataMeshMasks::DEGCustomDataMeshMasks(const CustomData_MeshMasks *other) :
+ vert_mask(other->vmask),
+ edge_mask(other->emask),
+ face_mask(other->fmask),
+ loop_mask(other->lmask),
+ poly_mask(other->pmask)
+{
+}
diff --git a/source/blender/depsgraph/intern/depsgraph_type.h b/source/blender/depsgraph/intern/depsgraph_type.h
index 5233b6d018d..d34b6d724cb 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.h
+++ b/source/blender/depsgraph/intern/depsgraph_type.h
@@ -39,6 +39,8 @@
struct Depsgraph;
+struct CustomData_MeshMasks;
+
namespace DEG {
/* Commonly used types. */
@@ -70,4 +72,94 @@ enum eUpdateSource {
DEG_UPDATE_SOURCE_VISIBILITY = (1 << 3),
};
+/* C++ wrapper around DNA's CustomData_MeshMasks struct. */
+struct DEGCustomDataMeshMasks {
+ uint64_t vert_mask;
+ uint64_t edge_mask;
+ uint64_t face_mask;
+ uint64_t loop_mask;
+ uint64_t poly_mask;
+
+ DEGCustomDataMeshMasks()
+ : vert_mask(0),
+ edge_mask(0),
+ face_mask(0),
+ loop_mask(0),
+ poly_mask(0)
+ {
+ }
+
+ explicit DEGCustomDataMeshMasks(const CustomData_MeshMasks *other);
+
+ DEGCustomDataMeshMasks& operator|=(const DEGCustomDataMeshMasks& other)
+ {
+ this->vert_mask |= other.vert_mask;
+ this->edge_mask |= other.edge_mask;
+ this->face_mask |= other.face_mask;
+ this->loop_mask |= other.loop_mask;
+ this->poly_mask |= other.poly_mask;
+ return *this;
+ }
+
+ DEGCustomDataMeshMasks operator|(const DEGCustomDataMeshMasks& other) const
+ {
+ DEGCustomDataMeshMasks result;
+ result.vert_mask = this->vert_mask | other.vert_mask;
+ result.edge_mask = this->edge_mask | other.edge_mask;
+ result.face_mask = this->face_mask | other.face_mask;
+ result.loop_mask = this->loop_mask | other.loop_mask;
+ result.poly_mask = this->poly_mask | other.poly_mask;
+ return result;
+ }
+
+ bool operator==(const DEGCustomDataMeshMasks& other) const
+ {
+ return (this->vert_mask == other.vert_mask &&
+ this->edge_mask == other.edge_mask &&
+ this->face_mask == other.face_mask &&
+ this->loop_mask == other.loop_mask &&
+ this->poly_mask == other.poly_mask);
+ }
+
+ bool operator!=(const DEGCustomDataMeshMasks& other) const
+ {
+ return !(*this == other);
+ }
+
+ static DEGCustomDataMeshMasks MaskVert(const uint64_t vert_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.vert_mask = vert_mask;
+ return result;
+ }
+
+ static DEGCustomDataMeshMasks MaskEdge(const uint64_t edge_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.edge_mask = edge_mask;
+ return result;
+ }
+
+ static DEGCustomDataMeshMasks MaskFace(const uint64_t face_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.face_mask = face_mask;
+ return result;
+ }
+
+ static DEGCustomDataMeshMasks MaskLoop(const uint64_t loop_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.loop_mask = loop_mask;
+ return result;
+ }
+
+ static DEGCustomDataMeshMasks MaskPoly(const uint64_t poly_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.poly_mask = poly_mask;
+ return result;
+ }
+};
+
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc
index f992ce33279..d391f727d35 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_id.cc
@@ -109,8 +109,8 @@ void IDNode::init(const ID *id, const char *UNUSED(subdata))
id_orig = (ID *)id;
eval_flags = 0;
previous_eval_flags = 0;
- customdata_mask = 0;
- previous_customdata_mask = 0;
+ customdata_masks = DEGCustomDataMeshMasks();
+ previous_customdata_masks = DEGCustomDataMeshMasks();
linked_state = DEG_ID_LINKED_INDIRECTLY;
is_directly_visible = true;
is_collection_fully_expanded = false;
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h
index 9c3ce7580ad..bbf671790c7 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.h
+++ b/source/blender/depsgraph/intern/node/deg_node_id.h
@@ -84,8 +84,8 @@ struct IDNode : public Node {
uint32_t previous_eval_flags;
/* Extra customdata mask which needs to be evaluated for the mesh object. */
- uint64_t customdata_mask;
- uint64_t previous_customdata_mask;
+ DEGCustomDataMeshMasks customdata_masks;
+ DEGCustomDataMeshMasks previous_customdata_masks;
eDepsNode_LinkedState_Type linked_state;