diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-02-02 15:09:18 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-02-07 14:18:15 +0300 |
commit | 7b66f73558d1e4dda308366bc8ad2b5dfa8009d3 (patch) | |
tree | fa1cb6ad40be190d67d578580c0a90f8c0ee7d3d /intern/cycles/blender/blender_util.h | |
parent | ad489b71646a2e03e2ce9b0d193d541e3987b4cd (diff) |
Cleanup: export particle hair as a separate Cycles object
Diffstat (limited to 'intern/cycles/blender/blender_util.h')
-rw-r--r-- | intern/cycles/blender/blender_util.h | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index bea30a20b8c..6d6dd75db6b 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -625,6 +625,11 @@ template<typename K, typename T> class id_map { return sync(r_data, id, id, id.ptr.owner_id); } + bool sync(T **r_data, const BL::ID &id, const K &key) + { + return sync(r_data, id, id, key); + } + bool sync(T **r_data, const BL::ID &id, const BL::ID &parent, const K &key) { T *data = find(key); @@ -639,8 +644,9 @@ template<typename K, typename T> class id_map { } else { recalc = (b_recalc.find(id.ptr.data) != b_recalc.end()); - if (parent.ptr.data) + if (parent.ptr.data && parent.ptr.data != id.ptr.data) { recalc = recalc || (b_recalc.find(parent.ptr.data) != b_recalc.end()); + } } used(data); @@ -725,9 +731,10 @@ struct ObjectKey { void *parent; int id[OBJECT_PERSISTENT_ID_SIZE]; void *ob; + bool use_particle_hair; - ObjectKey(void *parent_, int id_[OBJECT_PERSISTENT_ID_SIZE], void *ob_) - : parent(parent_), ob(ob_) + ObjectKey(void *parent_, int id_[OBJECT_PERSISTENT_ID_SIZE], void *ob_, bool use_particle_hair_) + : parent(parent_), ob(ob_), use_particle_hair(use_particle_hair_) { if (id_) memcpy(id, id_, sizeof(id)); @@ -741,10 +748,42 @@ struct ObjectKey { return true; } else if (ob == k.ob) { - if (parent < k.parent) + if (parent < k.parent) { + return true; + } + else if (parent == k.parent) { + if (use_particle_hair < k.use_particle_hair) { + return true; + } + else if (use_particle_hair == k.use_particle_hair) { + return memcmp(id, k.id, sizeof(id)) < 0; + } + } + } + + return false; + } +}; + +/* Mesh Key */ + +struct MeshKey { + void *id; + bool use_particle_hair; + + MeshKey(void *id, bool use_particle_hair) : id(id), use_particle_hair(use_particle_hair) + { + } + + bool operator<(const MeshKey &k) const + { + if (id < k.id) { + return true; + } + else if (id == k.id) { + if (use_particle_hair < k.use_particle_hair) { return true; - else if (parent == k.parent) - return memcmp(id, k.id, sizeof(id)) < 0; + } } return false; |