fix for crashes running some operators in background mode and some divide by zero errors.
This commit is contained in:
@@ -3436,7 +3436,9 @@ int BKE_curve_center_median(Curve *cu, float cent[3])
|
||||
}
|
||||
}
|
||||
|
||||
mul_v3_fl(cent, 1.0f / (float)total);
|
||||
if (total) {
|
||||
mul_v3_fl(cent, 1.0f / (float)total);
|
||||
}
|
||||
|
||||
return (total != 0);
|
||||
}
|
||||
|
||||
@@ -563,7 +563,9 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode
|
||||
add_v3_v3(cent, ebone->head);
|
||||
add_v3_v3(cent, ebone->tail);
|
||||
}
|
||||
mul_v3_fl(cent, 1.0f / (float)total);
|
||||
if (total) {
|
||||
mul_v3_fl(cent, 1.0f / (float)total);
|
||||
}
|
||||
}
|
||||
else {
|
||||
float min[3], max[3];
|
||||
|
||||
@@ -3955,9 +3955,11 @@ static int edbm_select_mirror_exec(bContext *C, wmOperator *op)
|
||||
BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
int extend = RNA_boolean_get(op->ptr, "extend");
|
||||
|
||||
EDBM_select_mirrored(obedit, em, extend);
|
||||
EDBM_selectmode_flush(em);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
|
||||
if (em->bm->totvert && em->bm->totvertsel) {
|
||||
EDBM_select_mirrored(obedit, em, extend);
|
||||
EDBM_selectmode_flush(em);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -2005,7 +2005,8 @@ void OBJECT_OT_duplicate(wmOperatorType *ot)
|
||||
|
||||
static int add_named_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmEvent *event = CTX_wm_window(C)->eventstate;
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
wmEvent *event = win ? win->eventstate : NULL;
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Base *basen, *base;
|
||||
@@ -2037,8 +2038,10 @@ static int add_named_exec(bContext *C, wmOperator *op)
|
||||
|
||||
basen->lay = basen->object->lay = scene->lay;
|
||||
|
||||
ED_object_location_from_view(C, basen->object->loc);
|
||||
ED_view3d_cursor3d_position(C, basen->object->loc, event->x, event->y);
|
||||
if (event) {
|
||||
ED_object_location_from_view(C, basen->object->loc);
|
||||
ED_view3d_cursor3d_position(C, basen->object->loc, event->x, event->y);
|
||||
}
|
||||
|
||||
ED_base_object_activate(C, basen);
|
||||
|
||||
|
||||
@@ -700,9 +700,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
else {
|
||||
if (around == V3D_CENTROID) {
|
||||
const float total_div = 1.0f / (float)em->bm->totvert;
|
||||
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
|
||||
madd_v3_v3fl(cent, eve->co, total_div);
|
||||
if (em->bm->totvert) {
|
||||
const float total_div = 1.0f / (float)em->bm->totvert;
|
||||
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
|
||||
madd_v3_v3fl(cent, eve->co, total_div);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -266,10 +266,10 @@ static int unpack_item_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
ID *id;
|
||||
char idname[BKE_ST_MAXNAME];
|
||||
char idname[MAX_ID_NAME - 2];
|
||||
int type = RNA_int_get(op->ptr, "id_type");
|
||||
int method = RNA_enum_get(op->ptr, "method");
|
||||
|
||||
|
||||
RNA_string_get(op->ptr, "id_name", idname);
|
||||
id = BKE_libblock_find_name(type, idname);
|
||||
|
||||
@@ -319,7 +319,7 @@ void FILE_OT_unpack_item(wmOperatorType *ot)
|
||||
/* properties */
|
||||
RNA_def_enum(ot->srna, "method", unpack_item_method_items, PF_USE_LOCAL, "Method", "How to unpack");
|
||||
RNA_def_string(ot->srna, "id_name", "", BKE_ST_MAXNAME, "ID name", "Name of ID block to unpack");
|
||||
RNA_def_int(ot->srna, "id_type", 0, 0, INT_MAX, "ID Type", "Identifier type of ID block", 0, INT_MAX);
|
||||
RNA_def_int(ot->srna, "id_type", ID_IM, 0, INT_MAX, "ID Type", "Identifier type of ID block", 0, INT_MAX);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6023,7 +6023,7 @@ static int createVertSlideVerts(TransInfo *t)
|
||||
if (t->spacetype == SPACE_VIEW3D) {
|
||||
/* background mode support */
|
||||
// v3d = t->sa ? t->sa->spacedata.first : NULL;
|
||||
rv3d = t->ar ? t->ar->regiondata : NULL;
|
||||
rv3d = ar ? ar->regiondata : NULL;
|
||||
}
|
||||
|
||||
sld->is_proportional = true;
|
||||
@@ -6089,18 +6089,30 @@ static int createVertSlideVerts(TransInfo *t)
|
||||
if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
|
||||
BMVert *v_other = BM_edge_other_vert(e, v);
|
||||
copy_v3_v3(sv_array[j].co_link_orig_3d[k], v_other->co);
|
||||
ED_view3d_project_float_v2_m4(ar,
|
||||
sv_array[j].co_link_orig_3d[k],
|
||||
sv_array[j].co_link_orig_2d[k],
|
||||
projectMat);
|
||||
if (ar) {
|
||||
ED_view3d_project_float_v2_m4(ar,
|
||||
sv_array[j].co_link_orig_3d[k],
|
||||
sv_array[j].co_link_orig_2d[k],
|
||||
projectMat);
|
||||
}
|
||||
else {
|
||||
copy_v2_v2(sv_array[j].co_link_orig_2d[k],
|
||||
sv_array[j].co_link_orig_3d[k]);
|
||||
}
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
ED_view3d_project_float_v2_m4(ar,
|
||||
sv_array[j].co_orig_3d,
|
||||
sv_array[j].co_orig_2d,
|
||||
projectMat);
|
||||
if (ar) {
|
||||
ED_view3d_project_float_v2_m4(ar,
|
||||
sv_array[j].co_orig_3d,
|
||||
sv_array[j].co_orig_2d,
|
||||
projectMat);
|
||||
}
|
||||
else {
|
||||
copy_v2_v2(sv_array[j].co_orig_2d,
|
||||
sv_array[j].co_orig_3d);
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
@@ -433,14 +433,18 @@ void makeraytree(Render *re)
|
||||
* This is ONLY needed to kept a bogus behavior of SUN and HEMI lights */
|
||||
INIT_MINMAX(min, max);
|
||||
RE_rayobject_merge_bb(re->raytree, min, max);
|
||||
if (min[0] > max[0]) { /* empty raytree */
|
||||
zero_v3(min);
|
||||
zero_v3(max);
|
||||
}
|
||||
for (i=0; i<3; i++) {
|
||||
/* TODO: explain why add top both min and max??? */
|
||||
min[i] += 0.01f;
|
||||
max[i] += 0.01f;
|
||||
sub[i] = max[i]-min[i];
|
||||
}
|
||||
|
||||
re->maxdist = dot_v3v3(sub, sub);
|
||||
if (re->maxdist > 0.0f) re->maxdist= sqrt(re->maxdist);
|
||||
re->maxdist = len_v3(sub);
|
||||
|
||||
re->i.infostr= "Raytree finished";
|
||||
re->stats_draw(re->sdh, &re->i);
|
||||
|
||||
Reference in New Issue
Block a user