Fix T52733 Percent mode for Bevel sometimes had nans.
authorHoward Trickey <howard.trickey@gmail.com>
Tue, 19 Sep 2017 13:38:17 +0000 (09:38 -0400)
committerHoward Trickey <howard.trickey@gmail.com>
Tue, 19 Sep 2017 13:39:11 +0000 (09:39 -0400)
Forgot some initialization.

source/blender/editors/mesh/editmesh_bevel.c

index a81add7a86edc0e4f8a50d92f85cc2b48ed919ed..6b4f3516338c12679eb3a3f059092184da4a5513 100644 (file)
@@ -150,6 +150,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
 
        for (i = 0; i < NUM_VALUE_KINDS; i++) {
                opdata->shift_value[i] = -1.0f;
 
        for (i = 0; i < NUM_VALUE_KINDS; i++) {
                opdata->shift_value[i] = -1.0f;
+               opdata->initial_length[i] = -1.0f;
                /* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */
                opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch; 
 
                /* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */
                opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch; 
 
@@ -300,7 +301,7 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event,
        mlen[1] = opdata->mcenter[1] - event->mval[1];
        len = len_v2(mlen);
        vmode = opdata->value_mode;
        mlen[1] = opdata->mcenter[1] - event->mval[1];
        len = len_v2(mlen);
        vmode = opdata->value_mode;
-       if (mode_changed) {
+       if (mode_changed || opdata->initial_length[vmode] == -1.0f) {
                /* If current value is not default start value, adjust len so that 
                 * the scaling and offset in edbm_bevel_mouse_set_value will
                 * start at current value */
                /* If current value is not default start value, adjust len so that 
                 * the scaling and offset in edbm_bevel_mouse_set_value will
                 * start at current value */
@@ -506,6 +507,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
                                        else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT)
                                                opdata->value_mode = OFFSET_VALUE;
                                        RNA_property_enum_set(op->ptr, prop, type);
                                        else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT)
                                                opdata->value_mode = OFFSET_VALUE;
                                        RNA_property_enum_set(op->ptr, prop, type);
+                                       if (opdata->initial_length[opdata->value_mode] == -1.0f)
+                                               edbm_bevel_calc_initial_length(op, event, true);
                                }
                                /* Update offset accordingly to new offset_type. */
                                if (!has_numinput &&
                                }
                                /* Update offset accordingly to new offset_type. */
                                if (!has_numinput &&