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-08 18:10:42 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-05-09 11:34:45 +0300
commitafdc5c148bc16191be612a0a7770ee167196c039 (patch)
tree01cb0d709d5526d689e5ff16d7fc898c2d76439f
parent43c6ba9eeddc7fbe3875b73e4ae74920f4afd10b (diff)
Draw manager: Use utility function to get particle edit mode
Makes it more local where we have to do all the tricky checks.
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c27
-rw-r--r--source/blender/editors/include/ED_particle.h2
-rw-r--r--source/blender/editors/physics/particle_edit.c17
3 files changed, 27 insertions, 19 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 0ee30fc957d..4b69c017ba0 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -45,6 +45,8 @@
#include "BKE_particle.h"
#include "BKE_pointcache.h"
+#include "ED_particle.h"
+
#include "GPU_batch.h"
#include "DEG_depsgraph_query.h"
@@ -171,13 +173,9 @@ static void ensure_seg_pt_count(ParticleSystem *psys, ParticleBatchCache *cache)
cache->elems_count = 0;
cache->point_count = 0;
- if (psys->edit != NULL && psys->edit->pathcache != NULL) {
- count_cache_segment_keys(
- psys->edit->pathcache, psys->totpart, cache);
- }
- else if (psys->pointcache != NULL && psys->pointcache->edit != NULL) {
- count_cache_segment_keys(
- psys->pointcache->edit->pathcache, psys->totpart, cache);
+ PTCacheEdit* edit = PE_get_current_from_psys(psys);
+ if (edit != NULL && edit->pathcache != NULL) {
+ count_cache_segment_keys(edit->pathcache, psys->totpart, cache);
} else {
if (psys->pathcache &&
(!psys->childcache || (psys->part->draw & PART_DRAW_PARENT)))
@@ -438,19 +436,10 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys,
}
}
- if (psys->edit != NULL && psys->edit->pathcache != NULL) {
- /* Edit mode strands for hair editing. */
- curr_point = particle_batch_cache_fill_segments(
- psys, psmd, psys->edit->pathcache, PARTICLE_SOURCE_PARENT,
- 0, 0, psys->totpart,
- num_uv_layers, mtfaces, uv_id, &parent_uvs,
- &elb, &attr_id, cache);
- }
- else if (psys->pointcache != NULL && psys->pointcache->edit != NULL) {
- /* Edit mode for particle paths. */
+ PTCacheEdit* edit = PE_get_current_from_psys(psys);
+ if (edit != NULL && edit->pathcache != NULL) {
curr_point = particle_batch_cache_fill_segments(
- psys, psmd, psys->pointcache->edit->pathcache,
- PARTICLE_SOURCE_PARENT,
+ psys, psmd, edit->pathcache, PARTICLE_SOURCE_PARENT,
0, 0, psys->totpart,
num_uv_layers, mtfaces, uv_id, &parent_uvs,
&elb, &attr_id, cache);
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index f84015c53ee..8b522c91188 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -34,6 +34,7 @@
struct bContext;
struct Object;
+struct ParticleSystem;
struct ParticleEditSettings;
struct rcti;
struct PTCacheEdit;
@@ -46,6 +47,7 @@ void PE_free_ptcache_edit(struct PTCacheEdit *edit);
int PE_start_edit(struct PTCacheEdit *edit);
/* access */
+struct PTCacheEdit *PE_get_current_from_psys(struct ParticleSystem *psys);
struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob);
struct PTCacheEdit *PE_create_current(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void PE_current_changed(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index d343264c2c9..78ee8939de5 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -189,6 +189,23 @@ static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *br
return brush->size * U.pixelsize;
}
+PTCacheEdit *PE_get_current_from_psys(ParticleSystem *psys)
+{
+ if (psys->part && psys->part->type == PART_HAIR) {
+ if ((psys->flag & PSYS_HAIR_DYNAMICS) != 0 &&
+ (psys->pointcache->flag & PTCACHE_BAKED) != 0)
+ {
+ return psys->pointcache->edit;
+ }
+ else {
+ return psys->edit;
+ }
+ }
+ else if (psys->pointcache->flag & PTCACHE_BAKED) {
+ return psys->pointcache->edit;
+ }
+ return NULL;
+}
/* always gets at least the first particlesystem even if PSYS_CURRENT flag is not set
*