2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2014 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2015-05-12 12:50:24 +05:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2015-05-12 12:50:24 +05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "DNA_anim_types.h"
|
2018-08-29 15:32:50 +02:00
|
|
|
#include "DNA_collection_types.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
#include "DNA_constraint_types.h"
|
2023-03-13 10:42:51 +01:00
|
|
|
#include "DNA_gpencil_legacy_types.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
#include "DNA_key_types.h"
|
|
|
|
|
#include "DNA_material_types.h"
|
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
|
|
|
#include "DNA_mesh_types.h"
|
2020-12-15 10:47:58 +11:00
|
|
|
#include "DNA_modifier_types.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 11:39:20 +03:00
|
|
|
#include "BLI_math_matrix.h"
|
|
|
|
|
#include "BLI_math_vector.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_threads.h"
|
|
|
|
|
#include "BLI_utildefines.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
|
#include "BKE_action.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
#include "BKE_armature.h"
|
|
|
|
|
#include "BKE_constraint.h"
|
2017-04-21 21:14:11 +10:00
|
|
|
#include "BKE_curve.h"
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
#include "BKE_curves.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
#include "BKE_displist.h"
|
2018-06-11 12:14:18 +02:00
|
|
|
#include "BKE_editmesh.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
#include "BKE_effect.h"
|
2023-03-13 10:42:51 +01:00
|
|
|
#include "BKE_gpencil_legacy.h"
|
|
|
|
|
#include "BKE_gpencil_modifier_legacy.h"
|
2023-05-30 11:14:16 +02:00
|
|
|
#include "BKE_grease_pencil.h"
|
|
|
|
|
#include "BKE_grease_pencil.hh"
|
2018-06-11 12:14:18 +02:00
|
|
|
#include "BKE_image.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
#include "BKE_key.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_lattice.h"
|
2019-02-27 17:09:30 +01:00
|
|
|
#include "BKE_layer.h"
|
2019-02-27 12:34:56 +11:00
|
|
|
#include "BKE_light.h"
|
2018-06-11 12:14:18 +02:00
|
|
|
#include "BKE_material.h"
|
2018-06-11 14:39:38 +02:00
|
|
|
#include "BKE_mball.h"
|
2023-03-12 22:29:15 +01:00
|
|
|
#include "BKE_mesh.hh"
|
2023-10-09 23:41:53 +02:00
|
|
|
#include "BKE_object.hh"
|
2016-12-28 17:30:58 +01:00
|
|
|
#include "BKE_particle.h"
|
2017-03-15 11:10:42 +01:00
|
|
|
#include "BKE_pointcache.h"
|
2020-03-17 14:41:48 +01:00
|
|
|
#include "BKE_pointcloud.h"
|
2015-05-12 12:50:24 +05:00
|
|
|
#include "BKE_scene.h"
|
2020-03-17 14:41:48 +01:00
|
|
|
#include "BKE_volume.h"
|
2015-05-12 12:50:24 +05: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
|
|
|
#include "MEM_guardedalloc.h"
|
2018-04-06 12:07:27 +02:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
2023-05-24 13:36:13 +02:00
|
|
|
#include "DEG_depsgraph_light_linking.hh"
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph_query.hh"
|
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
|
|
|
|
2023-05-24 13:36:13 +02:00
|
|
|
namespace deg = blender::deg;
|
|
|
|
|
|
2018-12-14 08:40:33 -02:00
|
|
|
void BKE_object_eval_reset(Object *ob_eval)
|
|
|
|
|
{
|
|
|
|
|
BKE_object_free_derived_caches(ob_eval);
|
|
|
|
|
}
|
2015-05-12 13:57:11 +05:00
|
|
|
|
2018-05-02 11:46:56 +02:00
|
|
|
void BKE_object_eval_local_transform(Depsgraph *depsgraph, Object *ob)
|
2015-05-12 13:57:11 +05:00
|
|
|
{
|
2018-05-02 11:46:56 +02:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob);
|
2015-05-12 13:57:11 +05:00
|
|
|
|
|
|
|
|
/* calculate local matrix */
|
2022-10-24 14:16:37 +02:00
|
|
|
BKE_object_to_mat4(ob, ob->object_to_world);
|
2015-05-12 13:57:11 +05:00
|
|
|
}
|
|
|
|
|
|
2018-12-19 11:20:32 +01:00
|
|
|
void BKE_object_eval_parent(Depsgraph *depsgraph, Object *ob)
|
2015-05-12 13:57:11 +05:00
|
|
|
{
|
2021-12-07 17:19:15 +11:00
|
|
|
/* NOTE: based on `solve_parenting()`, but with the cruft stripped out. */
|
|
|
|
|
|
2015-05-12 13:57:11 +05:00
|
|
|
Object *par = ob->parent;
|
|
|
|
|
|
|
|
|
|
float totmat[4][4];
|
|
|
|
|
float tmat[4][4];
|
|
|
|
|
float locmat[4][4];
|
|
|
|
|
|
2018-05-02 11:46:56 +02:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob);
|
2015-05-12 13:57:11 +05:00
|
|
|
|
|
|
|
|
/* get local matrix (but don't calculate it, as that was done already!) */
|
|
|
|
|
/* XXX: redundant? */
|
2022-10-24 14:16:37 +02:00
|
|
|
copy_m4_m4(locmat, ob->object_to_world);
|
2015-05-12 13:57:11 +05:00
|
|
|
|
|
|
|
|
/* get parent effect matrix */
|
2018-12-19 11:20:32 +01:00
|
|
|
BKE_object_get_parent_matrix(ob, par, totmat);
|
2015-05-12 13:57:11 +05:00
|
|
|
|
|
|
|
|
/* total */
|
|
|
|
|
mul_m4_m4m4(tmat, totmat, ob->parentinv);
|
2022-10-24 14:16:37 +02:00
|
|
|
mul_m4_m4m4(ob->object_to_world, tmat, locmat);
|
2015-05-12 13:57:11 +05:00
|
|
|
|
|
|
|
|
/* origin, for help line */
|
|
|
|
|
if ((ob->partype & PARTYPE) == PARSKEL) {
|
2022-10-24 14:16:37 +02:00
|
|
|
copy_v3_v3(ob->runtime.parent_display_origin, par->object_to_world[3]);
|
2015-05-12 13:57:11 +05:00
|
|
|
}
|
|
|
|
|
else {
|
2019-02-19 11:37:27 +11:00
|
|
|
copy_v3_v3(ob->runtime.parent_display_origin, totmat[3]);
|
2015-05-12 13:57:11 +05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
void BKE_object_eval_constraints(Depsgraph *depsgraph, Scene *scene, Object *ob)
|
2015-05-12 13:57:11 +05:00
|
|
|
{
|
|
|
|
|
bConstraintOb *cob;
|
2021-07-12 16:15:03 +02:00
|
|
|
float ctime = BKE_scene_ctime_get(scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-02 11:46:56 +02:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-05-12 13:57:11 +05:00
|
|
|
/* evaluate constraints stack */
|
|
|
|
|
/* TODO: split this into:
|
|
|
|
|
* - pre (i.e. BKE_constraints_make_evalob, per-constraint (i.e.
|
|
|
|
|
* - inner body of BKE_constraints_solve),
|
|
|
|
|
* - post (i.e. BKE_constraints_clear_evalob)
|
|
|
|
|
*
|
|
|
|
|
* Not sure why, this is from Joshua - sergey
|
|
|
|
|
*/
|
2022-09-29 17:11:20 -05:00
|
|
|
cob = BKE_constraints_make_evalob(depsgraph, scene, ob, nullptr, CONSTRAINT_OBTYPE_OBJECT);
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime);
|
2015-05-12 13:57:11 +05:00
|
|
|
BKE_constraints_clear_evalob(cob);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-21 14:52:42 +01:00
|
|
|
void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob)
|
2015-05-12 13:57:11 +05:00
|
|
|
{
|
2018-05-02 11:46:56 +02:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob);
|
2019-01-28 12:17:54 +01:00
|
|
|
/* Make sure inverse matrix is always up to date. This way users of it
|
2019-06-12 09:04:10 +10:00
|
|
|
* do not need to worry about recalculating it. */
|
2022-11-02 14:41:49 +01:00
|
|
|
invert_m4_m4_safe(ob->world_to_object, ob->object_to_world);
|
2015-05-12 13:57:11 +05:00
|
|
|
/* Set negative scale flag in object. */
|
2022-10-24 14:16:37 +02:00
|
|
|
if (is_negative_m4(ob->object_to_world)) {
|
2015-05-12 13:57:11 +05:00
|
|
|
ob->transflag |= OB_NEG_SCALE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2015-05-12 13:57:11 +05:00
|
|
|
ob->transflag &= ~OB_NEG_SCALE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-05-12 13:57:11 +05:00
|
|
|
}
|
|
|
|
|
|
2017-08-16 12:45:11 +10:00
|
|
|
void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
|
2015-05-12 12:50:24 +05:00
|
|
|
{
|
2018-10-29 16:37:00 +01:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob);
|
2015-05-12 12:50:24 +05:00
|
|
|
|
|
|
|
|
/* includes all keys and modifiers */
|
|
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH: {
|
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
|
|
|
CustomData_MeshMasks cddata_masks = scene->customdata_mask;
|
|
|
|
|
CustomData_MeshMasks_update(&cddata_masks, &CD_MASK_BAREMESH);
|
2021-04-16 11:28:23 +02:00
|
|
|
/* Custom attributes should not be removed automatically. They might be used by the render
|
2023-01-10 20:07:47 -05:00
|
|
|
* engine or scripts. They can still be removed explicitly using geometry nodes. Crease and
|
|
|
|
|
* vertex groups can be used in arbitrary situations with geometry nodes as well. */
|
2023-06-13 20:23:39 +02:00
|
|
|
cddata_masks.vmask |= CD_MASK_PROP_ALL | CD_MASK_MDEFORMVERT;
|
|
|
|
|
cddata_masks.emask |= CD_MASK_PROP_ALL;
|
2021-04-16 11:28:23 +02:00
|
|
|
cddata_masks.fmask |= CD_MASK_PROP_ALL;
|
|
|
|
|
cddata_masks.pmask |= CD_MASK_PROP_ALL;
|
|
|
|
|
cddata_masks.lmask |= CD_MASK_PROP_ALL;
|
Refactor: Move normals out of MVert, lazy calculation
As described in T91186, this commit moves mesh vertex normals into a
contiguous array of float vectors in a custom data layer, how face
normals are currently stored.
The main interface is documented in `BKE_mesh.h`. Vertex and face
normals are now calculated on-demand and cached, retrieved with an
"ensure" function. Since the logical state of a mesh is now "has
normals when necessary", they can be retrieved from a `const` mesh.
The goal is to use on-demand calculation for all derived data, but
leave room for eager calculation for performance purposes (modifier
evaluation is threaded, but viewport data generation is not).
**Benefits**
This moves us closer to a SoA approach rather than the current AoS
paradigm. Accessing a contiguous `float3` is much more efficient than
retrieving data from a larger struct. The memory requirements for
accessing only normals or vertex locations are smaller, and at the
cost of more memory usage for just normals, they now don't have to
be converted between float and short, which also simplifies code
In the future, the remaining items can be removed from `MVert`,
leaving only `float3`, which has similar benefits (see T93602).
Removing the combination of derived and original data makes it
conceptually simpler to only calculate normals when necessary.
This is especially important now that we have more opportunities
for temporary meshes in geometry nodes.
**Performance**
In addition to the theoretical future performance improvements by
making `MVert == float3`, I've done some basic performance testing
on this patch directly. The data is fairly rough, but it gives an idea
about where things stand generally.
- Mesh line primitive 4m Verts: 1.16x faster (36 -> 31 ms),
showing that accessing just `MVert` is now more efficient.
- Spring Splash Screen: 1.03-1.06 -> 1.06-1.11 FPS, a very slight
change that at least shows there is no regression.
- Sprite Fright Snail Smoosh: 3.30-3.40 -> 3.42-3.50 FPS, a small
but observable speedup.
- Set Position Node with Scaled Normal: 1.36x faster (53 -> 39 ms),
shows that using normals in geometry nodes is faster.
- Normal Calculation 1.6m Vert Cube: 1.19x faster (25 -> 21 ms),
shows that calculating normals is slightly faster now.
- File Size of 1.6m Vert Cube: 1.03x smaller (214.7 -> 208.4 MB),
Normals are not saved in files, which can help with large meshes.
As for memory usage, it may be slightly more in some cases, but
I didn't observe any difference in the production files I tested.
**Tests**
Some modifiers and cycles test results need to be updated with this
commit, for two reasons:
- The subdivision surface modifier is not responsible for calculating
normals anymore. In master, the modifier creates different normals
than the result of the `Mesh` normal calculation, so this is a bug
fix.
- There are small differences in the results of some modifiers that
use normals because they are not converted to and from `short`
anymore.
**Future improvements**
- Remove `ModifierTypeInfo::dependsOnNormals`. Code in each modifier
already retrieves normals if they are needed anyway.
- Copy normals as part of a better CoW system for attributes.
- Make more areas use lazy instead of eager normal calculation.
- Remove `BKE_mesh_normals_tag_dirty` in more places since that is
now the default state of a new mesh.
- Possibly apply a similar change to derived face corner normals.
Differential Revision: https://developer.blender.org/D12770
2022-01-13 14:37:58 -06:00
|
|
|
|
2023-02-12 14:37:16 +11:00
|
|
|
/* Make sure Freestyle edge/face marks appear in DM for render (see #40315).
|
2021-03-21 13:18:20 +11:00
|
|
|
* Due to Line Art implementation, edge marks should also be shown in viewport. */
|
2015-05-12 12:50:24 +05:00
|
|
|
#ifdef WITH_FREESTYLE
|
2021-03-16 19:35:53 +01:00
|
|
|
cddata_masks.emask |= CD_MASK_FREESTYLE_EDGE;
|
|
|
|
|
cddata_masks.pmask |= CD_MASK_FREESTYLE_FACE;
|
2015-05-12 12:50:24 +05:00
|
|
|
#endif
|
2021-03-16 19:35:53 +01:00
|
|
|
if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) {
|
2019-06-13 19:56:25 +02:00
|
|
|
/* Always compute UVs, vertex colors as orcos for render. */
|
2023-01-10 20:07:47 -05:00
|
|
|
cddata_masks.vmask |= CD_MASK_ORCO;
|
2019-06-13 19:56:25 +02:00
|
|
|
}
|
2022-01-11 15:42:07 +01:00
|
|
|
makeDerivedMesh(depsgraph, scene, ob, &cddata_masks); /* was CD_MASK_BAREMESH */
|
2015-05-12 12:50:24 +05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case OB_ARMATURE:
|
2022-02-03 17:57:40 +01:00
|
|
|
BKE_pose_where_is(depsgraph, scene, ob);
|
2015-05-12 12:50:24 +05:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-05-12 12:50:24 +05:00
|
|
|
case OB_MBALL:
|
2022-08-17 10:20:25 -04:00
|
|
|
BKE_mball_data_update(depsgraph, scene, ob);
|
2015-05-12 12:50:24 +05:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-02-18 09:50:29 -06:00
|
|
|
case OB_CURVES_LEGACY:
|
2015-05-12 12:50:24 +05:00
|
|
|
case OB_SURF:
|
2019-05-13 15:24:43 +02:00
|
|
|
case OB_FONT: {
|
|
|
|
|
bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
|
2021-06-28 15:14:43 -05:00
|
|
|
BKE_displist_make_curveTypes(depsgraph, scene, ob, for_render);
|
2015-05-12 12:50:24 +05:00
|
|
|
break;
|
2019-05-13 15:24:43 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-05-12 12:50:24 +05:00
|
|
|
case OB_LATTICE:
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_lattice_modifiers_calc(depsgraph, scene, ob);
|
2015-05-12 12:50:24 +05:00
|
|
|
break;
|
2023-03-08 12:35:58 +01:00
|
|
|
case OB_GPENCIL_LEGACY: {
|
2020-03-09 16:27:24 +01:00
|
|
|
BKE_gpencil_prepare_eval_data(depsgraph, scene, ob);
|
2019-08-23 23:10:41 +02:00
|
|
|
BKE_gpencil_modifiers_calc(depsgraph, scene, ob);
|
2021-01-16 15:33:38 +01:00
|
|
|
BKE_gpencil_update_layer_transforms(depsgraph, ob);
|
2019-08-23 23:10:41 +02:00
|
|
|
break;
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
case OB_CURVES:
|
|
|
|
|
BKE_curves_data_update(depsgraph, scene, ob);
|
2020-03-17 14:41:48 +01:00
|
|
|
break;
|
|
|
|
|
case OB_POINTCLOUD:
|
|
|
|
|
BKE_pointcloud_data_update(depsgraph, scene, ob);
|
|
|
|
|
break;
|
|
|
|
|
case OB_VOLUME:
|
|
|
|
|
BKE_volume_data_update(depsgraph, scene, ob);
|
|
|
|
|
break;
|
2023-05-30 11:14:16 +02:00
|
|
|
case OB_GREASE_PENCIL:
|
|
|
|
|
BKE_grease_pencil_data_update(depsgraph, scene, ob);
|
|
|
|
|
break;
|
2015-05-12 12:50:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
/* particles */
|
2018-04-13 12:51:49 +02:00
|
|
|
if (!(ob->mode & OB_MODE_EDIT) && ob->particlesystem.first) {
|
2018-04-06 12:07:27 +02:00
|
|
|
const bool use_render_params = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
|
2016-12-28 17:30:58 +01:00
|
|
|
ParticleSystem *tpsys, *psys;
|
|
|
|
|
ob->transflag &= ~OB_DUPLIPARTS;
|
2022-09-29 17:11:20 -05:00
|
|
|
psys = static_cast<ParticleSystem *>(ob->particlesystem.first);
|
2016-12-28 17:30:58 +01:00
|
|
|
while (psys) {
|
2018-04-06 12:07:27 +02:00
|
|
|
if (psys_check_enabled(ob, psys, use_render_params)) {
|
2016-12-28 17:30:58 +01:00
|
|
|
/* check use of dupli objects here */
|
2018-04-06 12:07:27 +02:00
|
|
|
if (psys->part && (psys->part->draw_as == PART_DRAW_REND || use_render_params) &&
|
2019-02-17 19:00:54 +11:00
|
|
|
((psys->part->ren_as == PART_DRAW_OB && psys->part->instance_object) ||
|
|
|
|
|
(psys->part->ren_as == PART_DRAW_GR && psys->part->instance_collection)))
|
|
|
|
|
{
|
2016-12-28 17:30:58 +01:00
|
|
|
ob->transflag |= OB_DUPLIPARTS;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
particle_system_update(depsgraph, scene, ob, psys, use_render_params);
|
2016-12-28 17:30:58 +01:00
|
|
|
psys = psys->next;
|
|
|
|
|
}
|
|
|
|
|
else if (psys->flag & PSYS_DELETE) {
|
|
|
|
|
tpsys = psys->next;
|
|
|
|
|
BLI_remlink(&ob->particlesystem, psys);
|
|
|
|
|
psys_free(ob, psys);
|
|
|
|
|
psys = tpsys;
|
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2016-12-28 17:30:58 +01:00
|
|
|
psys = psys->next;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
}
|
|
|
|
|
}
|
2018-11-21 15:02:36 +01:00
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
|
2020-12-08 17:57:16 +01:00
|
|
|
/** Bounding box from evaluated geometry. */
|
|
|
|
|
static void object_sync_boundbox_to_original(Object *object_orig, Object *object_eval)
|
2018-11-21 15:02:36 +01:00
|
|
|
{
|
Refactor: Improve access to object data bounds
Currently object bounds (`object.runtime.bb`) are lazily initialized
when accessed. This access happens from arbitrary threads, and
is unprotected by a mutex. This can cause access to stale data at
best, and crashes at worst. Eager calculation is meant to keep this
working, but it's fragile.
Since e8f4010611e7, geometry bounds are cached in the geometry
itself, which makes this object-level cache redundant. So, it's clearer
to build the `BoundBox` from those cached bounds and return it by
value, without interacting with the object's cached bounding box.
The code change is is mostly a move from `const BoundBox *` to
`std::optional<BoundBox>`. This is only one step of a larger change
described in #96968. Followup steps would include switching to
a simpler and smaller `Bounds` type, removing redundant object-
level access, and eventually removing `object.runtime.bb`.
Access of bounds from the object for mesh, curves, and point cloud
objects should now be thread-safe. Other object types still lazily
initialize the object `BoundBox` cache since they don't have
a data-level cache.
Pull Request: https://projects.blender.org/blender/blender/pulls/113465
2023-10-19 14:18:40 +02:00
|
|
|
if (!object_eval->runtime.bb || (object_eval->runtime.bb->flag & BOUNDBOX_DIRTY)) {
|
2021-11-24 14:32:19 -03:00
|
|
|
BKE_object_boundbox_calc_from_evaluated_geometry(object_eval);
|
|
|
|
|
}
|
|
|
|
|
|
Refactor: Improve access to object data bounds
Currently object bounds (`object.runtime.bb`) are lazily initialized
when accessed. This access happens from arbitrary threads, and
is unprotected by a mutex. This can cause access to stale data at
best, and crashes at worst. Eager calculation is meant to keep this
working, but it's fragile.
Since e8f4010611e7, geometry bounds are cached in the geometry
itself, which makes this object-level cache redundant. So, it's clearer
to build the `BoundBox` from those cached bounds and return it by
value, without interacting with the object's cached bounding box.
The code change is is mostly a move from `const BoundBox *` to
`std::optional<BoundBox>`. This is only one step of a larger change
described in #96968. Followup steps would include switching to
a simpler and smaller `Bounds` type, removing redundant object-
level access, and eventually removing `object.runtime.bb`.
Access of bounds from the object for mesh, curves, and point cloud
objects should now be thread-safe. Other object types still lazily
initialize the object `BoundBox` cache since they don't have
a data-level cache.
Pull Request: https://projects.blender.org/blender/blender/pulls/113465
2023-10-19 14:18:40 +02:00
|
|
|
if (const std::optional<BoundBox> bb = BKE_object_boundbox_get(object_eval)) {
|
2022-09-29 17:11:20 -05:00
|
|
|
if (object_orig->runtime.bb == nullptr) {
|
|
|
|
|
object_orig->runtime.bb = MEM_new<BoundBox>(__func__);
|
2018-11-21 15:02:36 +01:00
|
|
|
}
|
2020-12-08 17:57:16 +01:00
|
|
|
*object_orig->runtime.bb = *bb;
|
2018-11-21 15:02:36 +01:00
|
|
|
}
|
2015-05-12 12:50:24 +05:00
|
|
|
}
|
2015-05-12 13:57:11 +05:00
|
|
|
|
2020-04-03 16:46:34 +11:00
|
|
|
void BKE_object_sync_to_original(Depsgraph *depsgraph, Object *object)
|
2018-12-04 16:04:10 +01:00
|
|
|
{
|
|
|
|
|
if (!DEG_is_active(depsgraph)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Object *object_orig = DEG_get_original_object(object);
|
|
|
|
|
/* Base flags. */
|
|
|
|
|
object_orig->base_flag = object->base_flag;
|
|
|
|
|
/* Transformation flags. */
|
2022-10-24 14:16:37 +02:00
|
|
|
copy_m4_m4(object_orig->object_to_world, object->object_to_world);
|
2022-11-02 14:41:49 +01:00
|
|
|
copy_m4_m4(object_orig->world_to_object, object->world_to_object);
|
2018-12-04 16:04:10 +01:00
|
|
|
copy_m4_m4(object_orig->constinv, object->constinv);
|
|
|
|
|
object_orig->transflag = object->transflag;
|
|
|
|
|
object_orig->flag = object->flag;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-04 17:07:47 +01:00
|
|
|
/* Copy back error messages from modifiers. */
|
2022-09-29 17:11:20 -05:00
|
|
|
for (ModifierData *md = static_cast<ModifierData *>(object->modifiers.first),
|
|
|
|
|
*md_orig = static_cast<ModifierData *>(object_orig->modifiers.first);
|
|
|
|
|
md != nullptr && md_orig != nullptr;
|
2018-12-04 17:07:47 +01:00
|
|
|
md = md->next, md_orig = md_orig->next)
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(md->type == md_orig->type && STREQ(md->name, md_orig->name));
|
|
|
|
|
MEM_SAFE_FREE(md_orig->error);
|
2022-09-29 17:11:20 -05:00
|
|
|
if (md->error != nullptr) {
|
2018-12-04 17:07:47 +01:00
|
|
|
md_orig->error = BLI_strdup(md->error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-08 17:57:16 +01:00
|
|
|
|
|
|
|
|
object_sync_boundbox_to_original(object_orig, object);
|
2018-12-04 16:04:10 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
void BKE_object_eval_uber_transform(Depsgraph * /*depsgraph*/, Object * /*object*/) {}
|
2015-05-12 13:57:11 +05:00
|
|
|
|
2022-08-09 13:03:35 -05:00
|
|
|
void BKE_object_batch_cache_dirty_tag(Object *ob)
|
2015-05-12 13:57:11 +05:00
|
|
|
{
|
2022-08-09 13:03:35 -05:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_mesh_batch_cache_dirty_tag((Mesh *)ob->data, BKE_MESH_BATCH_DIRTY_ALL);
|
2017-04-13 22:09:59 +10:00
|
|
|
break;
|
2022-08-09 13:03:35 -05:00
|
|
|
case OB_LATTICE:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_lattice_batch_cache_dirty_tag((Lattice *)ob->data, BKE_LATTICE_BATCH_DIRTY_ALL);
|
2017-04-13 22:09:59 +10:00
|
|
|
break;
|
2022-08-09 13:03:35 -05:00
|
|
|
case OB_CURVES_LEGACY:
|
2022-10-19 11:33:19 +02:00
|
|
|
case OB_SURF:
|
|
|
|
|
case OB_FONT:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_curve_batch_cache_dirty_tag((Curve *)ob->data, BKE_CURVE_BATCH_DIRTY_ALL);
|
2017-04-15 16:46:17 +10:00
|
|
|
break;
|
2022-08-17 10:20:25 -04:00
|
|
|
case OB_MBALL: {
|
|
|
|
|
/* This function is currently called on original objects, so to properly
|
|
|
|
|
* clear the actual displayed geometry, we have to tag the evaluated mesh. */
|
|
|
|
|
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(ob);
|
|
|
|
|
if (mesh) {
|
|
|
|
|
BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL);
|
|
|
|
|
}
|
2017-11-16 15:12:32 -02:00
|
|
|
break;
|
2022-08-17 10:20:25 -04:00
|
|
|
}
|
2023-03-08 12:35:58 +01:00
|
|
|
case OB_GPENCIL_LEGACY:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_gpencil_batch_cache_dirty_tag((bGPdata *)ob->data);
|
2018-07-31 10:22:19 +02:00
|
|
|
break;
|
2022-08-09 13:03:35 -05:00
|
|
|
case OB_CURVES:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_curves_batch_cache_dirty_tag((Curves *)ob->data, BKE_CURVES_BATCH_DIRTY_ALL);
|
2020-03-17 14:41:48 +01:00
|
|
|
break;
|
2022-08-09 13:03:35 -05:00
|
|
|
case OB_POINTCLOUD:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_pointcloud_batch_cache_dirty_tag((PointCloud *)ob->data, BKE_POINTCLOUD_BATCH_DIRTY_ALL);
|
2020-03-17 14:41:48 +01:00
|
|
|
break;
|
2022-08-09 13:03:35 -05:00
|
|
|
case OB_VOLUME:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_volume_batch_cache_dirty_tag((Volume *)ob->data, BKE_VOLUME_BATCH_DIRTY_ALL);
|
2021-06-22 09:06:33 -03:00
|
|
|
break;
|
2023-05-30 11:14:16 +02:00
|
|
|
case OB_GREASE_PENCIL:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_grease_pencil_batch_cache_dirty_tag((GreasePencil *)ob->data,
|
2023-05-30 11:14:16 +02:00
|
|
|
BKE_GREASEPENCIL_BATCH_DIRTY_ALL);
|
|
|
|
|
break;
|
2021-06-22 09:06:33 -03:00
|
|
|
default:
|
2020-03-17 14:41:48 +01:00
|
|
|
break;
|
2017-03-02 12:58:28 +01:00
|
|
|
}
|
2015-05-12 13:57:11 +05:00
|
|
|
}
|
2017-03-15 11:10:42 +01:00
|
|
|
|
2018-08-22 17:02:37 -03:00
|
|
|
void BKE_object_eval_uber_data(Depsgraph *depsgraph, Scene *scene, Object *ob)
|
|
|
|
|
{
|
|
|
|
|
DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob);
|
|
|
|
|
BLI_assert(ob->type != OB_ARMATURE);
|
|
|
|
|
BKE_object_handle_data_update(depsgraph, scene, ob);
|
2021-07-19 10:17:38 -03:00
|
|
|
BKE_object_batch_cache_dirty_tag(ob);
|
2018-08-22 17:02:37 -03:00
|
|
|
}
|
|
|
|
|
|
2018-11-14 11:24:54 +01:00
|
|
|
void BKE_object_eval_ptcache_reset(Depsgraph *depsgraph, Scene *scene, Object *object)
|
2017-03-15 11:10:42 +01:00
|
|
|
{
|
2018-05-02 11:46:56 +02:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
|
2017-03-15 11:10:42 +01:00
|
|
|
BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH);
|
|
|
|
|
}
|
2017-07-10 14:43:57 +02:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
void BKE_object_eval_transform_all(Depsgraph *depsgraph, Scene *scene, Object *object)
|
2017-11-29 15:29:39 +01:00
|
|
|
{
|
|
|
|
|
/* This mimics full transform update chain from new depsgraph. */
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_object_eval_local_transform(depsgraph, object);
|
2022-09-29 17:11:20 -05:00
|
|
|
if (object->parent != nullptr) {
|
2018-12-19 11:20:32 +01:00
|
|
|
BKE_object_eval_parent(depsgraph, object);
|
2017-11-29 15:29:39 +01:00
|
|
|
}
|
|
|
|
|
if (!BLI_listbase_is_empty(&object->constraints)) {
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_object_eval_constraints(depsgraph, scene, object);
|
2017-11-29 15:29:39 +01:00
|
|
|
}
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_object_eval_uber_transform(depsgraph, object);
|
2018-11-21 14:52:42 +01:00
|
|
|
BKE_object_eval_transform_final(depsgraph, object);
|
2017-11-29 15:29:39 +01:00
|
|
|
}
|
2017-11-29 15:47:00 +01:00
|
|
|
|
2018-05-02 11:46:56 +02:00
|
|
|
void BKE_object_data_select_update(Depsgraph *depsgraph, ID *object_data)
|
2017-11-23 16:03:44 +01:00
|
|
|
{
|
2018-05-02 11:46:56 +02:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, object_data->name, object_data);
|
2017-11-23 16:03:44 +01:00
|
|
|
switch (GS(object_data->name)) {
|
|
|
|
|
case ID_ME:
|
2018-10-05 11:20:12 +10:00
|
|
|
BKE_mesh_batch_cache_dirty_tag((Mesh *)object_data, BKE_MESH_BATCH_DIRTY_SELECT);
|
2017-11-23 16:03:44 +01:00
|
|
|
break;
|
2022-02-18 09:50:29 -06:00
|
|
|
case ID_CU_LEGACY:
|
2018-10-05 11:20:12 +10:00
|
|
|
BKE_curve_batch_cache_dirty_tag((Curve *)object_data, BKE_CURVE_BATCH_DIRTY_SELECT);
|
2017-11-23 16:03:44 +01:00
|
|
|
break;
|
|
|
|
|
case ID_LT:
|
2023-06-03 08:36:28 +10:00
|
|
|
BKE_lattice_batch_cache_dirty_tag((Lattice *)object_data, BKE_LATTICE_BATCH_DIRTY_SELECT);
|
2017-11-23 16:03:44 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-24 10:18:16 +01:00
|
|
|
|
2019-07-02 15:14:47 +02:00
|
|
|
void BKE_object_select_update(Depsgraph *depsgraph, Object *object)
|
|
|
|
|
{
|
|
|
|
|
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
|
2020-02-27 11:23:15 +01:00
|
|
|
if (object->type == OB_MESH && !object->runtime.is_data_eval_owned) {
|
|
|
|
|
Mesh *mesh_input = (Mesh *)object->runtime.data_orig;
|
2022-10-12 22:31:02 -05:00
|
|
|
std::lock_guard lock{mesh_input->runtime->eval_mutex};
|
2022-09-29 17:11:20 -05:00
|
|
|
BKE_object_data_select_update(depsgraph, static_cast<ID *>(object->data));
|
2019-07-03 11:52:56 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2022-09-29 17:11:20 -05:00
|
|
|
BKE_object_data_select_update(depsgraph, static_cast<ID *>(object->data));
|
2019-07-03 11:52:56 +02:00
|
|
|
}
|
2019-07-02 15:14:47 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-26 15:58:37 +01:00
|
|
|
void BKE_object_eval_eval_base_flags(Depsgraph *depsgraph,
|
|
|
|
|
Scene *scene,
|
|
|
|
|
const int view_layer_index,
|
|
|
|
|
Object *object,
|
|
|
|
|
int base_index,
|
|
|
|
|
const bool is_from_set)
|
2017-11-24 10:18:16 +01:00
|
|
|
{
|
2018-04-19 12:03:02 +02:00
|
|
|
/* TODO(sergey): Avoid list lookup. */
|
|
|
|
|
BLI_assert(view_layer_index >= 0);
|
2022-09-29 17:11:20 -05:00
|
|
|
ViewLayer *view_layer = static_cast<ViewLayer *>(
|
|
|
|
|
BLI_findlink(&scene->view_layers, view_layer_index));
|
|
|
|
|
BLI_assert(view_layer != nullptr);
|
|
|
|
|
BLI_assert(view_layer->object_bases_array != nullptr);
|
2018-04-11 12:39:36 +02:00
|
|
|
BLI_assert(base_index >= 0);
|
|
|
|
|
BLI_assert(base_index < MEM_allocN_len(view_layer->object_bases_array) / sizeof(Base *));
|
|
|
|
|
Base *base = view_layer->object_bases_array[base_index];
|
|
|
|
|
BLI_assert(base->object == object);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-02 11:46:56 +02:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-12 18:24:33 +01:00
|
|
|
/* Set base flags based on collection and object restriction. */
|
2019-02-27 17:09:30 +01:00
|
|
|
BKE_base_eval_flags(base);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-12 18:24:33 +01:00
|
|
|
/* For render, compute base visibility again since BKE_base_eval_flags
|
2019-08-17 00:54:22 +10:00
|
|
|
* assumed viewport visibility. Select-ability does not matter here. */
|
2019-03-12 18:24:33 +01:00
|
|
|
if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) {
|
|
|
|
|
if (base->flag & BASE_ENABLED_RENDER) {
|
2022-09-05 17:14:40 +02:00
|
|
|
base->flag |= BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT;
|
2019-02-26 15:58:37 +01:00
|
|
|
}
|
2019-03-12 18:24:33 +01:00
|
|
|
else {
|
2022-09-05 17:14:40 +02:00
|
|
|
base->flag &= ~BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT;
|
2019-02-26 15:58:37 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-24 10:18:16 +01:00
|
|
|
/* Copy flags and settings from base. */
|
|
|
|
|
object->base_flag = base->flag;
|
2017-11-24 14:16:10 +01:00
|
|
|
if (is_from_set) {
|
|
|
|
|
object->base_flag |= BASE_FROM_SET;
|
2018-06-25 13:50:11 +02:00
|
|
|
object->base_flag &= ~(BASE_SELECTED | BASE_SELECTABLE);
|
2017-11-24 14:16:10 +01:00
|
|
|
}
|
2018-11-25 09:50:34 -02:00
|
|
|
object->base_local_view_bits = base->local_view_bits;
|
2019-08-19 14:25:29 -03:00
|
|
|
object->runtime.local_collections_bits = base->local_collections_bits;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-09 14:08:44 +02:00
|
|
|
if (object->mode == OB_MODE_PARTICLE_EDIT) {
|
2022-09-29 17:11:20 -05:00
|
|
|
for (ParticleSystem *psys = static_cast<ParticleSystem *>(object->particlesystem.first);
|
|
|
|
|
psys != nullptr;
|
|
|
|
|
psys = psys->next)
|
|
|
|
|
{
|
2018-08-23 10:14:29 -03:00
|
|
|
BKE_particle_batch_cache_dirty_tag(psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-05-09 14:08:44 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-26 15:58:37 +01:00
|
|
|
/* Copy base flag back to the original view layer for editing. */
|
|
|
|
|
if (DEG_is_active(depsgraph) && (view_layer == DEG_get_evaluated_view_layer(depsgraph))) {
|
|
|
|
|
Base *base_orig = base->base_orig;
|
2022-09-29 17:11:20 -05:00
|
|
|
BLI_assert(base_orig != nullptr);
|
|
|
|
|
BLI_assert(base_orig->object != nullptr);
|
2019-02-26 15:58:37 +01:00
|
|
|
base_orig->flag = base->flag;
|
|
|
|
|
}
|
2017-11-24 10:18:16 +01:00
|
|
|
}
|
2023-05-24 13:36:13 +02:00
|
|
|
|
|
|
|
|
void BKE_object_eval_light_linking(Depsgraph *depsgraph, Object *object)
|
|
|
|
|
{
|
|
|
|
|
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
|
|
|
|
|
deg::light_linking::eval_runtime_data(depsgraph, *object);
|
|
|
|
|
}
|