diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-11 13:44:43 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-11 13:49:25 +0300 |
commit | d50821f145550b60078ce1106edd21348476d960 (patch) | |
tree | 644681631a283c40ac746279a4b6bc4c298f996c /source/blender/draw/intern | |
parent | ff3e9d0d90e105e0b6c9cd6e09189f420268d9ec (diff) |
Particle edit: Initial support of edit with copy-on-write
The idea is that edit mode structure is owned by original object,
and used for drawing. This is a bit confusing, especially since
path cache is also in that structure and needs evaluated object
to calculate cache.
In the future we should split edit data from visualization data,
but that's bigger refactor.
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 12 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache.h | 6 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl.h | 6 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_particles.c | 31 |
4 files changed, 34 insertions, 21 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index b70ed1d053d..6c6e9a732b3 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2886,19 +2886,19 @@ Gwn_Batch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys) return DRW_particles_batch_cache_get_dots(object, psys); } -Gwn_Batch *DRW_cache_particles_get_edit_strands(struct PTCacheEdit *edit) +Gwn_Batch *DRW_cache_particles_get_edit_strands(Object *object, struct PTCacheEdit *edit) { - return DRW_particles_batch_cache_get_edit_strands(edit); + return DRW_particles_batch_cache_get_edit_strands(object, edit); } -Gwn_Batch *DRW_cache_particles_get_edit_inner_points(struct PTCacheEdit *edit) +Gwn_Batch *DRW_cache_particles_get_edit_inner_points(Object *object, struct PTCacheEdit *edit) { - return DRW_particles_batch_cache_get_edit_inner_points(edit); + return DRW_particles_batch_cache_get_edit_inner_points(object, edit); } -Gwn_Batch *DRW_cache_particles_get_edit_tip_points(struct PTCacheEdit *edit) +Gwn_Batch *DRW_cache_particles_get_edit_tip_points(Object *object, struct PTCacheEdit *edit) { - return DRW_particles_batch_cache_get_edit_tip_points(edit); + return DRW_particles_batch_cache_get_edit_tip_points(object, edit); } Gwn_Batch *DRW_cache_particles_get_prim(int type) diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 66db405786d..2dc07e40c42 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -169,9 +169,9 @@ struct Gwn_Batch *DRW_cache_lattice_vert_overlay_get(struct Object *ob); /* Particles */ struct Gwn_Batch *DRW_cache_particles_get_hair(struct ParticleSystem *psys, struct ModifierData *md); struct Gwn_Batch *DRW_cache_particles_get_dots(struct Object *object, struct ParticleSystem *psys); -struct Gwn_Batch *DRW_cache_particles_get_edit_strands(struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_cache_particles_get_edit_inner_points(struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_cache_particles_get_edit_tip_points(struct PTCacheEdit *edit); +struct Gwn_Batch *DRW_cache_particles_get_edit_strands(struct Object *object, struct PTCacheEdit *edit); +struct Gwn_Batch *DRW_cache_particles_get_edit_inner_points(struct Object *object, struct PTCacheEdit *edit); +struct Gwn_Batch *DRW_cache_particles_get_edit_tip_points(struct Object *object, struct PTCacheEdit *edit); struct Gwn_Batch *DRW_cache_particles_get_prim(int type); /* Metaball */ diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 4e3c56eb427..9d9668f3ffc 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -125,8 +125,8 @@ void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me); /* Particles */ struct Gwn_Batch *DRW_particles_batch_cache_get_hair(struct ParticleSystem *psys, struct ModifierData *md); struct Gwn_Batch *DRW_particles_batch_cache_get_dots(struct Object *object, struct ParticleSystem *psys); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(struct PTCacheEdit *edit); +struct Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(struct Object *object, struct PTCacheEdit *edit); +struct Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(struct Object *object, struct PTCacheEdit *edit); +struct Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(struct Object *object, struct PTCacheEdit *edit); #endif /* __DRAW_CACHE_IMPL_H__ */ diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 4102b72175f..f1ae9d6ef8c 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -597,10 +597,25 @@ Gwn_Batch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *ps return cache->hairs; } -Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(PTCacheEdit *edit) +/* TODO(sergey): Avoid linear lookup. */ +static ParticleBatchCache *particle_batch_cache_get_edit(Object *object, PTCacheEdit *edit) +{ + ParticleSystem *psys_orig = edit->psys; + for (ParticleSystem *psys_eval = object->particlesystem.first; + psys_eval != NULL; + psys_eval = psys_eval->next) + { + if (STREQ(psys_orig->name, psys_eval->name)) { + return particle_batch_cache_get(psys_eval); + } + } + return NULL; +} + +Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(Object *object, PTCacheEdit *edit) { ParticleSystem *psys = edit->psys; - ParticleBatchCache *cache = particle_batch_cache_get(psys); + ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); if (cache->hairs != NULL) { return cache->hairs; } @@ -676,10 +691,9 @@ static void particle_batch_cache_ensure_edit_inner_pos( } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(PTCacheEdit *edit) +Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(Object *object, PTCacheEdit *edit) { - ParticleSystem *psys = edit->psys; - ParticleBatchCache *cache = particle_batch_cache_get(psys); + ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); if (cache->edit_inner_points != NULL) { return cache->edit_inner_points; } @@ -692,7 +706,7 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(PTCacheEdit *edit) } static void ensure_edit_tip_points_count(const PTCacheEdit *edit, - ParticleBatchCache *cache) + ParticleBatchCache *cache) { if (cache->edit_tip_pos != NULL) { return; @@ -738,10 +752,9 @@ static void particle_batch_cache_ensure_edit_tip_pos( } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(PTCacheEdit *edit) +Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(Object *object, PTCacheEdit *edit) { - ParticleSystem *psys = edit->psys; - ParticleBatchCache *cache = particle_batch_cache_get(psys); + ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); if (cache->edit_tip_points != NULL) { return cache->edit_tip_points; } |