[Bf-blender-cvs] [5b3538e02a6] blender-v2.79a-release: Fix T53832: Particle weight paint crash
Campbell Barton
noreply at git.blender.org
Fri Jan 19 04:57:17 CET 2018
Commit: 5b3538e02a6867bd40aac51594292324f15dd8df
Author: Campbell Barton
Date: Fri Jan 19 12:07:14 2018 +1100
Branches: blender-v2.79a-release
https://developer.blender.org/rB5b3538e02a6867bd40aac51594292324f15dd8df
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.
===================================================================
M source/blender/blenkernel/intern/particle.c
===================================================================
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) {
More information about the Bf-blender-cvs
mailing list