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>2010-01-14 11:53:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-14 11:53:10 +0300
commitc1f2fd0a464c62e01e78f3b8f544219fa087ffc2 (patch)
tree4935c55ebf8218c463c4d0ba6ace71e86cd13c89 /source/blender/editors/physics
parent72b14be4609fd3d9717fcc0a8b59c9c0644032ad (diff)
particle weight brush back (mostly the same as in 2.4x), needed to control long hairs movement.
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r--source/blender/editors/physics/particle_edit.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index fc86971b8ac..f9c786b29b0 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -2844,7 +2844,6 @@ static void brush_puff(PEData *data, int point_index)
PTCacheEditPoint *point = edit->points + point_index;
KEY_K;
float mat[4][4], imat[4][4];
- float obmat[4][4], obimat[4][4];
float lastco[3], rootco[3] = {0.0f, 0.0f, 0.0f}, co[3], nor[3], kco[3], dco[3], ofs[3] = {0.0f, 0.0f, 0.0f}, fac=0.0f, length=0.0f;
int puff_volume = 0;
@@ -2865,22 +2864,19 @@ static void brush_puff(PEData *data, int point_index)
unit_m4(imat);
}
- copy_m4_m4(obmat, data->ob->obmat);
- invert_m4_m4(obimat, obmat);
-
LOOP_KEYS {
if(k==0) {
/* find root coordinate and normal on emitter */
VECCOPY(co, key->co);
mul_m4_v3(mat, co);
- mul_v3_m4v3(kco, obimat, co); /* use 'kco' as the object space version of worldspace 'co' */
+ mul_v3_m4v3(kco, data->ob->imat, co); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */
point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL);
if(point_index == -1) return;
VECCOPY(rootco, co);
copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]);
- mul_mat3_m4_v3(obmat, nor); /* normal into worldspace */
+ mul_mat3_m4_v3(data->ob->obmat, nor); /* normal into worldspace */
normalize_v3(nor);
length= 0.0f;
@@ -2949,6 +2945,21 @@ static void brush_puff(PEData *data, int point_index)
point->flag |= PEP_EDIT_RECALC;
}
+
+static void brush_weight(PEData *data, float mat[][4], float imat[][4], int point_index, int key_index, PTCacheEditKey *key)
+{
+ /* roots have full weight allways */
+ if(key_index) {
+ PTCacheEdit *edit = data->edit;
+ ParticleSystem *psys = edit->psys;
+
+ ParticleData *pa= psys->particles + point_index;
+ pa->hair[key_index].weight = data->weightfac;
+
+ (data->edit->points + point_index)->flag |= PEP_EDIT_RECALC;
+ }
+}
+
static void brush_smooth_get(PEData *data, float mat[][4], float imat[][4], int point_index, int key_index, PTCacheEditKey *key)
{
if(key_index) {
@@ -3396,6 +3407,23 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
break;
}
+ case PE_BRUSH_WEIGHT:
+ {
+ PEData data;
+ PE_set_view3d_data(C, &data);
+
+ if(edit->psys) {
+ data.dm= psmd->dm;
+ data.mval= mval;
+ data.rad= (float)brush->size;
+
+ data.weightfac = (float)(brush->strength / 100.0f); /* note that this will never be zero */
+
+ foreach_mouse_hit_key(&data, brush_weight, selected);
+ }
+
+ break;
+ }
}
if((pset->flag & PE_KEEP_LENGTHS)==0)
recalc_lengths(edit);