Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
/*
|
|
|
|
* 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) 2013 Blender Foundation.
|
|
|
|
* All rights reserved.
|
2015-05-20 12:54:45 +10:00
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup depsgraph
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
*
|
2019-05-03 12:39:12 +02:00
|
|
|
* Public API for Querying Depsgraph.
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-12-11 12:24:12 +01:00
|
|
|
#include "BLI_iterator.h"
|
|
|
|
|
2017-06-08 16:11:14 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
2018-08-23 01:24:48 +12:00
|
|
|
#include "DEG_depsgraph_build.h"
|
2017-06-08 16:11:14 +02:00
|
|
|
|
2019-05-21 17:29:58 +02:00
|
|
|
/* Needed for the instance iterator. */
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
2017-05-18 16:16:23 +02:00
|
|
|
struct BLI_Iterator;
|
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
2019-03-07 11:13:40 +01:00
|
|
|
struct CustomData_MeshMasks;
|
2017-06-01 15:26:47 +02:00
|
|
|
struct Depsgraph;
|
|
|
|
struct DupliObject;
|
2019-08-25 16:27:13 +10:00
|
|
|
struct ID;
|
2017-06-01 15:26:47 +02:00
|
|
|
struct ListBase;
|
2019-08-25 16:27:13 +10:00
|
|
|
struct PointerRNA;
|
2017-06-01 15:26:47 +02:00
|
|
|
struct Scene;
|
2017-11-22 10:52:39 -02:00
|
|
|
struct ViewLayer;
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-04-06 09:17:53 +02:00
|
|
|
/* *********************** DEG input data ********************* */
|
|
|
|
|
|
|
|
/* Get scene that depsgraph was built for. */
|
|
|
|
struct Scene *DEG_get_input_scene(const Depsgraph *graph);
|
|
|
|
|
|
|
|
/* Get view layer that depsgraph was built for. */
|
|
|
|
struct ViewLayer *DEG_get_input_view_layer(const Depsgraph *graph);
|
|
|
|
|
2020-08-18 15:45:58 +02:00
|
|
|
/* Get bmain that depsgraph was built for. */
|
|
|
|
struct Main *DEG_get_bmain(const Depsgraph *graph);
|
|
|
|
|
2018-04-06 09:17:53 +02:00
|
|
|
/* Get evaluation mode that depsgraph was built for. */
|
|
|
|
eEvaluationMode DEG_get_mode(const Depsgraph *graph);
|
|
|
|
|
|
|
|
/* Get time that depsgraph is being evaluated or was last evaluated at. */
|
|
|
|
float DEG_get_ctime(const Depsgraph *graph);
|
|
|
|
|
|
|
|
/* ********************* DEG evaluated data ******************* */
|
|
|
|
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
/* Check if given ID type was tagged for update. */
|
2018-05-29 15:57:14 +02:00
|
|
|
bool DEG_id_type_updated(const struct Depsgraph *depsgraph, short id_type);
|
|
|
|
bool DEG_id_type_any_updated(const struct Depsgraph *depsgraph);
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
|
2019-05-28 09:11:55 +02:00
|
|
|
/* Check if given ID type is present in the depsgraph */
|
|
|
|
bool DEG_id_type_any_exists(const struct Depsgraph *depsgraph, short id_type);
|
|
|
|
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
/* Get additional evaluation flags for the given ID. */
|
2018-10-24 19:38:50 +03:00
|
|
|
uint32_t DEG_get_eval_flags_for_id(const struct Depsgraph *graph, struct ID *id);
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
|
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
2019-03-07 11:13:40 +01:00
|
|
|
/* Get additional mesh CustomData_MeshMasks flags for the given object. */
|
|
|
|
void DEG_get_customdata_mask_for_object(const struct Depsgraph *graph,
|
|
|
|
struct Object *object,
|
|
|
|
struct CustomData_MeshMasks *r_mask);
|
2018-12-03 18:09:45 +03:00
|
|
|
|
2019-05-06 10:03:22 +02:00
|
|
|
/* Get scene at its evaluated state.
|
|
|
|
*
|
|
|
|
* Technically, this is a copied-on-written and fully evaluated version of the input scene.
|
2019-06-12 09:04:10 +10:00
|
|
|
* This function will check that the data-block has been expanded (and copied) from the original
|
2019-05-06 10:03:22 +02:00
|
|
|
* one. Assert will happen if it's not. */
|
2018-01-17 12:26:43 +01:00
|
|
|
struct Scene *DEG_get_evaluated_scene(const struct Depsgraph *graph);
|
2017-04-20 18:59:47 +02:00
|
|
|
|
2019-05-06 10:03:22 +02:00
|
|
|
/* Get view layer at its evaluated state.
|
|
|
|
* This is a shortcut for accessing active view layer from evaluated scene. */
|
2018-01-17 12:26:43 +01:00
|
|
|
struct ViewLayer *DEG_get_evaluated_view_layer(const struct Depsgraph *graph);
|
2017-04-20 17:09:18 +02:00
|
|
|
|
2017-07-13 12:57:19 +02:00
|
|
|
/* Get evaluated version of object for given original one. */
|
2018-01-17 12:26:43 +01:00
|
|
|
struct Object *DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object);
|
2017-04-21 11:29:47 +02:00
|
|
|
|
Depsgraph: Initial groundwork for copy-on-write support
< Dependency graph Copy-on-Write >
--------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
This is an initial commit of Copy-on-write support added to dependency graph.
Main priority for now: get playback (Alt-A) and all operators (selection,
transform etc) to work with the new concept of clear separation between
evaluated data coming from dependency graph and original data coming from
.blend file (and stored in bmain).
= How does this work? =
The idea is to support Copy-on-Write on the ID level. This means, we duplicate
the whole ID before we cann it's evaluaiton function. This is currently done
in the following way:
- At the depsgraph construction time we create "shallow" copy of the ID
datablock, just so we know it's pointer in memory and can use for function
bindings.
- At the evaluaiton time, the copy of ID get's "expanded" (needs a better
name internally, so it does not conflict with expanding datablocks during
library linking), which means the content of the datablock is being
copied over and all IDs are getting remapped to the copied ones.
Currently we do the whole copy, in the future we will support some tricks
here to prevent duplicating geometry arrays (verts, edges, loops, faces
and polys) when we don't need that.
- Evaluation functions are operating on copied datablocks and never touching
original datablock.
- There are some cases when we need to know non-ID pointers for function
bindings. This mainly applies to scene collections and armatures. The
idea of dealing with this is to "expand" copy-on-write datablock at
the dependency graph build time. This might introduce some slowdown to the
dependency graph construction time, but allows us to have minimal changes
in the code and avoid any hash look-up from evaluation function (one of
the ideas to avoid using pointers as function bindings is to pass name
of layer or a bone to the evaluation function and look up actual data based
on that name).
Currently there is a special function in depsgraph which does such a
synchronization, in the future we might want to make it more generic.
At some point we need to synchronize copy-on-write version of datablock with
the original version. This happens, i.e., when we change active object or
change selection. We don't want any actual evaluation of update flush happening
for such thins, so now we have a special update tag:
DEG_id_tag_update((id, DEG_TAG_COPY_ON_WRITE)
- For the render engines we now have special call for the dependency graph to
give evaluated datablock for the given original one. This isn't fully ideal
but allows to have Cycles viewport render.
This is definitely a subject for further investigation / improvement.
This call will tag copy-on-write component tagged for update without causing
updates to be flushed to any other objects, causing chain reaction of updates.
This tag is handy when selection in the scene changes.
This basically summarizes ideas underneath this commit. The code should be
reasonably documented.
Here is a demo of dependency graph with all copy-on-write stuff in it:
https://developer.blender.org/F635468
= What to expect to (not) work? =
- Only meshes are properly-ish aware of copy-on-write currently, Non-mesh
geometry will probably crash or will not work at all.
- Armatures will need similar depsgraph built-time expansion of the copied
datablock.
- There are some extra tags / relations added, to keep things demo-able but
which are slowing things down for evaluation.
- Edit mode works for until click selection is used (due to the selection
code using EditDerivedMesh created ad-hoc).
- Lots of tools will lack tagging synchronization of copied datablock for
sync with original ID.
= How to move forward? =
There is some tedious work related on going over all the tools, checking
whether they need to work with original or final evaluated object and make
the required changes.
Additionally, there need synchronization tag done in fair amount of tools
and operators as well. For example, currently it's not possible to change
render engine without re-opening the file or forcing dependency graph for
re-build via python console.
There is also now some thoughts required about copying evaluated properties
between objects or from collection to a new object. Perhaps easiest way
would be to move base flag flush to Object ID node and tag new objects for
update instead of doing manual copy.
here is some WIP patch which moves such evaluaiton / flush:
https://developer.blender.org/F635479
Lots of TODOs in the code, with possible optimization.
= How to test? =
This is a feature under heavy development, so obviously it is disabled by
default. The only reason it goes to 2.8 branch is to avoid possible merge
hell.
In order to enable this feature use WITH_DEPSGRAPH_COPY_ON_WRITE CMake
configuration option.
2017-06-14 10:26:24 +02:00
|
|
|
/* Get evaluated version of given ID datablock. */
|
2018-01-17 12:26:43 +01:00
|
|
|
struct ID *DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id);
|
Depsgraph: Initial groundwork for copy-on-write support
< Dependency graph Copy-on-Write >
--------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
This is an initial commit of Copy-on-write support added to dependency graph.
Main priority for now: get playback (Alt-A) and all operators (selection,
transform etc) to work with the new concept of clear separation between
evaluated data coming from dependency graph and original data coming from
.blend file (and stored in bmain).
= How does this work? =
The idea is to support Copy-on-Write on the ID level. This means, we duplicate
the whole ID before we cann it's evaluaiton function. This is currently done
in the following way:
- At the depsgraph construction time we create "shallow" copy of the ID
datablock, just so we know it's pointer in memory and can use for function
bindings.
- At the evaluaiton time, the copy of ID get's "expanded" (needs a better
name internally, so it does not conflict with expanding datablocks during
library linking), which means the content of the datablock is being
copied over and all IDs are getting remapped to the copied ones.
Currently we do the whole copy, in the future we will support some tricks
here to prevent duplicating geometry arrays (verts, edges, loops, faces
and polys) when we don't need that.
- Evaluation functions are operating on copied datablocks and never touching
original datablock.
- There are some cases when we need to know non-ID pointers for function
bindings. This mainly applies to scene collections and armatures. The
idea of dealing with this is to "expand" copy-on-write datablock at
the dependency graph build time. This might introduce some slowdown to the
dependency graph construction time, but allows us to have minimal changes
in the code and avoid any hash look-up from evaluation function (one of
the ideas to avoid using pointers as function bindings is to pass name
of layer or a bone to the evaluation function and look up actual data based
on that name).
Currently there is a special function in depsgraph which does such a
synchronization, in the future we might want to make it more generic.
At some point we need to synchronize copy-on-write version of datablock with
the original version. This happens, i.e., when we change active object or
change selection. We don't want any actual evaluation of update flush happening
for such thins, so now we have a special update tag:
DEG_id_tag_update((id, DEG_TAG_COPY_ON_WRITE)
- For the render engines we now have special call for the dependency graph to
give evaluated datablock for the given original one. This isn't fully ideal
but allows to have Cycles viewport render.
This is definitely a subject for further investigation / improvement.
This call will tag copy-on-write component tagged for update without causing
updates to be flushed to any other objects, causing chain reaction of updates.
This tag is handy when selection in the scene changes.
This basically summarizes ideas underneath this commit. The code should be
reasonably documented.
Here is a demo of dependency graph with all copy-on-write stuff in it:
https://developer.blender.org/F635468
= What to expect to (not) work? =
- Only meshes are properly-ish aware of copy-on-write currently, Non-mesh
geometry will probably crash or will not work at all.
- Armatures will need similar depsgraph built-time expansion of the copied
datablock.
- There are some extra tags / relations added, to keep things demo-able but
which are slowing things down for evaluation.
- Edit mode works for until click selection is used (due to the selection
code using EditDerivedMesh created ad-hoc).
- Lots of tools will lack tagging synchronization of copied datablock for
sync with original ID.
= How to move forward? =
There is some tedious work related on going over all the tools, checking
whether they need to work with original or final evaluated object and make
the required changes.
Additionally, there need synchronization tag done in fair amount of tools
and operators as well. For example, currently it's not possible to change
render engine without re-opening the file or forcing dependency graph for
re-build via python console.
There is also now some thoughts required about copying evaluated properties
between objects or from collection to a new object. Perhaps easiest way
would be to move base flag flush to Object ID node and tag new objects for
update instead of doing manual copy.
here is some WIP patch which moves such evaluaiton / flush:
https://developer.blender.org/F635479
Lots of TODOs in the code, with possible optimization.
= How to test? =
This is a feature under heavy development, so obviously it is disabled by
default. The only reason it goes to 2.8 branch is to avoid possible merge
hell.
In order to enable this feature use WITH_DEPSGRAPH_COPY_ON_WRITE CMake
configuration option.
2017-06-14 10:26:24 +02:00
|
|
|
|
WIP COW Fix: Insert keyframe operators/api now queries depsgraph for evaluated data
When using copy on write, insert keyframe operators were reading from old
bmain data instead of COW data. This meant that inserting keyframes would
often read old/stale data, resulting in invalid keyframes getting created
(e.g. from last transform operation, instead of actual current state).
This commit makes it so that keyframing operators will ask depsgraph for
the evaluated copy of the data, so that it can read values from that. It
introduces a new function - `DEG_get_evaluated_rna_pointer()`, which when
working correctly/fully, should work just like the other `DEG_get_evaluated_*()`
functions, except it lets you pass in an RNA Pointer.
However, currently, this is only done for Pose Bones (as a dirty hack, since this
is an important/pivotal requirement for production) and/or datablock
properties directly (since we can just use the DEG_get_evaluated_id() directly).
on the datablock.
Committing to a branch for now as this all needs more testing. More work to come
later at a more sane time of day!
2018-05-18 20:36:48 +02:00
|
|
|
/* Get evaluated version of data pointed to by RNA pointer */
|
|
|
|
void DEG_get_evaluated_rna_pointer(const struct Depsgraph *depsgraph,
|
2018-05-19 19:12:26 +02:00
|
|
|
struct PointerRNA *ptr,
|
WIP COW Fix: Insert keyframe operators/api now queries depsgraph for evaluated data
When using copy on write, insert keyframe operators were reading from old
bmain data instead of COW data. This meant that inserting keyframes would
often read old/stale data, resulting in invalid keyframes getting created
(e.g. from last transform operation, instead of actual current state).
This commit makes it so that keyframing operators will ask depsgraph for
the evaluated copy of the data, so that it can read values from that. It
introduces a new function - `DEG_get_evaluated_rna_pointer()`, which when
working correctly/fully, should work just like the other `DEG_get_evaluated_*()`
functions, except it lets you pass in an RNA Pointer.
However, currently, this is only done for Pose Bones (as a dirty hack, since this
is an important/pivotal requirement for production) and/or datablock
properties directly (since we can just use the DEG_get_evaluated_id() directly).
on the datablock.
Committing to a branch for now as this all needs more testing. More work to come
later at a more sane time of day!
2018-05-18 20:36:48 +02:00
|
|
|
struct PointerRNA *r_ptr_eval);
|
2018-04-20 11:01:43 +02:00
|
|
|
|
|
|
|
/* Get original version of object for given evaluated one. */
|
|
|
|
struct Object *DEG_get_original_object(struct Object *object);
|
|
|
|
|
|
|
|
/* Get original version of given evaluated ID datablock. */
|
|
|
|
struct ID *DEG_get_original_id(struct ID *id);
|
|
|
|
|
2019-05-09 15:50:46 +02:00
|
|
|
/* Check whether given ID is an original,
|
|
|
|
*
|
|
|
|
* Original IDs are considered all the IDs which are not covered by copy-on-write system and are
|
2019-06-12 09:04:10 +10:00
|
|
|
* not out-of-main localized data-blocks. */
|
2020-04-29 12:36:33 +10:00
|
|
|
bool DEG_is_original_id(const struct ID *id);
|
|
|
|
bool DEG_is_original_object(const struct Object *object);
|
2019-05-09 15:50:46 +02:00
|
|
|
|
|
|
|
/* Opposite of the above.
|
|
|
|
*
|
2019-06-12 09:04:10 +10:00
|
|
|
* If the data-block is not original it must be evaluated, and vice versa. */
|
2020-04-29 12:36:33 +10:00
|
|
|
bool DEG_is_evaluated_id(const struct ID *id);
|
|
|
|
bool DEG_is_evaluated_object(const struct Object *object);
|
2019-05-09 15:50:46 +02:00
|
|
|
|
2019-05-28 15:42:08 +02:00
|
|
|
/* Check whether depsgraph os fully evaluated. This includes the following checks:
|
|
|
|
* - Relations are up-to-date.
|
|
|
|
* - Nothing is tagged for update. */
|
|
|
|
bool DEG_is_fully_evaluated(const struct Depsgraph *depsgraph);
|
|
|
|
|
2018-05-29 15:57:14 +02:00
|
|
|
/* ************************ DEG object iterators ********************* */
|
2017-04-21 11:42:59 +02:00
|
|
|
|
2017-06-01 15:26:47 +02:00
|
|
|
enum {
|
2017-12-15 07:51:16 -02:00
|
|
|
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY = (1 << 0),
|
|
|
|
DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY = (1 << 1),
|
|
|
|
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET = (1 << 2),
|
|
|
|
DEG_ITER_OBJECT_FLAG_VISIBLE = (1 << 3),
|
|
|
|
DEG_ITER_OBJECT_FLAG_DUPLI = (1 << 4),
|
2017-11-30 16:46:33 +01:00
|
|
|
};
|
2017-06-01 15:26:47 +02:00
|
|
|
|
2017-12-15 08:11:19 -02:00
|
|
|
typedef struct DEGObjectIterData {
|
2017-06-01 15:26:47 +02:00
|
|
|
struct Depsgraph *graph;
|
2018-04-09 15:01:41 +02:00
|
|
|
int flag;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-06-01 15:26:47 +02:00
|
|
|
struct Scene *scene;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-18 18:18:00 +01:00
|
|
|
eEvaluationMode eval_mode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-02 13:28:08 +01:00
|
|
|
/* **** Iteration over geometry components **** */
|
|
|
|
|
|
|
|
/* The object whose components we currently iterate over.
|
|
|
|
* This might point to #temp_dupli_object. */
|
|
|
|
struct Object *geometry_component_owner;
|
|
|
|
/* Some identifier that is used to determine which geometry component should be returned next. */
|
|
|
|
int geometry_component_id;
|
|
|
|
/* Temporary storage for an object that is created from a component. */
|
|
|
|
struct Object temp_geometry_component_object;
|
|
|
|
|
2017-06-06 13:58:40 +02:00
|
|
|
/* **** Iteration over dupli-list. *** */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-06-06 13:58:40 +02:00
|
|
|
/* Object which created the dupli-list. */
|
|
|
|
struct Object *dupli_parent;
|
|
|
|
/* List of duplicated objects. */
|
2017-06-01 15:26:47 +02:00
|
|
|
struct ListBase *dupli_list;
|
2017-06-06 13:58:40 +02:00
|
|
|
/* Next duplicated object to step into. */
|
|
|
|
struct DupliObject *dupli_object_next;
|
|
|
|
/* Corresponds to current object: current iterator object is evaluated from
|
2019-01-31 12:56:40 +01:00
|
|
|
* this duplicated object. */
|
2017-06-06 13:58:40 +02:00
|
|
|
struct DupliObject *dupli_object_current;
|
|
|
|
/* Temporary storage to report fully populated DNA to the render engine or
|
2019-01-31 12:56:40 +01:00
|
|
|
* other users of the iterator. */
|
2017-06-01 15:26:47 +02:00
|
|
|
struct Object temp_dupli_object;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-09-21 10:07:57 +02:00
|
|
|
/* **** Iteration over ID nodes **** */
|
2017-11-08 14:37:31 +01:00
|
|
|
size_t id_node_index;
|
|
|
|
size_t num_id_nodes;
|
2017-12-15 08:11:19 -02:00
|
|
|
} DEGObjectIterData;
|
2017-06-01 15:26:47 +02:00
|
|
|
|
2017-12-15 08:11:19 -02:00
|
|
|
void DEG_iterator_objects_begin(struct BLI_Iterator *iter, DEGObjectIterData *data);
|
2017-11-30 16:44:35 +01:00
|
|
|
void DEG_iterator_objects_next(struct BLI_Iterator *iter);
|
|
|
|
void DEG_iterator_objects_end(struct BLI_Iterator *iter);
|
2017-04-21 11:42:59 +02:00
|
|
|
|
2017-12-15 07:51:16 -02:00
|
|
|
/**
|
|
|
|
* Note: Be careful with DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY objects.
|
|
|
|
* Although they are available they have no overrides (collection_properties)
|
|
|
|
* and will crash if you try to access it.
|
|
|
|
*/
|
2018-06-06 16:01:51 +02:00
|
|
|
#define DEG_OBJECT_ITER_BEGIN(graph_, instance_, flag_) \
|
2017-06-01 15:26:47 +02:00
|
|
|
{ \
|
2017-12-15 08:11:19 -02:00
|
|
|
DEGObjectIterData data_ = { \
|
2018-04-09 15:01:41 +02:00
|
|
|
graph_, \
|
2019-02-03 14:01:45 +11:00
|
|
|
flag_, \
|
2017-06-01 15:26:47 +02:00
|
|
|
}; \
|
|
|
|
\
|
2017-11-30 16:44:35 +01:00
|
|
|
ITER_BEGIN (DEG_iterator_objects_begin, \
|
|
|
|
DEG_iterator_objects_next, \
|
|
|
|
DEG_iterator_objects_end, \
|
2017-12-15 07:51:16 -02:00
|
|
|
&data_, \
|
|
|
|
Object *, \
|
|
|
|
instance_)
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-06-01 15:26:47 +02:00
|
|
|
#define DEG_OBJECT_ITER_END \
|
2018-03-09 11:44:42 +11:00
|
|
|
ITER_END; \
|
2019-04-02 17:54:04 +11:00
|
|
|
} \
|
|
|
|
((void)0)
|
2017-04-21 11:42:59 +02:00
|
|
|
|
2017-12-15 07:51:16 -02:00
|
|
|
/**
|
2019-03-19 15:17:46 +11:00
|
|
|
* Depsgraph objects iterator for draw manager and final render
|
|
|
|
*/
|
2018-06-06 16:01:51 +02:00
|
|
|
#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(graph_, instance_) \
|
|
|
|
DEG_OBJECT_ITER_BEGIN (graph_, \
|
|
|
|
instance_, \
|
2018-03-01 12:21:56 -03:00
|
|
|
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | \
|
|
|
|
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE | \
|
2017-12-15 07:51:16 -02:00
|
|
|
DEG_ITER_OBJECT_FLAG_DUPLI)
|
|
|
|
|
2018-03-01 12:21:56 -03:00
|
|
|
#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END DEG_OBJECT_ITER_END
|
2018-05-29 15:57:14 +02:00
|
|
|
|
|
|
|
/* ************************ DEG ID iterators ********************* */
|
|
|
|
|
|
|
|
typedef struct DEGIDIterData {
|
|
|
|
struct Depsgraph *graph;
|
|
|
|
bool only_updated;
|
|
|
|
|
|
|
|
size_t id_node_index;
|
|
|
|
size_t num_id_nodes;
|
|
|
|
} DEGIDIterData;
|
|
|
|
|
|
|
|
void DEG_iterator_ids_begin(struct BLI_Iterator *iter, DEGIDIterData *data);
|
|
|
|
void DEG_iterator_ids_next(struct BLI_Iterator *iter);
|
|
|
|
void DEG_iterator_ids_end(struct BLI_Iterator *iter);
|
|
|
|
|
2017-12-01 11:35:36 +01:00
|
|
|
/* ************************ DEG traversal ********************* */
|
|
|
|
|
|
|
|
typedef void (*DEGForeachIDCallback)(ID *id, void *user_data);
|
2019-07-04 15:04:03 +02:00
|
|
|
typedef void (*DEGForeachIDComponentCallback)(ID *id,
|
|
|
|
eDepsObjectComponentType component,
|
|
|
|
void *user_data);
|
2017-12-01 11:35:36 +01:00
|
|
|
|
|
|
|
/* NOTE: Modifies runtime flags in depsgraph nodes, so can not be used in
|
|
|
|
* parallel. Keep an eye on that!
|
|
|
|
*/
|
2018-08-21 16:20:54 +12:00
|
|
|
void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph,
|
|
|
|
const ID *id,
|
|
|
|
DEGForeachIDCallback callback,
|
|
|
|
void *user_data);
|
2017-12-01 11:35:36 +01:00
|
|
|
void DEG_foreach_dependent_ID(const Depsgraph *depsgraph,
|
|
|
|
const ID *id,
|
|
|
|
DEGForeachIDCallback callback,
|
|
|
|
void *user_data);
|
|
|
|
|
2019-07-04 15:13:26 +02:00
|
|
|
/* Starts traversal from given component of the given ID, invokes callback for every other
|
|
|
|
* component which is directly on indirectly dependent on the source one. */
|
2019-09-26 11:23:00 +02:00
|
|
|
enum {
|
|
|
|
/* Ignore transform solvers which depends on multiple inputs and affects final transform.
|
|
|
|
* Is used for cases like snapping objects which are part of a rigid body simulation:
|
2019-09-30 17:06:28 +10:00
|
|
|
* without this there will be "false-positive" dependencies between transform components of
|
2019-09-26 11:23:00 +02:00
|
|
|
* objects:
|
|
|
|
*
|
|
|
|
* object 1 transform before solver ---> solver ------> object 1 final transform
|
|
|
|
* object 2 transform before solver -----^ \------> object 2 final transform
|
|
|
|
*/
|
2020-03-19 13:18:17 -03:00
|
|
|
DEG_FOREACH_COMPONENT_IGNORE_TRANSFORM_SOLVERS = (1 << 0),
|
2019-09-26 11:23:00 +02:00
|
|
|
};
|
2019-07-04 15:04:03 +02:00
|
|
|
void DEG_foreach_dependent_ID_component(const Depsgraph *depsgraph,
|
|
|
|
const ID *id,
|
2019-07-04 15:15:02 +02:00
|
|
|
eDepsObjectComponentType source_component_type,
|
2019-09-26 11:23:00 +02:00
|
|
|
int flags,
|
2019-07-04 15:04:03 +02:00
|
|
|
DEGForeachIDComponentCallback callback,
|
|
|
|
void *user_data);
|
|
|
|
|
2018-05-02 16:31:05 +02:00
|
|
|
void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback, void *user_data);
|
|
|
|
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|