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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-05-11 13:44:43 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-05-11 13:49:25 +0300
commitd50821f145550b60078ce1106edd21348476d960 (patch)
tree644681631a283c40ac746279a4b6bc4c298f996c /source/blender/draw/intern/draw_cache_impl_particles.c
parentff3e9d0d90e105e0b6c9cd6e09189f420268d9ec (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/draw_cache_impl_particles.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c31
1 files changed, 22 insertions, 9 deletions
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;
}