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:
authorCampbell Barton <ideasman42@gmail.com>2018-01-19 04:07:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-01-19 07:06:19 +0300
commit5b3538e02a6867bd40aac51594292324f15dd8df (patch)
tree9a10ccabf11d7360c2d98a64113add964b84ffc9
parentc3873a5156447c583ab05c9d164d99e51929c070 (diff)
Fix T53832: Particle weight paint crash
Drawing hair weights read before the hair array start. This code could be improved since it currently copy-pastes, from do_particle_interpolation, but this would need larger changes. For now just correct existing logic.
-rw-r--r--source/blender/blenkernel/intern/particle.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 7a0e8a3578c..455ca3ebbb6 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2827,7 +2827,8 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
if (pset->brushtype == PE_BRUSH_WEIGHT) {
pind.hkey[0] = NULL;
/* pa != NULL since the weight brush is only available for hair */
- pind.hkey[1] = pa->hair;
+ pind.hkey[0] = pa->hair;
+ pind.hkey[1] = pa->hair + 1;
}
@@ -2885,12 +2886,26 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/* selection coloring in edit mode */
if (pset->brushtype == PE_BRUSH_WEIGHT) {
- float t2;
-
if (k == 0) {
weight_to_rgb(ca->col, pind.hkey[1]->weight);
}
else {
+ /* warning: copied from 'do_particle_interpolation' (without 'mvert' array stepping) */
+ float real_t;
+ if (result.time < 0.0f) {
+ real_t = -result.time;
+ }
+ else {
+ real_t = pind.hkey[0]->time + t * (pind.hkey[0][pa->totkey - 1].time - pind.hkey[0]->time);
+ }
+
+ while (pind.hkey[1]->time < real_t) {
+ pind.hkey[1]++;
+ }
+ pind.hkey[0] = pind.hkey[1] - 1;
+ /* end copy */
+
+
float w1[3], w2[3];
keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
@@ -2899,13 +2914,6 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
interp_v3_v3v3(ca->col, w1, w2, keytime);
}
-
- /* at the moment this is only used for weight painting.
- * will need to move out of this check if its used elsewhere. */
- t2 = birthtime + ((float)k / (float)segments) * (dietime - birthtime);
-
- while (pind.hkey[1]->time < t2) pind.hkey[1]++;
- pind.hkey[0] = pind.hkey[1] - 1;
}
else {
if ((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT) {