diff options
Diffstat (limited to 'source/blender/depsgraph')
9 files changed, 184 insertions, 4 deletions
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index 169e7f00744..355d2536e1a 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -69,6 +69,7 @@ set(SRC intern/eval/deg_eval_runtime_backup_sequence.cc intern/eval/deg_eval_runtime_backup_sequencer.cc intern/eval/deg_eval_runtime_backup_sound.cc + intern/eval/deg_eval_runtime_backup_volume.cc intern/eval/deg_eval_stats.cc intern/node/deg_node.cc intern/node/deg_node_component.cc @@ -122,6 +123,7 @@ set(SRC intern/eval/deg_eval_runtime_backup_sequence.h intern/eval/deg_eval_runtime_backup_sequencer.h intern/eval/deg_eval_runtime_backup_sound.h + intern/eval/deg_eval_runtime_backup_volume.h intern/eval/deg_eval_stats.h intern/node/deg_node.h intern/node/deg_node_component.h diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 442b4aa406a..ea49882fd77 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -97,6 +97,7 @@ extern "C" { #include "BKE_shader_fx.h" #include "BKE_sound.h" #include "BKE_tracking.h" +#include "BKE_volume.h" #include "BKE_world.h" #include "RNA_access.h" @@ -455,6 +456,9 @@ void DepsgraphNodeBuilder::build_id(ID *id) case ID_CU: case ID_MB: case ID_LT: + case ID_HA: + case ID_PT: + case ID_VO: /* TODO(sergey): Get visibility from a "parent" somehow. * * NOTE: Similarly to above, we don't want false-positives on @@ -700,6 +704,9 @@ void DepsgraphNodeBuilder::build_object_data(Object *object, bool is_object_visi case OB_MBALL: case OB_LATTICE: case OB_GPENCIL: + case OB_HAIR: + case OB_POINTCLOUD: + case OB_VOLUME: build_object_data_geometry(object, is_object_visible); break; case OB_ARMATURE: @@ -1326,6 +1333,26 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool op_node->set_as_entry(); break; } + case ID_HA: { + op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); + op_node->set_as_entry(); + break; + } + case ID_PT: { + op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); + op_node->set_as_entry(); + break; + } + case ID_VO: { + /* Volume frame update. */ + op_node = add_operation_node( + obdata, + NodeType::GEOMETRY, + OperationCode::GEOMETRY_EVAL, + function_bind(BKE_volume_eval_geometry, _1, (Volume *)obdata_cow)); + op_node->set_as_entry(); + break; + } default: BLI_assert(!"Should not happen"); break; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 27d6db6a58f..4647486bafd 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -64,6 +64,7 @@ extern "C" { #include "DNA_sound_types.h" #include "DNA_speaker_types.h" #include "DNA_texture_types.h" +#include "DNA_volume_types.h" #include "DNA_world_types.h" #include "DNA_object_force_types.h" @@ -537,6 +538,9 @@ void DepsgraphRelationBuilder::build_id(ID *id) case ID_CU: case ID_MB: case ID_LT: + case ID_HA: + case ID_PT: + case ID_VO: build_object_data_geometry_datablock(id); break; case ID_SPK: @@ -771,7 +775,10 @@ void DepsgraphRelationBuilder::build_object_data(Object *object) case OB_SURF: case OB_MBALL: case OB_LATTICE: - case OB_GPENCIL: { + case OB_GPENCIL: + case OB_HAIR: + case OB_POINTCLOUD: + case OB_VOLUME: { build_object_data_geometry(object); /* TODO(sergey): Only for until we support granular * update of curves. */ @@ -2145,6 +2152,19 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) } break; } + case ID_HA: + break; + case ID_PT: + break; + case ID_VO: { + Volume *volume = (Volume *)obdata; + if (volume->is_sequence) { + TimeSourceKey time_key; + ComponentKey geometry_key(obdata, NodeType::GEOMETRY); + add_relation(time_key, geometry_key, "Volume sequence time"); + } + break; + } default: BLI_assert(!"Should not happen"); break; @@ -2593,7 +2613,7 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node) continue; } int rel_flag = (RELATION_FLAG_NO_FLUSH | RELATION_FLAG_GODMODE); - if ((id_type == ID_ME && comp_node->type == NodeType::GEOMETRY) || + if ((ELEM(id_type, ID_ME, ID_HA, ID_PT, ID_VO) && comp_node->type == NodeType::GEOMETRY) || (id_type == ID_CF && comp_node->type == NodeType::CACHE)) { rel_flag &= ~RELATION_FLAG_NO_FLUSH; } diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 8decb9f6b87..a14f22350a4 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -89,7 +89,7 @@ void depsgraph_geometry_tag_to_component(const ID *id, NodeType *component_type) bool is_selectable_data_id_type(const ID_Type id_type) { - return ELEM(id_type, ID_ME, ID_CU, ID_MB, ID_LT, ID_GD); + return ELEM(id_type, ID_ME, ID_CU, ID_MB, ID_LT, ID_GD, ID_HA, ID_PT, ID_VO); } void depsgraph_select_tag_to_component_opcode(const ID *id, @@ -582,6 +582,9 @@ NodeType geometry_tag_to_component(const ID *id) case OB_LATTICE: case OB_MBALL: case OB_GPENCIL: + case OB_HAIR: + case OB_POINTCLOUD: + case OB_VOLUME: return NodeType::GEOMETRY; case OB_ARMATURE: return NodeType::EVAL_POSE; @@ -593,6 +596,9 @@ NodeType geometry_tag_to_component(const ID *id) case ID_CU: case ID_LT: case ID_MB: + case ID_HA: + case ID_PT: + case ID_VO: return NodeType::GEOMETRY; case ID_PA: /* Particles */ return NodeType::UNDEFINED; diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc index 40a17666880..108f5f04879 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc @@ -37,7 +37,8 @@ RuntimeBackup::RuntimeBackup(const Depsgraph *depsgraph) sound_backup(depsgraph), object_backup(depsgraph), drawdata_ptr(nullptr), - movieclip_backup(depsgraph) + movieclip_backup(depsgraph), + volume_backup(depsgraph) { drawdata_backup.first = drawdata_backup.last = nullptr; } @@ -64,6 +65,9 @@ void RuntimeBackup::init_from_id(ID *id) case ID_MC: movieclip_backup.init_from_movieclip(reinterpret_cast<MovieClip *>(id)); break; + case ID_VO: + volume_backup.init_from_volume(reinterpret_cast<Volume *>(id)); + break; default: break; } @@ -95,6 +99,9 @@ void RuntimeBackup::restore_to_id(ID *id) case ID_MC: movieclip_backup.restore_to_movieclip(reinterpret_cast<MovieClip *>(id)); break; + case ID_VO: + volume_backup.restore_to_volume(reinterpret_cast<Volume *>(id)); + break; default: break; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h index cc8c6ae0d5b..c818c1f7064 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h @@ -30,6 +30,7 @@ #include "intern/eval/deg_eval_runtime_backup_object.h" #include "intern/eval/deg_eval_runtime_backup_scene.h" #include "intern/eval/deg_eval_runtime_backup_sound.h" +#include "intern/eval/deg_eval_runtime_backup_volume.h" namespace DEG { @@ -52,6 +53,7 @@ class RuntimeBackup { DrawDataList drawdata_backup; DrawDataList *drawdata_ptr; MovieClipBackup movieclip_backup; + VolumeBackup volume_backup; }; } // namespace DEG diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc index 855dd4821ce..2f45ea45197 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc @@ -129,6 +129,17 @@ void ObjectRuntimeBackup::restore_to_object(Object *object) } } } + else if (ELEM(object->type, OB_HAIR, OB_POINTCLOUD, OB_VOLUME)) { + if (object->id.recalc & ID_RECALC_GEOMETRY) { + /* Free evaluated caches. */ + object->data = data_orig; + BKE_object_free_derived_caches(object); + } + else { + object->data = object->runtime.data_eval; + } + } + object->base_flag = base_flag; object->base_local_view_bits = base_local_view_bits; /* Restore modifier's runtime data. diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc new file mode 100644 index 00000000000..09e13ec131d --- /dev/null +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc @@ -0,0 +1,60 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2019 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup depsgraph + */ + +#include "intern/eval/deg_eval_runtime_backup_volume.h" + +#include "BLI_assert.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "DNA_volume_types.h" + +#include "BKE_volume.h" + +#include <stdio.h> + +namespace DEG { + +VolumeBackup::VolumeBackup(const Depsgraph * /*depsgraph*/) : grids(nullptr) +{ +} + +void VolumeBackup::init_from_volume(Volume *volume) +{ + STRNCPY(filepath, volume->filepath); + BLI_STATIC_ASSERT(sizeof(filepath) == sizeof(volume->filepath), + "VolumeBackup filepath length wrong"); + + grids = volume->runtime.grids; + volume->runtime.grids = nullptr; +} + +void VolumeBackup::restore_to_volume(Volume *volume) +{ + if (grids) { + BKE_volume_grids_backup_restore(volume, grids, filepath); + grids = nullptr; + } +} + +} // namespace DEG diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.h new file mode 100644 index 00000000000..cf57c702c8f --- /dev/null +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.h @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2019 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup depsgraph + */ + +#pragma once + +struct Volume; +struct VolumeGridVector; + +namespace DEG { + +struct Depsgraph; + +/* Backup of volume datablocks runtime data. */ +class VolumeBackup { + public: + VolumeBackup(const Depsgraph *depsgraph); + + void init_from_volume(Volume *volume); + void restore_to_volume(Volume *volume); + + VolumeGridVector *grids; + char filepath[1024]; /* FILE_MAX */ +}; + +} // namespace DEG |