diff options
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 46 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_ops.c | 3 |
3 files changed, 50 insertions, 0 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index fe38d71dc92..f0870ca9764 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2366,6 +2366,52 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) RNA_def_float(ot->srna, "threshold", 0.0002f, 0.0f, FLT_MAX, "Threshold", "Threshold distance withing which particles are removed", 0.00001f, 0.1f); } + +static int weight_set_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + ParticleEditSettings *pset= PE_settings(scene); + Object *ob= CTX_data_active_object(C); + PTCacheEdit *edit= PE_get_current(scene, ob); + ParticleSystem *psys = edit->psys; + POINT_P; + KEY_K; + HairKey *hkey; + float weight; + ParticleBrushData *brush= &pset->brush[pset->brushtype]; + edit= psys->edit; + + weight= (float)(brush->strength / 100.0f); + + LOOP_SELECTED_POINTS { + ParticleData *pa= psys->particles + p; + + LOOP_SELECTED_KEYS { + hkey= pa->hair + k; + hkey->weight= weight; + } + } + + DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob); + + return OPERATOR_FINISHED; +} + +void PARTICLE_OT_weight_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Weight Set"; + ot->idname= "PARTICLE_OT_weight_set"; + + /* api callbacks */ + ot->exec= weight_set_exec; + ot->poll= PE_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /************************ cursor drawing *******************************/ static void brush_drawcursor(bContext *C, int x, int y, void *customdata) diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index cc0a288f8be..3de5c256df7 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -50,6 +50,7 @@ void PARTICLE_OT_reveal(struct wmOperatorType *ot); void PARTICLE_OT_rekey(struct wmOperatorType *ot); void PARTICLE_OT_subdivide(struct wmOperatorType *ot); void PARTICLE_OT_remove_doubles(struct wmOperatorType *ot); +void PARTICLE_OT_weight_set(struct wmOperatorType *ot); void PARTICLE_OT_delete(struct wmOperatorType *ot); void PARTICLE_OT_mirror(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 5cb8230e463..2728f64a777 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -57,6 +57,7 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_rekey); WM_operatortype_append(PARTICLE_OT_subdivide); WM_operatortype_append(PARTICLE_OT_remove_doubles); + WM_operatortype_append(PARTICLE_OT_weight_set); WM_operatortype_append(PARTICLE_OT_delete); WM_operatortype_append(PARTICLE_OT_mirror); @@ -111,6 +112,8 @@ static void keymap_particle(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0); + + WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); ED_object_generic_keymap(keyconf, keymap, 1); } |