2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2013 Blender Foundation. All rights reserved. */
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup depsgraph
|
2017-12-20 16:35:48 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-04-28 12:49:52 +02:00
|
|
|
#include "BLI_ghash.h"
|
2018-09-19 15:46:03 +02:00
|
|
|
#include "BLI_sys_types.h"
|
2020-03-11 17:25:17 +01:00
|
|
|
#include "DNA_ID.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "intern/node/deg_node.h"
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2020-06-29 15:19:56 +02:00
|
|
|
namespace blender {
|
|
|
|
|
namespace deg {
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2019-01-31 12:56:40 +01:00
|
|
|
struct ComponentNode;
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2018-09-19 15:46:03 +02:00
|
|
|
typedef uint64_t IDComponentsMask;
|
|
|
|
|
|
2019-01-31 12:56:40 +01:00
|
|
|
/* NOTE: We use max comparison to mark an id node that is linked more than once
|
|
|
|
|
* So keep this enum ordered accordingly. */
|
|
|
|
|
enum eDepsNode_LinkedState_Type {
|
|
|
|
|
/* Generic indirectly linked id node. */
|
|
|
|
|
DEG_ID_LINKED_INDIRECTLY = 0,
|
|
|
|
|
/* Id node present in the set (background) only. */
|
|
|
|
|
DEG_ID_LINKED_VIA_SET = 1,
|
|
|
|
|
/* Id node directly linked via the SceneLayer. */
|
|
|
|
|
DEG_ID_LINKED_DIRECTLY = 2,
|
|
|
|
|
};
|
|
|
|
|
const char *linkedStateAsString(eDepsNode_LinkedState_Type linked_state);
|
|
|
|
|
|
2017-12-20 16:35:48 +01:00
|
|
|
/* ID-Block Reference */
|
2019-01-31 12:56:40 +01:00
|
|
|
struct IDNode : public Node {
|
2017-12-20 16:35:48 +01:00
|
|
|
struct ComponentIDKey {
|
2019-01-31 12:56:40 +01:00
|
|
|
ComponentIDKey(NodeType type, const char *name = "");
|
2020-07-20 12:16:20 +02:00
|
|
|
uint64_t hash() const;
|
2017-12-20 16:35:48 +01:00
|
|
|
bool operator==(const ComponentIDKey &other) const;
|
|
|
|
|
|
2019-01-31 12:56:40 +01:00
|
|
|
NodeType type;
|
2017-12-20 16:35:48 +01:00
|
|
|
const char *name;
|
|
|
|
|
};
|
|
|
|
|
|
2021-12-10 12:11:43 +11:00
|
|
|
/** Initialize 'id' node - from pointer data given. */
|
2018-11-14 11:24:54 +01:00
|
|
|
virtual void init(const ID *id, const char *subdata) override;
|
2020-01-28 14:50:13 +01:00
|
|
|
void init_copy_on_write(ID *id_cow_hint = nullptr);
|
2019-01-31 12:56:40 +01:00
|
|
|
~IDNode();
|
2017-12-20 16:40:49 +01:00
|
|
|
void destroy();
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2018-11-14 11:24:54 +01:00
|
|
|
virtual string identifier() const override;
|
2018-04-30 17:31:04 +02:00
|
|
|
|
2019-02-15 16:00:54 +01:00
|
|
|
ComponentNode *find_component(NodeType type, const char *name = "") const;
|
|
|
|
|
ComponentNode *add_component(NodeType type, const char *name = "");
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2019-01-30 11:21:34 +01:00
|
|
|
virtual void tag_update(Depsgraph *graph, eUpdateSource source) override;
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2017-12-20 16:40:49 +01:00
|
|
|
void finalize_build(Depsgraph *graph);
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2018-09-19 15:46:03 +02:00
|
|
|
IDComponentsMask get_visible_components_mask() const;
|
|
|
|
|
|
2020-03-11 17:25:17 +01:00
|
|
|
/* Type of the ID stored separately, so it's possible to perform check whether CoW is needed
|
|
|
|
|
* without de-referencing the id_cow (which is not safe when ID is NOT covered by CoW and has
|
|
|
|
|
* been deleted from the main database.) */
|
|
|
|
|
ID_Type id_type;
|
2021-01-12 17:12:27 +01:00
|
|
|
|
|
|
|
|
/* ID Block referenced. */
|
2017-12-20 16:40:49 +01:00
|
|
|
ID *id_orig;
|
2021-01-12 17:12:27 +01:00
|
|
|
|
|
|
|
|
/* Session-wide UUID of the id_orig.
|
|
|
|
|
* Is used on relations update to map evaluated state from old nodes to the new ones, without
|
|
|
|
|
* relying on pointers (which are not guaranteed to be unique) and without dereferencing id_orig
|
|
|
|
|
* which could be "stale" pointer. */
|
|
|
|
|
uint id_orig_session_uuid;
|
|
|
|
|
|
2021-01-20 15:24:52 +11:00
|
|
|
/* Evaluated data-block.
|
2021-01-12 17:12:27 +01:00
|
|
|
* Will be covered by the copy-on-write system if the ID Type needs it. */
|
2017-12-20 16:40:49 +01:00
|
|
|
ID *id_cow;
|
2017-12-20 16:35:48 +01:00
|
|
|
|
|
|
|
|
/* Hash to make it faster to look up components. */
|
2020-04-28 12:49:52 +02:00
|
|
|
Map<ComponentIDKey, ComponentNode *> components;
|
2017-12-20 16:35:48 +01:00
|
|
|
|
|
|
|
|
/* Additional flags needed for scene evaluation.
|
|
|
|
|
* TODO(sergey): Only needed for until really granular updates
|
2019-01-31 12:56:40 +01:00
|
|
|
* of all the entities. */
|
2018-10-24 19:38:50 +03:00
|
|
|
uint32_t eval_flags;
|
|
|
|
|
uint32_t previous_eval_flags;
|
2017-12-20 16:35:48 +01:00
|
|
|
|
2018-12-03 18:09:45 +03:00
|
|
|
/* Extra customdata mask which needs to be evaluated for the mesh object. */
|
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
|
|
|
DEGCustomDataMeshMasks customdata_masks;
|
|
|
|
|
DEGCustomDataMeshMasks previous_customdata_masks;
|
2018-12-03 18:09:45 +03:00
|
|
|
|
2017-12-20 16:40:49 +01:00
|
|
|
eDepsNode_LinkedState_Type linked_state;
|
|
|
|
|
|
2021-01-20 15:24:52 +11:00
|
|
|
/* Indicates the data-block is visible in the evaluated scene. */
|
2018-09-19 15:21:51 +02:00
|
|
|
bool is_directly_visible;
|
2018-09-19 15:46:03 +02:00
|
|
|
|
2018-11-14 16:50:59 +01:00
|
|
|
/* For the collection type of ID, denotes whether collection was fully
|
2019-01-31 12:56:40 +01:00
|
|
|
* recursed into. */
|
2018-11-14 16:50:59 +01:00
|
|
|
bool is_collection_fully_expanded;
|
|
|
|
|
|
2019-04-29 14:11:32 +02:00
|
|
|
/* Is used to figure out whether object came to the dependency graph via a base. */
|
|
|
|
|
bool has_base;
|
|
|
|
|
|
2019-06-04 11:33:41 +02:00
|
|
|
/* Accumulated flag from operation. Is initialized and used during updates flush. */
|
|
|
|
|
bool is_user_modified;
|
|
|
|
|
|
2022-01-31 17:37:07 +01:00
|
|
|
/* Copy-on-Write component has been explicitly tagged for update. */
|
|
|
|
|
bool is_cow_explicitly_tagged;
|
|
|
|
|
|
2021-04-19 19:38:05 +02:00
|
|
|
/* Accumulate recalc flags from multiple update passes. */
|
|
|
|
|
int id_cow_recalc_backup;
|
|
|
|
|
|
2018-09-19 15:46:03 +02:00
|
|
|
IDComponentsMask visible_components_mask;
|
|
|
|
|
IDComponentsMask previously_visible_components_mask;
|
2018-08-23 16:17:06 +02:00
|
|
|
|
2017-12-20 16:35:48 +01:00
|
|
|
DEG_DEPSNODE_DECLARE;
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-29 15:19:56 +02:00
|
|
|
} // namespace deg
|
|
|
|
|
} // namespace blender
|