Blender V4.5
eevee_sync.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12#pragma once
13
14#include "BKE_duplilist.hh"
15#include "BLI_map.hh"
17#include "DNA_object_types.h"
18#include "DRW_render.hh"
19#include "GPU_material.hh"
20
22
23namespace blender::eevee {
24
25class Instance;
26
27/* -------------------------------------------------------------------- */
33
34class ObjectKey {
36 uint64_t hash_value_ = 0;
38 Object *ob_ = nullptr;
40 Object *parent_ = nullptr;
42 int id_[MAX_DUPLI_RECUR];
44 int sub_key_ = 0;
45
46 public:
47 ObjectKey() = default;
48
49 ObjectKey(const ObjectRef &ob_ref, int sub_key = 0)
50 {
51 ob_ = DEG_get_original(ob_ref.object);
52 hash_value_ = get_default_hash(ob_);
53
54 if (DupliObject *dupli = ob_ref.dupli_object) {
55 parent_ = ob_ref.dupli_parent;
56 hash_value_ = get_default_hash(hash_value_, get_default_hash(parent_));
57 for (int i : IndexRange(MAX_DUPLI_RECUR)) {
58 id_[i] = dupli->persistent_id[i];
59 if (id_[i] == INT_MAX) {
60 break;
61 }
62 hash_value_ = get_default_hash(hash_value_, get_default_hash(id_[i]));
63 }
64 }
65
66 if (sub_key != 0) {
67 sub_key_ = sub_key;
68 hash_value_ = get_default_hash(hash_value_, get_default_hash(sub_key_));
69 }
70 }
71
72 uint64_t hash() const
73 {
74 return hash_value_;
75 }
76
77 bool operator==(const ObjectKey &k) const
78 {
79 if (hash_value_ != k.hash_value_) {
80 return false;
81 }
82 if (ob_ != k.ob_) {
83 return false;
84 }
85 if (parent_ != k.parent_) {
86 return false;
87 }
88 if (sub_key_ != k.sub_key_) {
89 return false;
90 }
91 if (parent_) {
92 for (int i : IndexRange(MAX_DUPLI_RECUR)) {
93 if (id_[i] != k.id_[i]) {
94 return false;
95 }
96 if (id_[i] == INT_MAX) {
97 break;
98 }
99 }
100 }
101 return true;
102 }
103};
104
106
107/* -------------------------------------------------------------------- */
111
113 unsigned int recalc;
114};
115
119
120struct WorldHandle : public BaseHandle {};
121
122struct SceneHandle : public BaseHandle {};
123
125 private:
126 Instance &inst_;
127
128 Map<ObjectKey, ObjectHandle> ob_handles = {};
129
130 public:
131 SyncModule(Instance &inst) : inst_(inst){};
133
134 ObjectHandle &sync_object(const ObjectRef &ob_ref);
135 WorldHandle sync_world(const ::World &world);
136
137 void sync_mesh(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref);
138 bool sync_sculpt(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref);
139 void sync_pointcloud(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref);
140 void sync_volume(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref);
141 void sync_curves(Object *ob,
142 ObjectHandle &ob_handle,
143 const ObjectRef &ob_ref,
144 ResourceHandle res_handle = 0,
145 ModifierData *modifier_data = nullptr,
146 ParticleSystem *particle_sys = nullptr);
147};
148
151 ObjectHandle ob_handle,
152 HairHandleCallback callback);
153
155
156} // namespace blender::eevee
constexpr int MAX_DUPLI_RECUR
T * DEG_get_original(T *id)
Object is a sort of wrapper for general info.
unsigned long long int uint64_t
A running instance of the engine.
ObjectKey(const ObjectRef &ob_ref, int sub_key=0)
Definition eevee_sync.hh:49
uint64_t hash() const
Definition eevee_sync.hh:72
bool operator==(const ObjectKey &k) const
Definition eevee_sync.hh:77
ObjectHandle & sync_object(const ObjectRef &ob_ref)
Definition eevee_sync.cc:32
void sync_mesh(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref)
Definition eevee_sync.cc:86
void sync_curves(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref, ResourceHandle res_handle=0, ModifierData *modifier_data=nullptr, ParticleSystem *particle_sys=nullptr)
void sync_volume(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref)
SyncModule(Instance &inst)
WorldHandle sync_world(const ::World &world)
Definition eevee_sync.cc:47
bool sync_sculpt(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref)
void sync_pointcloud(Object *ob, ObjectHandle &ob_handle, const ObjectRef &ob_ref)
FunctionRef< void(ObjectHandle, ModifierData &, ParticleSystem &)> HairHandleCallback
void foreach_hair_particle_handle(ObjectRef &ob_ref, ObjectHandle ob_handle, HairHandleCallback callback)
uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:233
DupliObject * dupli_object
i
Definition text_draw.cc:230