Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2020-02-02 14:04:19 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-02-07 14:18:15 +0300
commitd9c5f0d25fc91b069158ae1ab4fddc21bfd85846 (patch)
tree18f55163c5b06385d055d5a79a4c653d3da6e595 /intern/cycles/blender/blender_id_map.h
parent46c9872afaa8053f8b2894c038402b1beb3ac66c (diff)
Cleanup: split Cycles Hair and Mesh classes, with Geometry base class
Diffstat (limited to 'intern/cycles/blender/blender_id_map.h')
-rw-r--r--intern/cycles/blender/blender_id_map.h56
1 files changed, 38 insertions, 18 deletions
diff --git a/intern/cycles/blender/blender_id_map.h b/intern/cycles/blender/blender_id_map.h
index 52031cd9f34..83c93bb09ee 100644
--- a/intern/cycles/blender/blender_id_map.h
+++ b/intern/cycles/blender/blender_id_map.h
@@ -72,41 +72,61 @@ template<typename K, typename T> class id_map {
used_set.clear();
}
- bool sync(T **r_data, const BL::ID &id)
+ /* Add new data. */
+ void add(const K &key, T *data)
{
- return sync(r_data, id, id, id.ptr.owner_id);
+ assert(find(key) == NULL);
+ scene_data->push_back(data);
+ b_map[key] = data;
+ used(data);
}
- bool sync(T **r_data, const BL::ID &id, const K &key)
+ /* Update existing data. */
+ bool update(T *data, const BL::ID &id)
{
- return sync(r_data, id, id, key);
+ return update(data, id, id);
+ }
+ bool update(T *data, const BL::ID &id, const BL::ID &parent)
+ {
+ bool recalc = (b_recalc.find(id.ptr.data) != b_recalc.end());
+ if (parent.ptr.data && parent.ptr.data != id.ptr.data) {
+ recalc = recalc || (b_recalc.find(parent.ptr.data) != b_recalc.end());
+ }
+ used(data);
+ return recalc;
}
- bool sync(T **r_data, const BL::ID &id, const BL::ID &parent, const K &key)
+ /* Combined add and update as needed. */
+ bool add_or_update(T **r_data, const BL::ID &id)
+ {
+ return add_or_update(r_data, id, id, id.ptr.owner_id);
+ }
+ bool add_or_update(T **r_data, const BL::ID &id, const K &key)
+ {
+ return add_or_update(r_data, id, id, key);
+ }
+ bool add_or_update(T **r_data, const BL::ID &id, const BL::ID &parent, const K &key)
{
T *data = find(key);
bool recalc;
if (!data) {
- /* add data if it didn't exist yet */
+ /* Add data if it didn't exist yet. */
data = new T();
- scene_data->push_back(data);
- b_map[key] = data;
+ add(key, data);
recalc = true;
}
else {
- recalc = (b_recalc.find(id.ptr.data) != b_recalc.end());
- if (parent.ptr.data && parent.ptr.data != id.ptr.data) {
- recalc = recalc || (b_recalc.find(parent.ptr.data) != b_recalc.end());
- }
+ /* check if updated needed. */
+ recalc = update(data, id, parent);
}
- used(data);
-
*r_data = data;
return recalc;
}
+ /* Combined add or update for convenience. */
+
bool is_used(const K &key)
{
T *data = find(key);
@@ -220,20 +240,20 @@ struct ObjectKey {
}
};
-/* Mesh Key
+/* Geometry Key
*
* We export separate geomtry for a mesh and its particle hair, so key needs to
* distinguish between them. */
-struct MeshKey {
+struct GeometryKey {
void *id;
bool use_particle_hair;
- MeshKey(void *id, bool use_particle_hair) : id(id), use_particle_hair(use_particle_hair)
+ GeometryKey(void *id, bool use_particle_hair) : id(id), use_particle_hair(use_particle_hair)
{
}
- bool operator<(const MeshKey &k) const
+ bool operator<(const GeometryKey &k) const
{
if (id < k.id) {
return true;