Fix for [#21103] Updating bugs in Particle Mode
authorJanne Karhu <jhkarh@gmail.com>
Mon, 22 Mar 2010 17:12:08 +0000 (17:12 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Mon, 22 Mar 2010 17:12:08 +0000 (17:12 +0000)
release/scripts/ui/space_view3d_toolbar.py
source/blender/blenkernel/intern/scene.c
source/blender/editors/physics/particle_edit.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_sculpt_paint.c

index 26e8ec1..829d351 100644 (file)
@@ -523,9 +523,11 @@ class VIEW3D_PT_tools_brush(PaintPanel):
             if settings.tool != 'NONE':
                 col = layout.column()
                 col.prop(brush, "size", slider=True)
-                col.prop(brush, "strength", slider=True)
+                if settings.tool != 'ADD':
+                    col.prop(brush, "strength", slider=True)
 
             if settings.tool == 'ADD':
+                col.prop(brush, "count")
                 col = layout.column()
                 col.prop(settings, "add_interpolate")
                 sub = col.column(align=True)
index 44035af..0bce2d0 100644 (file)
@@ -424,9 +424,10 @@ Scene *add_scene(char *name)
        pset->fade_frames= 2;
        pset->selectmode= SCE_SELECT_PATH;
        for(a=0; a<PE_TOT_BRUSH; a++) {
-               pset->brush[a].strength= 50;
+               pset->brush[a].strength= 0.5;
                pset->brush[a].size= 50;
                pset->brush[a].step= 10;
+               pset->brush[a].count= 10;
        }
        pset->brush[PE_BRUSH_CUT].strength= 100;
        
index 744ef28..2261aa6 100644 (file)
@@ -2386,7 +2386,7 @@ static int weight_set_exec(bContext *C, wmOperator *op)
        ParticleBrushData *brush= &pset->brush[pset->brushtype];
        edit= psys->edit;
 
-       weight= (float)(brush->strength / 100.0f);
+       weight= brush->strength;
 
        LOOP_SELECTED_POINTS {
                ParticleData *pa= psys->particles + p;
@@ -2510,6 +2510,8 @@ static int brush_radial_control_exec(bContext *C, wmOperator *op)
        else if(mode == WM_RADIALCONTROL_STRENGTH)
                brush->strength= new_value;
 
+       WM_event_add_notifier(C, NC_WINDOW, NULL);
+
        return OPERATOR_FINISHED;
 }
 
@@ -2944,7 +2946,7 @@ static void brush_puff(PEData *data, int point_index)
                        VECCOPY(co, key->co);
                        mul_m4_v3(mat, co);
                        length += len_v3v3(lastco, co);
-                       if((key->flag & PEK_SELECT) && !(key->flag & PEK_HIDE)) {
+                       if((data->select==0 || (key->flag & PEK_SELECT)) && !(key->flag & PEK_HIDE)) {
                                VECADDFAC(kco, rootco, nor, length);
 
                                /* blend between the current and straight position */
@@ -3359,7 +3361,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                                data.mval= mval;
                                data.rad= (float)brush->size;
 
-                               data.combfac= (float)(brush->strength - 50) / 50.0f;
+                               data.combfac= (brush->strength - 0.5f) * 2.0f;
                                if(data.combfac < 0.0f)
                                        data.combfac= 1.0f - 9.0f * data.combfac;
                                else
@@ -3381,7 +3383,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                                        PE_set_view3d_data(C, &data);
                                        data.mval= mval;
                                        data.rad= (float)brush->size;
-                                       data.cutfac= (float)(brush->strength / 100.0f);
+                                       data.cutfac= brush->strength;
 
                                        if(selected)
                                                foreach_selected_point(&data, brush_cut);
@@ -3405,7 +3407,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                                data.mval= mval;
                                
                                data.rad= (float)brush->size;
-                               data.growfac= (float)brush->strength / 5000.0f;
+                               data.growfac= brush->strength / 50.0f;
 
                                if(brush->invert ^ flip)
                                        data.growfac= 1.0f - data.growfac;
@@ -3427,8 +3429,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                                        data.dm= psmd->dm;
                                        data.mval= mval;
                                        data.rad= (float)brush->size;
+                                       data.select= selected;
 
-                                       data.pufffac= (float)(brush->strength - 50) / 50.0f;
+                                       data.pufffac= (brush->strength - 0.5f) * 2.0f;
                                        if(data.pufffac < 0.0f)
                                                data.pufffac= 1.0f - 9.0f * data.pufffac;
                                        else
@@ -3449,7 +3452,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                                        PE_set_view3d_data(C, &data);
                                        data.mval= mval;
 
-                                       added= brush_add(&data, brush->strength);
+                                       added= brush_add(&data, brush->count);
 
                                        if(pset->flag & PE_KEEP_LENGTHS)
                                                recalc_lengths(edit);
@@ -3469,7 +3472,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                                data.vec[0]= data.vec[1]= data.vec[2]= 0.0f;
                                data.tot= 0;
 
-                               data.smoothfac= (float)(brush->strength / 100.0f);
+                               data.smoothfac= brush->strength;
 
                                invert_m4_m4(ob->imat, ob->obmat);
 
@@ -3492,7 +3495,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                                        data.mval= mval;
                                        data.rad= (float)brush->size;
 
-                                       data.weightfac = (float)(brush->strength / 100.0f); /* note that this will never be zero */
+                                       data.weightfac = brush->strength; /* note that this will never be zero */
 
                                        foreach_mouse_hit_key(&data, brush_weight, selected);
                                }
index bd5c2e1..ed06406 100644 (file)
@@ -534,9 +534,10 @@ typedef struct ImagePaintSettings {
 } ImagePaintSettings;
 
 typedef struct ParticleBrushData {
-       short size, strength;   /* common settings */
-       short step, invert;             /* for specific brushes only */
-       int flag, pad;
+       short size;                                             /* common setting */
+       short step, invert, count;              /* for specific brushes only */
+       int flag;
+       float strength;
 } ParticleBrushData;
 
 typedef struct ParticleEditSettings {
index c483025..aa85acb 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "BKE_paint.h"
 
+#include "WM_api.h"
 #include "WM_types.h"
 
 static EnumPropertyItem particle_edit_hair_brush_items[] = {
@@ -128,7 +129,21 @@ static void rna_ParticleEdit_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
        if(ob) DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 }
+static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value)
+{
+       ParticleEditSettings *pset= (ParticleEditSettings*)ptr->data;
+       
+       /* redraw hair completely if weight brush is/was used */
+       if(pset->brushtype == PE_BRUSH_WEIGHT || value == PE_BRUSH_WEIGHT) {
+               Object *ob = (pset->scene->basact)? pset->scene->basact->object: NULL;
+               if(ob) {
+                       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+                       WM_main_add_notifier(NC_OBJECT|ND_PARTICLE_DATA, NULL);
+               }
+       }
 
+       pset->brushtype = value;
+}
 static EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *ptr, int *free)
 {
        Scene *scene= CTX_data_scene(C);
@@ -407,7 +422,7 @@ static void rna_def_particle_edit(BlenderRNA *brna)
        prop= RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "brushtype");
        RNA_def_property_enum_items(prop, particle_edit_hair_brush_items);
-       RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_ParticleEdit_tool_itemf");
+       RNA_def_property_enum_funcs(prop, NULL, "rna_ParticleEdit_tool_set", "rna_ParticleEdit_tool_itemf");
        RNA_def_property_ui_text(prop, "Tool", "");
 
        prop= RNA_def_property(srna, "selection_mode", PROP_ENUM, PROP_NONE);
@@ -504,11 +519,15 @@ static void rna_def_particle_edit(BlenderRNA *brna)
        RNA_def_property_ui_range(prop, 1, 100, 10, 3);
        RNA_def_property_ui_text(prop, "Size", "Brush size");
 
-       prop= RNA_def_property(srna, "strength", PROP_INT, PROP_NONE);
-       RNA_def_property_range(prop, 1, INT_MAX);
-       RNA_def_property_ui_range(prop, 1, 100, 10, 3);
+       prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_range(prop, 0.001, 1.0);
        RNA_def_property_ui_text(prop, "Strength", "Brush strength");
 
+       prop= RNA_def_property(srna, "count", PROP_INT, PROP_NONE);
+       RNA_def_property_range(prop, 1, 1000);
+       RNA_def_property_ui_range(prop, 1, 100, 10, 3);
+       RNA_def_property_ui_text(prop, "Count", "Particle count");
+
        prop= RNA_def_property(srna, "steps", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "step");
        RNA_def_property_range(prop, 1, INT_MAX);