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:
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_query_iter.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_iter.cc138
1 files changed, 9 insertions, 129 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index 770d9775dd3..7af3d03d478 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -120,130 +120,6 @@ bool deg_object_hide_original(eEvaluationMode eval_mode, Object *ob, DupliObject
return false;
}
-void deg_iterator_components_init(DEGObjectIterData *data, Object *object)
-{
- data->geometry_component_owner = object;
- data->geometry_component_id = 0;
-}
-
-/* Returns false when iterator is exhausted. */
-bool deg_iterator_components_step(BLI_Iterator *iter)
-{
- DEGObjectIterData *data = (DEGObjectIterData *)iter->data;
- if (data->geometry_component_owner == nullptr) {
- return false;
- }
-
- if (data->geometry_component_owner->runtime.geometry_set_eval == nullptr) {
- /* Return the object itself, if it does not have a geometry set yet. */
- iter->current = data->geometry_component_owner;
- data->geometry_component_owner = nullptr;
- return true;
- }
-
- GeometrySet *geometry_set = data->geometry_component_owner->runtime.geometry_set_eval;
- if (geometry_set == nullptr) {
- data->geometry_component_owner = nullptr;
- return false;
- }
-
- /* The mesh component. */
- if (data->geometry_component_id == 0) {
- data->geometry_component_id++;
-
- /* Don't use a temporary object for this component, when the owner is a mesh object. */
- if (data->geometry_component_owner->type == OB_MESH) {
- iter->current = data->geometry_component_owner;
- return true;
- }
-
- const Mesh *mesh = geometry_set->get_mesh_for_read();
- if (mesh != nullptr) {
- Object *temp_object = &data->temp_geometry_component_object;
- *temp_object = *data->geometry_component_owner;
- temp_object->type = OB_MESH;
- temp_object->data = (void *)mesh;
- temp_object->runtime.select_id = data->geometry_component_owner->runtime.select_id;
- iter->current = temp_object;
- return true;
- }
- }
-
- /* The pointcloud component. */
- if (data->geometry_component_id == 1) {
- data->geometry_component_id++;
-
- /* Don't use a temporary object for this component, when the owner is a point cloud object. */
- if (data->geometry_component_owner->type == OB_POINTCLOUD) {
- iter->current = data->geometry_component_owner;
- return true;
- }
-
- const PointCloud *pointcloud = geometry_set->get_pointcloud_for_read();
- if (pointcloud != nullptr) {
- Object *temp_object = &data->temp_geometry_component_object;
- *temp_object = *data->geometry_component_owner;
- temp_object->type = OB_POINTCLOUD;
- temp_object->data = (void *)pointcloud;
- temp_object->runtime.select_id = data->geometry_component_owner->runtime.select_id;
- iter->current = temp_object;
- return true;
- }
- }
-
- /* The volume component. */
- if (data->geometry_component_id == 2) {
- data->geometry_component_id++;
-
- /* Don't use a temporary object for this component, when the owner is a volume object. */
- if (data->geometry_component_owner->type == OB_VOLUME) {
- iter->current = data->geometry_component_owner;
- return true;
- }
-
- const VolumeComponent *component = geometry_set->get_component_for_read<VolumeComponent>();
- if (component != nullptr) {
- const Volume *volume = component->get_for_read();
-
- if (volume != nullptr) {
- Object *temp_object = &data->temp_geometry_component_object;
- *temp_object = *data->geometry_component_owner;
- temp_object->type = OB_VOLUME;
- temp_object->data = (void *)volume;
- temp_object->runtime.select_id = data->geometry_component_owner->runtime.select_id;
- iter->current = temp_object;
- return true;
- }
- }
- }
-
- /* The curve component. */
- if (data->geometry_component_id == 3) {
- data->geometry_component_id++;
-
- const CurveComponent *component = geometry_set->get_component_for_read<CurveComponent>();
- if (component != nullptr) {
- const Curve *curve = component->get_curve_for_render();
-
- if (curve != nullptr) {
- Object *temp_object = &data->temp_geometry_component_object;
- *temp_object = *data->geometry_component_owner;
- temp_object->type = OB_CURVE;
- temp_object->data = (void *)curve;
- /* Assign data_eval here too, because curve rendering code tries
- * to use a mesh if it can find one in this pointer. */
- temp_object->runtime.data_eval = (ID *)curve;
- temp_object->runtime.select_id = data->geometry_component_owner->runtime.select_id;
- iter->current = temp_object;
- return true;
- }
- }
- }
-
- data->geometry_component_owner = nullptr;
- return false;
-}
-
void deg_iterator_duplis_init(DEGObjectIterData *data, Object *object)
{
if ((data->flag & DEG_ITER_OBJECT_FLAG_DUPLI) &&
@@ -292,6 +168,9 @@ bool deg_iterator_duplis_step(DEGObjectIterData *data)
temp_dupli_object->dt = MIN2(temp_dupli_object->dt, dupli_parent->dt);
copy_v4_v4(temp_dupli_object->color, dupli_parent->color);
temp_dupli_object->runtime.select_id = dupli_parent->runtime.select_id;
+ if (dob->ob->data != dob->ob_data) {
+ BKE_object_replace_data_on_shallow_copy(temp_dupli_object, dob->ob_data);
+ }
/* Duplicated elements shouldn't care whether their original collection is visible or not. */
temp_dupli_object->base_flag |= BASE_VISIBLE_DEPSGRAPH;
@@ -308,7 +187,7 @@ bool deg_iterator_duplis_step(DEGObjectIterData *data)
copy_m4_m4(data->temp_dupli_object.obmat, dob->mat);
invert_m4_m4(data->temp_dupli_object.imat, data->temp_dupli_object.obmat);
- deg_iterator_components_init(data, &data->temp_dupli_object);
+ data->next_object = &data->temp_dupli_object;
BLI_assert(deg::deg_validate_copy_on_write_datablock(&data->temp_dupli_object.id));
return true;
}
@@ -377,7 +256,7 @@ bool deg_iterator_objects_step(DEGObjectIterData *data)
}
if (ob_visibility & (OB_VISIBLE_SELF | OB_VISIBLE_PARTICLES)) {
- deg_iterator_components_init(data, object);
+ data->next_object = object;
}
data->id_node_index++;
return true;
@@ -400,6 +279,7 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
return;
}
+ data->next_object = nullptr;
data->dupli_parent = nullptr;
data->dupli_list = nullptr;
data->dupli_object_next = nullptr;
@@ -408,8 +288,6 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
data->id_node_index = 0;
data->num_id_nodes = num_id_nodes;
data->eval_mode = DEG_get_mode(depsgraph);
- data->geometry_component_id = 0;
- data->geometry_component_owner = nullptr;
deg_invalidate_iterator_work_data(data);
DEG_iterator_objects_next(iter);
@@ -419,7 +297,9 @@ void DEG_iterator_objects_next(BLI_Iterator *iter)
{
DEGObjectIterData *data = (DEGObjectIterData *)iter->data;
while (true) {
- if (deg_iterator_components_step(iter)) {
+ if (data->next_object != nullptr) {
+ iter->current = data->next_object;
+ data->next_object = nullptr;
return;
}
if (deg_iterator_duplis_step(data)) {