diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-06-17 14:10:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-06-17 14:13:47 +0300 |
commit | 70c061ee0a9af885e1a8c02894369b332aea75fe (patch) | |
tree | c339d0885d6fc69d523609712b8dac48c54b9095 /source/blender | |
parent | 7dae6eb5a2532d2937c1c89d053a7e7f1c8f7bef (diff) |
Fix T63411: Crash adding meta-ball with a small radius
Change how the radius, changing the size of meta plane, sphere & cube.
Previously the size of these primitives would be kept the same,
with only the radius outside the primitive being scaled.
This led to small scale adding a lot of polygons instead
of scaling the primitive down as users would expect.
Also change behavior not to change the resolution when adding
to an existing meta-ball.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_mball.h | 8 | ||||
-rw-r--r-- | source/blender/editors/metaball/mball_edit.c | 18 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 2 |
3 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 938d1059f90..5c2106b934c 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -38,8 +38,12 @@ void ED_operatortypes_metaball(void); void ED_operatormacros_metaball(void); void ED_keymap_metaball(struct wmKeyConfig *keyconf); -struct MetaElem *ED_mball_add_primitive( - struct bContext *C, struct Object *obedit, float mat[4][4], float dia, int type); +struct MetaElem *ED_mball_add_primitive(struct bContext *C, + struct Object *obedit, + bool obedit_is_new, + float mat[4][4], + float dia, + int type); bool ED_mball_select_pick( struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index a25175510cd..386fa1efa95 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -93,9 +93,11 @@ void ED_mball_editmball_load(Object *UNUSED(obedit)) { } -/* Add metaelem primitive to metaball object (which is in edit mode) */ +/** + * Add meta-element primitive to meta-ball object (which is in edit mode). + */ MetaElem *ED_mball_add_primitive( - bContext *UNUSED(C), Object *obedit, float mat[4][4], float dia, int type) + bContext *UNUSED(C), Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type) { MetaBall *mball = (MetaBall *)obedit->data; MetaElem *ml; @@ -109,9 +111,17 @@ MetaElem *ED_mball_add_primitive( ml = BKE_mball_element_add(mball, type); ml->rad *= dia; - mball->wiresize *= dia; - mball->rendersize *= dia; + + if (obedit_is_new) { + mball->wiresize *= dia; + mball->rendersize *= dia; + } copy_v3_v3(&ml->x, mat[3]); + /* MB_ELIPSOID works differently (intentional?). Whatever the case, + * on testing this needs to be skipped otherwise it doesn't behave like other types. */ + if (type != MB_ELIPSOID) { + mul_v3_fl(&ml->expx, dia); + } ml->flag |= SELECT; mball->lastelem = ml; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 50f85545c19..653e9d39eca 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -860,7 +860,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) * we want to pass in 1 so other values such as resolution are scaled by 1.0. */ dia = RNA_float_get(op->ptr, "radius") / 2; - ED_mball_add_primitive(C, obedit, mat, dia, RNA_enum_get(op->ptr, "type")); + ED_mball_add_primitive(C, obedit, newob, mat, dia, RNA_enum_get(op->ptr, "type")); /* userdef */ if (newob && !enter_editmode) { |