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