Fix T53823: Particle weight brush crash

Entering particle edit mode w/ the weight brush enabled crashed
on non-hair particle systems.
This commit is contained in:
Campbell Barton 2018-01-19 12:25:09 +11:00
parent 2b9fb723ed
commit 368414efac
Notes: blender-bot 2023-02-14 08:47:25 +01:00
Referenced by issue #53823, Enabling weight brush in particle edit mode of a hair particle system will cause a crash when entering an emitter system edit mode.
Referenced by issue #53683, 2.79a release
1 changed files with 5 additions and 3 deletions

View File

@ -2794,7 +2794,9 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/* frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; */ /* UNUSED */
if (pset->brushtype == PE_BRUSH_WEIGHT) {
const bool use_weight = (pset->brushtype == PE_BRUSH_WEIGHT) && (psys != NULL) && (psys->particles != NULL);
if (use_weight) {
; /* use weight painting colors now... */
}
else {
@ -2824,7 +2826,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/* should init_particle_interpolation set this ? */
if (pset->brushtype == PE_BRUSH_WEIGHT) {
if (use_weight) {
pind.hkey[0] = NULL;
/* pa != NULL since the weight brush is only available for hair */
pind.hkey[0] = pa->hair;
@ -2885,7 +2887,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
}
/* selection coloring in edit mode */
if (pset->brushtype == PE_BRUSH_WEIGHT) {
if (use_weight) {
if (k == 0) {
weight_to_rgb(ca->col, pind.hkey[1]->weight);
}