[Bf-committers] [Bf-blender-cvs] [c9209de] master: vertex weights: add weight quantize tool.

IRIE Shinsuke irieshinsuke at yahoo.co.jp
Sun Nov 17 10:25:11 CET 2013


In the wiki, how do we make a link to the git commit log?

IRIE Shinsuke

13/11/17, Brecht Van Lommel wrote:
> Hi,
>
> Just a friendly reminder to add new features to release notes immediately:
> http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70
>
> I'm replying to this particular commit, but I noticed a bunch of
> recent changes by various developers and no updates in the wiki, so it
> seems we needed another reminder.
>
> (And could you write commit logs with capitalization? Makes it more
> consistent and easier to generate bug fixes list later.)
>
> Thanks,
> Brecht.
>
> On Sun, Nov 17, 2013 at 8:57 AM, Campbell Barton
> <noreply at git.blender.org> wrote:
>> Commit: c9209de573ad680dbad6b560c05a90b02b780267
>> Author: Campbell Barton
>> Date:   Sun Nov 17 14:54:42 2013 +1100
>> http://developer.blender.org/rBc9209de573ad680dbad6b560c05a90b02b780267
>>
>> vertex weights: add weight quantize tool.
>>
>> ===================================================================
>>
>> M       release/scripts/startup/bl_ui/space_view3d.py
>> M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
>> M       source/blender/editors/object/object_intern.h
>> M       source/blender/editors/object/object_ops.c
>> M       source/blender/editors/object/object_vgroup.c
>>
>> ===================================================================
>>
>> diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
>> index ea2826f..16cef7c 100644
>> --- a/release/scripts/startup/bl_ui/space_view3d.py
>> +++ b/release/scripts/startup/bl_ui/space_view3d.py
>> @@ -1502,6 +1502,7 @@ class VIEW3D_MT_paint_weight(Menu):
>>           layout.operator("object.vertex_group_mirror", text="Mirror")
>>           layout.operator("object.vertex_group_invert", text="Invert")
>>           layout.operator("object.vertex_group_clean", text="Clean")
>> +        layout.operator("object.vertex_group_quantize", text="Quantize")
>>           layout.operator("object.vertex_group_levels", text="Levels")
>>           layout.operator("object.vertex_group_blend", text="Blend")
>>           layout.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
>> diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
>> index 088dfc3..8c86cc6 100644
>> --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
>> +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
>> @@ -1115,6 +1115,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
>>           col.operator("object.vertex_group_mirror", text="Mirror")
>>           col.operator("object.vertex_group_invert", text="Invert")
>>           col.operator("object.vertex_group_clean", text="Clean")
>> +        col.operator("object.vertex_group_quantize", text="Quantize")
>>           col.operator("object.vertex_group_levels", text="Levels")
>>           col.operator("object.vertex_group_blend", text="Blend")
>>           col.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
>> diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
>> index 4ff3bc9..313ac1d 100644
>> --- a/source/blender/editors/object/object_intern.h
>> +++ b/source/blender/editors/object/object_intern.h
>> @@ -222,6 +222,7 @@ void OBJECT_OT_vertex_group_fix(struct wmOperatorType *ot);
>>   void OBJECT_OT_vertex_group_invert(struct wmOperatorType *ot);
>>   void OBJECT_OT_vertex_group_blend(struct wmOperatorType *ot);
>>   void OBJECT_OT_vertex_group_clean(struct wmOperatorType *ot);
>> +void OBJECT_OT_vertex_group_quantize(struct wmOperatorType *ot);
>>   void OBJECT_OT_vertex_group_limit_total(struct wmOperatorType *ot);
>>   void OBJECT_OT_vertex_group_mirror(struct wmOperatorType *ot);
>>   void OBJECT_OT_vertex_group_set_active(struct wmOperatorType *ot);
>> diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
>> index 333e5ff..f5c2bcb 100644
>> --- a/source/blender/editors/object/object_ops.c
>> +++ b/source/blender/editors/object/object_ops.c
>> @@ -191,6 +191,7 @@ void ED_operatortypes_object(void)
>>          WM_operatortype_append(OBJECT_OT_vertex_group_levels);
>>          WM_operatortype_append(OBJECT_OT_vertex_group_blend);
>>          WM_operatortype_append(OBJECT_OT_vertex_group_clean);
>> +       WM_operatortype_append(OBJECT_OT_vertex_group_quantize);
>>          WM_operatortype_append(OBJECT_OT_vertex_group_limit_total);
>>          WM_operatortype_append(OBJECT_OT_vertex_group_mirror);
>>          WM_operatortype_append(OBJECT_OT_vertex_group_set_active);
>> diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
>> index a6f7c4d..16ee400 100644
>> --- a/source/blender/editors/object/object_vgroup.c
>> +++ b/source/blender/editors/object/object_vgroup.c
>> @@ -2398,6 +2398,44 @@ static void vgroup_clean_subset(Object *ob, const bool *vgroup_validmap, const i
>>          }
>>   }
>>
>> +static void vgroup_quantize_subset(Object *ob, const bool *vgroup_validmap, const int vgroup_tot, const int UNUSED(subset_count),
>> +                                   const int steps)
>> +{
>> +       MDeformVert **dvert_array = NULL;
>> +       int dvert_tot = 0;
>> +       const bool use_vert_sel = vertex_group_use_vert_sel(ob);
>> +       const bool use_mirror = (ob->type == OB_MESH) ? (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 : false;
>> +       ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
>> +
>> +       if (dvert_array) {
>> +               const float steps_fl = steps;
>> +               MDeformVert *dv;
>> +               int i;
>> +
>> +               if (use_mirror && use_vert_sel) {
>> +                       ED_vgroup_parray_mirror_assign(ob, dvert_array, dvert_tot);
>> +               }
>> +
>> +               for (i = 0; i < dvert_tot; i++) {
>> +                       MDeformWeight *dw;
>> +                       int j;
>> +
>> +                       /* in case its not selected */
>> +                       if (!(dv = dvert_array[i])) {
>> +                               continue;
>> +                       }
>> +
>> +                       for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) {
>> +                               if ((dw->def_nr < vgroup_tot) && vgroup_validmap[dw->def_nr]) {
>> +                                       dw->weight = floorf((dw->weight * steps_fl) + 0.5f) / steps_fl;
>> +                                       CLAMP(dw->weight, 0.0f, 1.0f);
>> +                               }
>> +                       }
>> +               }
>> +
>> +               MEM_freeN(dvert_array);
>> +       }
>> +}
>>
>>   static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
>>                               const char sel, const char sel_mirr,
>> @@ -3754,6 +3792,44 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot)
>>                          "Keep verts assigned to at least one group when cleaning");
>>   }
>>
>> +static int vertex_group_quantize_exec(bContext *C, wmOperator *op)
>> +{
>> +       Object *ob = ED_object_context(C);
>> +
>> +       const int steps = RNA_int_get(op->ptr, "steps");
>> +       eVGroupSelect subset_type  = RNA_enum_get(op->ptr, "group_select_mode");
>> +
>> +       int subset_count, vgroup_tot;
>> +
>> +       const bool *vgroup_validmap = ED_vgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count);
>> +       vgroup_quantize_subset(ob, vgroup_validmap, vgroup_tot, subset_count, steps);
>> +       MEM_freeN((void *)vgroup_validmap);
>> +
>> +       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
>> +       WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
>> +       WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
>> +
>> +       return OPERATOR_FINISHED;
>> +}
>> +
>> +void OBJECT_OT_vertex_group_quantize(wmOperatorType *ot)
>> +{
>> +       /* identifiers */
>> +       ot->name = "Quantize Vertex Weights";
>> +       ot->idname = "OBJECT_OT_vertex_group_quantize";
>> +       ot->description = "Set weights to a fixed number of steps";
>> +
>> +       /* api callbacks */
>> +       ot->poll = vertex_group_poll;
>> +       ot->exec = vertex_group_quantize_exec;
>> +
>> +       /* flags */
>> +       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
>> +
>> +       vgroup_operator_subset_select_props(ot, true);
>> +       RNA_def_int(ot->srna, "steps", 4, 1, 1000, "Steps", "Number of steps between 0 and 1", 1, 100);
>> +}
>> +
>>   static int vertex_group_limit_total_exec(bContext *C, wmOperator *op)
>>   {
>>          Object *ob = ED_object_context(C);
>>
>> _______________________________________________
>> Bf-blender-cvs mailing list
>> Bf-blender-cvs at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list