From c32720a0c0e8a846ff1f54a663e2cea848df724f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Jul 2010 05:47:46 +0000 Subject: bugfix [#23055] transforms with proportional fall off affect hidden vertices in certain situations faces were not being checked if they were hidden before adding their internal edges for connected proportional editing. --- source/blender/editors/transform/transform_conversions.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 0edf6f6d10c..2f8da7c2dd6 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1775,14 +1775,17 @@ static int connectivity_edge(float mtx[][3], EditVert *v1, EditVert *v2) float edge_len; int done = 0; + /* note: hidden verts are not being checked for, this assumes + * flushing of hidden faces & edges is working right */ + + if (v1->f2 + v2->f2 == 4) + return 0; + sub_v3_v3v3(edge_vec, v1->co, v2->co); mul_m3_v3(mtx, edge_vec); edge_len = len_v3(edge_vec); - if (v1->f2 + v2->f2 == 4) - return 0; - if (v1->f2) { if (v2->f2) { if (v2->tmp.fp + edge_len + THRESHOLD < v1->tmp.fp) { @@ -1848,7 +1851,7 @@ static void editmesh_set_connectivity_distance(EditMesh *em, float mtx[][3]) /* do internal edges for quads */ for(efa= em->faces.first; efa; efa= efa->next) { - if (efa->v4) { + if (efa->v4 && efa->h==0) { done |= connectivity_edge(mtx, efa->v1, efa->v3); done |= connectivity_edge(mtx, efa->v2, efa->v4); } -- cgit v1.2.3 From f2e1136ca3983e671f1484ddbe471c8a422ab9ea Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Jul 2010 07:00:40 +0000 Subject: bugfix [#23053] Blender crashes when adding image as a strip buffer overrun when copying image name. --- source/blender/editors/space_sequencer/sequencer_add.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 4d51ac05fbd..b00fcfcc22a 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -181,7 +181,9 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op) /* used for image strip */ /* best guess, first images name */ RNA_BEGIN(op->ptr, itemptr, "files") { - RNA_string_get(&itemptr, "name", seq_load->name); + char *name= RNA_string_get_alloc(&itemptr, "name", NULL, 0); + BLI_strncpy(seq_load->name, name, sizeof(seq_load->name)); + MEM_freeN(name); break; } RNA_END; -- cgit v1.2.3 From 79dd2cc8e9073039d3518c41d90adb006d344201 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 28 Jul 2010 08:05:39 +0000 Subject: Fix [#22197] empty XYZ text size changing according to distance from origin Partial revert for commit r 27946 Empty/axis xyz text is now purely aligned to object space. Previous 3d view matrix manipulation stuff that I added wasn't correct, and causing more problems than it solved. Perhaps someone can tweak this later to be fixed size/screen aligned, but for now this is less annoying. --- source/blender/editors/space_view3d/drawarmature.c | 11 +----- source/blender/editors/space_view3d/drawobject.c | 43 ++++++---------------- .../blender/editors/space_view3d/view3d_intern.h | 2 +- 3 files changed, 15 insertions(+), 41 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index d16f89e5785..5e0c49e6224 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1882,15 +1882,12 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* Draw additional axes on the bone tail */ if ( (arm->flag & ARM_DRAWAXES) && (arm->flag & ARM_POSEMODE) ) { - float mat[4][4]; glPushMatrix(); copy_m4_m4(bmat, pchan->pose_mat); bone_matrix_translate_y(bmat, pchan->bone->length); glMultMatrixf(bmat); - mul_m4_m4m4(mat, bmat, rv3d->viewmatob); - - drawaxes(rv3d, mat, pchan->bone->length*0.25f, 0, OB_ARROWS); + drawaxes(pchan->bone->length*0.25f, 0, OB_ARROWS); glPopMatrix(); } @@ -2078,16 +2075,12 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) } /* Draw additional axes */ if (arm->flag & ARM_DRAWAXES) { - float mat[4][4]; glPushMatrix(); get_matrix_editbone(eBone, bmat); bone_matrix_translate_y(bmat, eBone->length); glMultMatrixf(bmat); - mul_m4_m4m4(mat, bmat, rv3d->viewmatob); - - /* do cached text draw immediate to include transform */ - drawaxes(rv3d, mat, eBone->length*0.25f, 0, OB_ARROWS); + drawaxes(eBone->length*0.25f, 0, OB_ARROWS); glPopMatrix(); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 30bfa123007..5bb1ea2cc9f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -321,31 +321,12 @@ static float cosval[32] ={ 1.00000000 }; -static void draw_xyz_wire(RegionView3D *rv3d, float mat[][4], float *c, float size, int axis) +static void draw_xyz_wire(float *c, float size, int axis) { float v1[3]= {0.f, 0.f, 0.f}, v2[3] = {0.f, 0.f, 0.f}; - float imat[4][4]; - float dim; - float dx[3], dy[3]; - - /* hrms, really only works properly after glLoadMatrixf(rv3d->viewmat); */ - float pixscale= rv3d->persmat[0][3]*c[0]+ rv3d->persmat[1][3]*c[1]+ rv3d->persmat[2][3]*c[2] + rv3d->persmat[3][3]; - pixscale*= rv3d->pixsize; - - /* halfway blend between fixed size in worldspace vs viewspace - - * alleviates some of the weirdness due to not using viewmat for gl matrix */ - dim = (0.05*size*0.5) + (size*10.f*pixscale*0.5); - - invert_m4_m4(imat, mat); - normalize_v3(imat[0]); - normalize_v3(imat[1]); - - copy_v3_v3(dx, imat[0]); - copy_v3_v3(dy, imat[1]); + float dim = size * 0.1; + float dx[3]={dim, 0.0, 0.0}, dy[3]={0.0, dim, 0.0}, dz[3]={0.0, 0.0, dim}; - mul_v3_fl(dx, dim); - mul_v3_fl(dy, dim); - switch(axis) { case 0: /* x axis */ glBegin(GL_LINES); @@ -397,7 +378,7 @@ static void draw_xyz_wire(RegionView3D *rv3d, float mat[][4], float *c, float si /* start at top left */ sub_v3_v3v3(v1, c, dx); - add_v3_v3v3(v1, c, dy); + add_v3_v3v3(v1, c, dz); glVertex3fv(v1); @@ -406,9 +387,9 @@ static void draw_xyz_wire(RegionView3D *rv3d, float mat[][4], float *c, float si glVertex3fv(v1); - mul_v3_fl(dy, 2.f); + mul_v3_fl(dz, 2.f); sub_v3_v3(v1, dx); - sub_v3_v3(v1, dy); + sub_v3_v3(v1, dz); glVertex3fv(v1); @@ -423,7 +404,7 @@ static void draw_xyz_wire(RegionView3D *rv3d, float mat[][4], float *c, float si } /* flag is same as for draw_object */ -void drawaxes(RegionView3D *rv3d, float mat[][4], float size, int flag, char drawtype) +void drawaxes(float size, int flag, char drawtype) { int axis; float v1[3]= {0.0, 0.0, 0.0}; @@ -522,7 +503,7 @@ void drawaxes(RegionView3D *rv3d, float mat[][4], float size, int flag, char dra v2[axis]+= size*0.125; - draw_xyz_wire(rv3d, mat, v2, size, axis); + draw_xyz_wire(v2, size, axis); } break; } @@ -5925,7 +5906,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } case OB_EMPTY: if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) - drawaxes(rv3d, rv3d->viewmatob, ob->empty_drawsize, flag, ob->empty_drawtype); + drawaxes(ob->empty_drawsize, flag, ob->empty_drawtype); break; case OB_LAMP: if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { @@ -5951,7 +5932,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) break; default: if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { - drawaxes(rv3d, rv3d->viewmatob, 1.0, flag, OB_ARROWS); + drawaxes(1.0, flag, OB_ARROWS); } } @@ -6151,7 +6132,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(dtx && (G.f & G_RENDER_OGL)==0) { if(dtx & OB_AXIS) { - drawaxes(rv3d, rv3d->viewmatob, 1.0f, flag, OB_ARROWS); + drawaxes(1.0f, flag, OB_ARROWS); } if(dtx & OB_BOUNDBOX) { if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) @@ -6525,7 +6506,7 @@ void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object draw_object_mesh_instance(scene, v3d, rv3d, ob, dt, outline); break; case OB_EMPTY: - drawaxes(rv3d, rv3d->viewmatob, ob->empty_drawsize, 0, ob->empty_drawtype); + drawaxes(ob->empty_drawsize, 0, ob->empty_drawtype); break; } } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 846300ff9a6..fd78c8298e9 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -105,7 +105,7 @@ void draw_object(Scene *scene, struct ARegion *ar, View3D *v3d, Base *base, int int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt); void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int dt, int outline); void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob); -void drawaxes(struct RegionView3D *rv3d, float mat[][4], float size, int flag, char drawtype); +void drawaxes(float size, int flag, char drawtype); void view3d_cached_text_draw_begin(void); void view3d_cached_text_draw_add(float x, float y, float z, char *str, short xoffs, short flag); -- cgit v1.2.3 From 114b86f6d7781836635799deb12631a4f36c4eee Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 28 Jul 2010 13:15:29 +0000 Subject: Fix #22996: switching scenes did not exit editmode, meaning changes made were not visible in the other scene in object mode. --- source/blender/editors/screen/screen_edit.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 952f34ae2be..5082992aaba 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -51,6 +51,7 @@ #include "WM_types.h" #include "ED_image.h" +#include "ED_object.h" #include "ED_view3d.h" #include "ED_screen.h" #include "ED_screen_types.h" @@ -1369,6 +1370,8 @@ void ED_screen_set_scene(bContext *C, Scene *scene) bScreen *sc; bScreen *curscreen= CTX_wm_screen(C); + ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); + for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { if((U.flag & USER_SCENEGLOBAL) || sc==curscreen) { -- cgit v1.2.3 From 88cbcb0206b7f727b24c6018a24dc1c1a08e9531 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Jul 2010 00:44:53 +0000 Subject: bugfix [#23062] Resolve conflict button in text editor dissappers in Blener 2.5 beta release also uncommented console some code for testing by mistake & remove warning. --- source/blender/editors/space_text/text_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 91fb616a63f..25726bae84b 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -218,7 +218,7 @@ static int open_exec(bContext *C, wmOperator *op) PropertyPointerRNA *pprop; PointerRNA idptr; char str[FILE_MAX]; - short internal = RNA_int_get(op->ptr, "internal"); + short internal = RNA_boolean_get(op->ptr, "internal"); RNA_string_get(op->ptr, "filepath", str); -- cgit v1.2.3 From 4e405a9f3e2d13562515467f99775b1c7f6d496d Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 29 Jul 2010 02:29:32 +0000 Subject: Fixed some potential memory corruption --- source/blender/editors/sculpt_paint/paint_stroke.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 634829060b4..814b30a6673 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -789,7 +789,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev Paint *paint = paint_get_active(CTX_data_scene(C)); // XXX Brush *brush = paint_brush(paint); // XXX - float mouse[2]; + float mouse[3]; PointerRNA itemptr; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 546fbc14dfa..27d2d668790 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3073,20 +3073,15 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, SculptSession cache->special_rotation = atan2(dx, dy) + M_PI; if (brush->flag & BRUSH_EDGE_TO_EDGE) { - float d[3]; - float halfway[3]; + float halfway[2]; float out[3]; - d[0] = dx; - d[1] = dy; - d[2] = 0; - - mul_v3_v3fl(halfway, d, 0.5f); - add_v3_v3(halfway, cache->initial_mouse); + halfway[0] = dx*0.5 + cache->initial_mouse[0]; + halfway[1] = dy*0.5 + cache->initial_mouse[1]; if (sculpt_stroke_get_location(C, stroke, out, halfway)) { copy_v3_v3(sd->anchored_location, out); - copy_v3_v3(sd->anchored_initial_mouse, halfway); + copy_v2_v2(sd->anchored_initial_mouse, halfway); copy_v2_v2(cache->tex_mouse, halfway); copy_v3_v3(cache->true_location, sd->anchored_location); sd->anchored_size /= 2.0f; @@ -3114,7 +3109,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, SculptSession const float dy = cache->last_rake[1] - cache->mouse[1]; if (cache->first_time) { - copy_v3_v3(cache->last_rake, cache->mouse); + copy_v2_v2(cache->last_rake, cache->mouse); } else if (dx*dx + dy*dy >= r*r) { cache->special_rotation = atan2(dx, dy); -- cgit v1.2.3 From 407f394952d7d8f831824eff49d2ea85be8b22bc Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 29 Jul 2010 05:16:42 +0000 Subject: == Sculpt == * Changed rotation brush to not scale down the rotation angle; easier to control this way (and works the same as anchored brush rotation.) Note: rotate brush seems to work much better with USE_ORIGINAL_NORMAL, this should probably be made the default, if not forced on. --- source/blender/editors/sculpt_paint/sculpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 27d2d668790..3d74496ab67 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3125,7 +3125,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, SculptSession dx = cache->mouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; - cache->vertex_rotation = -atan2(dx, dy) / 4.0f; + cache->vertex_rotation = -atan2(dx, dy); sd->draw_anchored = 1; copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); -- cgit v1.2.3 From e33460150b0a0bf63e63db6bceb36114028feea0 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 29 Jul 2010 07:21:57 +0000 Subject: Added back modal keymap items for view manipulation mode switching in zoom/pan, so they can be added in customisation. Not sure why these were removed. --- source/blender/editors/space_view3d/view3d_edit.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index f4fbb501fc3..2e26988877f 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -826,6 +826,9 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + + {VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"}, + {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, {0, NULL, 0, NULL, NULL}}; @@ -968,6 +971,9 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + + {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, + {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"}, {0, NULL, 0, NULL, NULL}}; -- cgit v1.2.3 From 3f06cab75eb1203ae8f68535763cce456f52a895 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 29 Jul 2010 10:09:20 +0000 Subject: Fix #23073: glsl and 3d view background color didn't take color managment into account yet, should now be consistent with render. --- source/blender/editors/space_view3d/view3d_draw.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index a88ec9ead64..357b6e584e9 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1968,6 +1968,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, { Scene *sce; Base *base; + float backcol[3]; int bwinx, bwiny; glPushMatrix(); @@ -1987,7 +1988,11 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, /* set background color, fallback on the view background color */ if(scene->world) { - glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0); + if(scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr); + else + copy_v3_v3(backcol, &scene->world->horr); + glClearColor(backcol[0], backcol[1], backcol[2], 0.0); } else { UI_ThemeClearColor(TH_BACK); @@ -2205,6 +2210,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) Scene *sce; Base *base; Object *ob; + float backcol[3]; int retopo= 0, sculptparticle= 0; Object *obact = OBACT; char *grid_unit= NULL; @@ -2223,8 +2229,13 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } /* clear background */ - if((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) - glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0); + if((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) { + if(scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr); + else + copy_v3_v3(backcol, &scene->world->horr); + glClearColor(backcol[0], backcol[1], backcol[2], 0.0); + } else UI_ThemeClearColor(TH_BACK); -- cgit v1.2.3 From 365a4b4dcc56d447120c4edda79f185047322c4d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Jul 2010 11:47:00 +0000 Subject: bugfix [#21093] Alt-arrowkey 'Swap Strips' confused --- source/blender/editors/space_sequencer/sequencer_edit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 5d258ea0054..a55b2e77431 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2420,9 +2420,9 @@ void SEQUENCER_OT_previous_edit(wmOperatorType *ot) static void swap_sequence(Scene* scene, Sequence* seqa, Sequence* seqb) { int gap = seqb->startdisp - seqa->enddisp; - seqb->start = seqa->start; + seqb->start = (seqb->start - seqb->startdisp) + seqa->startdisp; calc_sequence(scene, seqb); - seqa->start = seqb->enddisp + gap; + seqa->start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap; calc_sequence(scene, seqa); } -- cgit v1.2.3 From ab7c879963fbfee436c03ff49849258c5b10d726 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Jul 2010 12:16:15 +0000 Subject: Fix for error while weight painting: RNA_boolean_get: OperatorStrokeElement.flip not found. flip was renamed to pen_flip but not updated everywhere. --- source/blender/editors/physics/particle_edit.c | 2 +- source/blender/editors/sculpt_paint/paint_vertex.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index f463da3f6a4..d491b1a9731 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3336,7 +3336,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) RNA_float_get_array(itemptr, "mouse", mousef); mouse[0] = mousef[0]; mouse[1] = mousef[1]; - flip= RNA_boolean_get(itemptr, "flip"); + flip= RNA_boolean_get(itemptr, "pen_flip"); if(bedit->first) { bedit->lastmouse[0]= mouse[0]; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 93555613b07..f7cc135fb75 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1445,7 +1445,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* load projection matrix */ mul_m4_m4m4(mat, ob->obmat, vc->rv3d->persmat); - flip = RNA_boolean_get(itemptr, "flip"); + flip = RNA_boolean_get(itemptr, "pen_flip"); pressure = RNA_float_get(itemptr, "pressure"); RNA_float_get_array(itemptr, "mouse", mval); mval[0]-= vc->ar->winrct.xmin; @@ -1860,7 +1860,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P float pressure, mval[2]; RNA_float_get_array(itemptr, "mouse", mval); - flip = RNA_boolean_get(itemptr, "flip"); + flip = RNA_boolean_get(itemptr, "pen_flip"); pressure = RNA_float_get(itemptr, "pressure"); view3d_operator_needs_opengl(C); -- cgit v1.2.3 From b1f53d98e4332cfa17b7e30fb8fa11feda5d826e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Jul 2010 22:34:46 +0000 Subject: patch [#23088] 2.5 Text Editor: Preserve indentation with spaces from Fabian Fricke (frigi) --- source/blender/editors/space_text/text_ops.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 25726bae84b..5638cb6daf5 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -902,15 +902,22 @@ void TEXT_OT_unindent(wmOperatorType *ot) static int line_break_exec(bContext *C, wmOperator *op) { + SpaceText *st= CTX_wm_space_text(C); Text *text= CTX_data_edit_text(C); - int a, curtab; + int a, curts; + int space = (text->flags & TXT_TABSTOSPACES) ? st->tabnumber : 1; - // double check tabs before splitting the line - curtab= setcurr_tab(text); + // double check tabs/spaces before splitting the line + curts= setcurr_tab_spaces(text, space); txt_split_curline(text); - for(a=0; a < curtab; a++) - txt_add_char(text, '\t'); + for(a=0; a < curts; a++) { + if (text->flags & TXT_TABSTOSPACES) { + txt_add_char(text, ' '); + } else { + txt_add_char(text, '\t'); + } + } if(text->curl) { if(text->curl->prev) -- cgit v1.2.3 From eec131899647cdf17c50553e265a925857f35cfe Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 30 Jul 2010 00:06:59 +0000 Subject: Preview commit in sculpt brushes broke resetting curves in other areas (rgb curves etc). Fixed by adding a 'slope' parameter to curvemap_reset() to mirror curve presets around Y axis. Also removed curve preset with 'random' icon, wasn't doing what it looked like it should, this was intended only for hue correct node anyway. --- source/blender/editors/interface/interface_templates.c | 4 ++-- source/blender/editors/sculpt_paint/paint_utils.c | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6bc81b7ab18..28d0e131ef2 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1747,7 +1747,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) switch(event) { case 0: /* reset */ - curvemap_reset(cuma, &cumap->clipr, cumap->preset); + curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); curvemapping_changed(cumap, 0); break; case 1: @@ -1827,7 +1827,7 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) cumap->preset = CURVE_PRESET_LINE; for(a=0; acm+a, &cumap->clipr, cumap->preset); + curvemap_reset(cumap->cm+a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); cumap->black[0]=cumap->black[1]=cumap->black[2]= 0.0f; cumap->white[0]=cumap->white[1]=cumap->white[2]= 1.0f; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index ecce64f2d10..30b3ddf6e8d 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -216,7 +216,6 @@ void BRUSH_OT_curve_preset(wmOperatorType *ot) {CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""}, {CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""}, {CURVE_PRESET_MAX, "MAX", 0, "Max", ""}, - {CURVE_PRESET_MID9, "MID9", 0, "Mid9", ""}, {CURVE_PRESET_LINE, "LINE", 0, "Line", ""}, {CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""}, {CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""}, -- cgit v1.2.3 From 9a9e04edfba277e6315be8a4a400fbda2b1423d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Jul 2010 00:20:05 +0000 Subject: patch [#23060] ColorRamp python access functions from Dan Eicher (dna) elem = color_ramp.elements.new(position=0.3) color_ramp.elements.remove(elem) - Modified the patch to make generic functions for adding and removing (inline code was in 3 different places) --- .../blender/editors/interface/interface_handlers.c | 20 +----- .../editors/interface/interface_templates.c | 80 +++------------------- 2 files changed, 13 insertions(+), 87 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 0f8f84b94dc..f617cc4ae8d 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3251,24 +3251,8 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle if(event->ctrl) { /* insert new key on mouse location */ - if(coba->tot < MAXCOLORBAND-1) { - float pos= ((float)(mx - but->x1))/(but->x2-but->x1); - float col[4]; - - do_colorband(coba, pos, col); /* executes it */ - - coba->tot++; - coba->cur= coba->tot-1; - - coba->data[coba->cur].r= col[0]; - coba->data[coba->cur].g= col[1]; - coba->data[coba->cur].b= col[2]; - coba->data[coba->cur].a= col[3]; - coba->data[coba->cur].pos= pos; - - ui_colorband_update(coba); - } - + float pos= ((float)(mx - but->x1))/(but->x2-but->x1); + colorband_element_add(coba, pos); button_activate_state(C, but, BUTTON_STATE_EXIT); } else { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 28d0e131ef2..01d2ad29b0e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1302,71 +1302,20 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *arg_unused) #define B_BANDCOL 1 -static int vergcband(const void *a1, const void *a2) -{ - const CBData *x1=a1, *x2=a2; - - if( x1->pos > x2->pos ) return 1; - else if( x1->pos < x2->pos) return -1; - return 0; -} - -static void colorband_pos_cb(bContext *C, void *cb_v, void *coba_v) -{ - ColorBand *coba= coba_v; - int a; - - if(coba->tot<2) return; - - for(a=0; atot; a++) coba->data[a].cur= a; - qsort(coba->data, coba->tot, sizeof(CBData), vergcband); - for(a=0; atot; a++) { - if(coba->data[a].cur==coba->cur) { - coba->cur= a; - break; - } - } - - rna_update_cb(C, cb_v, NULL); -} - static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) { ColorBand *coba= coba_v; + float pos= 0.5f; - if(coba->tot > 0) { - CBData *xnew, *x1, *x2; - float col[4]; - - xnew= &coba->data[coba->tot]; - - if(coba->tot > 1) { - if(coba->cur > 0) { - x1= &coba->data[coba->cur-1]; - x2= &coba->data[coba->cur]; - } - else { - x1= &coba->data[coba->cur]; - x2= &coba->data[coba->cur+1]; - } - - xnew->pos = x1->pos + ((x2->pos - x1->pos) / 2); - } - - do_colorband(coba, xnew->pos, col); - - xnew->r= col[0]; - xnew->g= col[1]; - xnew->b= col[2]; - xnew->a= col[3]; + if(coba->tot > 1) { + if(coba->cur > 0) pos= (coba->data[coba->cur-1].pos + coba->data[coba->cur].pos) * 0.5f; + else pos= (coba->data[coba->cur+1].pos + coba->data[coba->cur].pos) * 0.5f; } - if(coba->tot < MAXCOLORBAND-1) coba->tot++; - coba->cur= coba->tot-1; - - colorband_pos_cb(C, cb_v, coba_v); - - ED_undo_push(C, "Add colorband"); + if(colorband_element_add(coba, pos)) { + rna_update_cb(C, cb_v, NULL); + ED_undo_push(C, "Add colorband"); + } } static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v) @@ -1374,17 +1323,10 @@ static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v) ColorBand *coba= coba_v; int a; - if(coba->tot<2) return; - - for(a=coba->cur; atot; a++) { - coba->data[a]= coba->data[a+1]; + if(colorband_element_remove(coba, coba->cur)) { + ED_undo_push(C, "Delete colorband"); + rna_update_cb(C, cb_v, NULL); } - if(coba->cur) coba->cur--; - coba->tot--; - - ED_undo_push(C, "Delete colorband"); - - rna_update_cb(C, cb_v, NULL); } static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v) -- cgit v1.2.3 From 520d12e13e2143cfd54a7696df94cd87e7a51e39 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Jul 2010 01:13:07 +0000 Subject: 3 duplicate functions: bone_flip_name() object_flip_name() flip_side_name() removed object_flip_name() & bone_flip_name(), use flip_side_name() --- source/blender/editors/armature/editarmature.c | 15 ++- source/blender/editors/armature/poseobject.c | 20 ++-- .../editors/interface/interface_templates.c | 1 - source/blender/editors/object/object_select.c | 120 +-------------------- source/blender/editors/sculpt_paint/paint_vertex.c | 12 +-- 5 files changed, 24 insertions(+), 144 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 5386dbc8b98..7db20fea6eb 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1752,9 +1752,8 @@ EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) if (ebo == NULL) return NULL; - - BLI_strncpy(name, ebo->name, sizeof(name)); - bone_flip_name(name, 0); // 0 = don't strip off number extensions + + flip_side_name(name, ebo->name, FALSE); for (eboflip= edbo->first; eboflip; eboflip=eboflip->next) { if (ebo != eboflip) { @@ -4741,11 +4740,10 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m /* find flipped group */ if (dgroup && mirror) { char name[32]; - - BLI_strncpy(name, dgroup->name, 32); + // 0 = don't strip off number extensions - bone_flip_name(name, 0); - + flip_side_name(name, dgroup->name, FALSE); + for (curdg = ob->defbase.first; curdg; curdg=curdg->next) { if (!strcmp(curdg->name, name)) break; @@ -5540,8 +5538,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *op) /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { - BLI_strncpy(newname, ebone->name, sizeof(newname)); - bone_flip_name(newname, 1); // 1 = do strip off number extensions + flip_side_name(newname, ebone->name, TRUE); // 1 = do strip off number extensions ED_armature_bone_rename(arm, ebone->name, newname); } CTX_DATA_END; diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 6b71ed1ca7a..633b0b48a38 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -897,7 +897,6 @@ static int pose_paste_exec (bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); bPoseChannel *chan, *pchan; - char name[32]; int flip= RNA_boolean_get(op->ptr, "flipped"); /* sanity checks */ @@ -913,10 +912,12 @@ static int pose_paste_exec (bContext *C, wmOperator *op) for (chan= g_posebuf->chanbase.first; chan; chan=chan->next) { if (chan->flag & POSE_KEY) { /* get the name - if flipping, we must flip this first */ - BLI_strncpy(name, chan->name, sizeof(name)); + char name[32]; if (flip) - bone_flip_name(name, 0); /* 0 = don't strip off number extensions */ - + flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */ + else + BLI_strncpy(name, chan->name, sizeof(name)); + /* only copy when channel exists, poses are not meant to add random channels to anymore */ pchan= get_pose_channel(ob->pose, name); @@ -1431,7 +1432,6 @@ static int pose_flip_names_exec (bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); bArmature *arm; - char newname[32]; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) @@ -1441,8 +1441,8 @@ static int pose_flip_names_exec (bContext *C, wmOperator *op) /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) { - BLI_strncpy(newname, pchan->name, sizeof(newname)); - bone_flip_name(newname, 1); // 1 = do strip off number extensions + char newname[32]; + flip_side_name(newname, pchan->name, TRUE); ED_armature_bone_rename(arm, pchan->name, newname); } CTX_DATA_END; @@ -1546,10 +1546,8 @@ void pose_activate_flipped_bone(Scene *scene) if(arm->act_bone) { char name[32]; - - BLI_strncpy(name, arm->act_bone->name, 32); - bone_flip_name(name, 1); // 0 = do not strip off number extensions - + flip_side_name(name, arm->act_bone->name, TRUE); + pchanf= get_pose_channel(ob->pose, name); if(pchanf && pchanf->bone != arm->act_bone) { arm->act_bone->flag &= ~BONE_SELECTED; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 01d2ad29b0e..488258d2a06 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1321,7 +1321,6 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v) { ColorBand *coba= coba_v; - int a; if(colorband_element_remove(coba, coba->cur)) { ED_undo_push(C, "Delete colorband"); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 7eedefc358b..3c86c135914 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -53,6 +53,7 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_utildefines.h" +#include "BKE_deform.h" #include "WM_api.h" #include "WM_types.h" @@ -824,130 +825,17 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) } /**************************** Select Mirror ****************************/ - -/* finds the best possible flipped name. For renaming; check for unique names afterwards */ -/* if strip_number: removes number extensions */ -void object_flip_name (char *name) -{ - int len; - char prefix[128]={""}; /* The part before the facing */ - char suffix[128]={""}; /* The part after the facing */ - char replace[128]={""}; /* The replacement string */ - char number[128]={""}; /* The number extension string */ - char *index=NULL; - - len= strlen(name); - if(len<3) return; // we don't do names like .R or .L - - /* We first check the case with a .### extension, let's find the last period */ - if(isdigit(name[len-1])) { - index= strrchr(name, '.'); // last occurrence - if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! - strcpy(number, index); - *index= 0; - len= strlen(name); - } - } - - strcpy (prefix, name); - -#define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_') - - /* first case; separator . - _ with extensions r R l L */ - if( IS_SEPARATOR(name[len-2]) ) { - switch(name[len-1]) { - case 'l': - prefix[len-1]= 0; - strcpy(replace, "r"); - break; - case 'r': - prefix[len-1]= 0; - strcpy(replace, "l"); - break; - case 'L': - prefix[len-1]= 0; - strcpy(replace, "R"); - break; - case 'R': - prefix[len-1]= 0; - strcpy(replace, "L"); - break; - } - } - /* case; beginning with r R l L , with separator after it */ - else if( IS_SEPARATOR(name[1]) ) { - switch(name[0]) { - case 'l': - strcpy(replace, "r"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'r': - strcpy(replace, "l"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'L': - strcpy(replace, "R"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'R': - strcpy(replace, "L"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - } - } - else if(len > 5) { - /* hrms, why test for a separator? lets do the rule 'ultimate left or right' */ - index = BLI_strcasestr(prefix, "right"); - if (index==prefix || index==prefix+len-5) { - if(index[0]=='r') - strcpy (replace, "left"); - else { - if(index[1]=='I') - strcpy (replace, "LEFT"); - else - strcpy (replace, "Left"); - } - *index= 0; - strcpy (suffix, index+5); - } - else { - index = BLI_strcasestr(prefix, "left"); - if (index==prefix || index==prefix+len-4) { - if(index[0]=='l') - strcpy (replace, "right"); - else { - if(index[1]=='E') - strcpy (replace, "RIGHT"); - else - strcpy (replace, "Right"); - } - *index= 0; - strcpy (suffix, index+4); - } - } - } - -#undef IS_SEPARATOR - - sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); -} - static int object_select_mirror_exec(bContext *C, wmOperator *op) { - char tmpname[32]; short extend; extend= RNA_boolean_get(op->ptr, "extend"); CTX_DATA_BEGIN(C, Base*, primbase, selected_bases) { - strcpy(tmpname, primbase->object->id.name+2); - object_flip_name(tmpname); - + char tmpname[32]; + flip_side_name(tmpname, primbase->object->id.name+2, TRUE); + CTX_DATA_BEGIN(C, Base*, secbase, visible_bases) { if(!strcmp(secbase->object->id.name+2, tmpname)) { ED_base_object_select(secbase, BA_SELECT); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index f7cc135fb75..8832c7c857f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -386,9 +386,8 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) int actdef= 0; char name[32]; - BLI_strncpy(name, defgroup->name, 32); - bone_flip_name(name, 0); /* 0 = don't strip off number extensions */ - + flip_side_name(name, defgroup->name, FALSE); + for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++) if (!strcmp(curdef->name, name)) break; @@ -1390,10 +1389,9 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event) bDeformGroup *curdef; int actdef= 0; char name[32]; - - BLI_strncpy(name, defgroup->name, 32); - bone_flip_name(name, 0); /* 0 = don't strip off number extensions */ - + + flip_side_name(name, defgroup->name, FALSE); + for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++) if (!strcmp(curdef->name, name)) break; -- cgit v1.2.3 From 477c924f50c4dffcbf358fb8de63ec28dc35cbf1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Jul 2010 08:43:22 +0000 Subject: bugfix [#20038] Vertex path selection not working in Vertex/Face mode - disable this tool if edge mode isnt enabled using its poll function. Also fixed a bug where it would de-select the last active edge. - made view3d grid drawing use GL_LINES's for less context switching. --- source/blender/editors/mesh/editmesh_mods.c | 26 +++++++++++++--- source/blender/editors/space_view3d/view3d_draw.c | 37 ++++++++++++++--------- 2 files changed, 44 insertions(+), 19 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 4bea6488adb..f952820c1f0 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -2150,7 +2150,7 @@ static void mouse_mesh_shortest_path(bContext *C, short mval[2]) if(ese && ese->type == EDITEDGE) { eed_act = (EditEdge*)ese->data; if (eed_act != eed) { - if (edgetag_shortest_path(vc.scene, em, eed_act, eed)) { + if (edgetag_shortest_path(vc.scene, em, eed_act, eed)) { /* <- this is where the magic happens */ EM_remove_selection(em, eed_act, EDITEDGE); path = 1; } @@ -2163,13 +2163,19 @@ static void mouse_mesh_shortest_path(bContext *C, short mval[2]) } /* even if this is selected it may not be in the selection list */ - if(edgetag_context_check(vc.scene, eed)==EDGE_MODE_SELECT) + if(edgetag_context_check(vc.scene, eed)==0) { EM_remove_selection(em, eed, EDITEDGE); + } else { /* other modes need to keep the last edge tagged */ - if(eed_act) - EM_select_edge(eed_act, 0); + if(eed_act) { + if(vc.scene->toolsettings->edge_mode!=EDGE_MODE_SELECT) { + /* for non-select modes, always de-select the previous active edge */ + EM_select_edge(eed_act, 0); + } + } + /* set the new edge active */ EM_select_edge(eed, 1); EM_store_selection(em, eed, EDITEDGE); } @@ -2208,6 +2214,16 @@ static int mesh_shortest_path_select_invoke(bContext *C, wmOperator *op, wmEvent return OPERATOR_FINISHED; } + +static int mesh_shortest_path_select_poll(bContext *C) +{ + if(ED_operator_editmesh_view3d(C)) { + Object *obedit= CTX_data_edit_object(C); + EditMesh *em= BKE_mesh_get_editmesh(obedit->data); + return (em->selectmode & SCE_SELECT_EDGE); + } + return 0; +} void MESH_OT_select_shortest_path(wmOperatorType *ot) { @@ -2218,7 +2234,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) /* api callbacks */ ot->invoke= mesh_shortest_path_select_invoke; - ot->poll= ED_operator_editmesh_view3d; + ot->poll= mesh_shortest_path_select_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 357b6e584e9..8408152d23c 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -211,28 +211,37 @@ int view3d_test_clipping(RegionView3D *rv3d, float *vec, int local) static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, float dx) -{ - float fx, fy; - +{ + float v1[2], v2[2]; + x+= (wx); y+= (wy); - fx= x/dx; - fx= x-dx*floor(fx); + + v1[1]= 0.0f; + v2[1]= (float)ar->winy; + + v1[0] = v2[0] = x-dx*floor(x/dx); - while(fx< ar->winx) { - fdrawline(fx, 0.0, fx, (float)ar->winy); - fx+= dx; + glBegin(GL_LINES); + + while(v1[0] < ar->winx) { + glVertex2fv(v1); + glVertex2fv(v2); + v1[0] = v2[0] = v1[0] + dx; } - fy= y/dx; - fy= y-dx*floor(fy); - + v1[0]= 0.0f; + v2[0]= (float)ar->winx; - while(fy< ar->winy) { - fdrawline(0.0, fy, (float)ar->winx, fy); - fy+= dx; + v1[1]= v2[1]= y-dx*floor(y/dx); + + while(v1[1] < ar->winy) { + glVertex2fv(v1); + glVertex2fv(v2); + v1[1] = v2[1] = v1[1] + dx; } + glEnd(); } #define GRID_MIN_PX 6.0f -- cgit v1.2.3 From 3b9b4f76054e55465c3c0ddbaed3f09618860b58 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 30 Jul 2010 10:44:00 +0000 Subject: Fix #23103: * missing glsl update when changing color management setting * disable glsl lamps only when disabling them for render --- source/blender/editors/render/render_shading.c | 18 ++++++++++++++++++ source/blender/editors/space_view3d/view3d_draw.c | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 6e8c3b721d0..9fd0074b9f1 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -209,6 +209,21 @@ static void image_changed(Main *bmain, Image *ima) texture_changed(bmain, tex); } +static void scene_changed(Main *bmain, Scene *sce) +{ + Object *ob; + Material *ma; + + /* glsl */ + for(ob=bmain->object.first; ob; ob=ob->id.next) + if(ob->gpulamp.first) + GPU_lamp_free(ob); + + for(ma=bmain->mat.first; ma; ma=ma->id.next) + if(ma->gpumaterial.first) + GPU_material_free(ma); +} + void ED_render_id_flush_update(Main *bmain, ID *id) { if(!id) @@ -230,6 +245,9 @@ void ED_render_id_flush_update(Main *bmain, ID *id) case ID_IM: image_changed(bmain, (Image*)id); break; + case ID_SCE: + scene_changed(bmain, (Scene*)id); + break; default: break; } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 8408152d23c..69375674d94 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1807,7 +1807,7 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object lamp = GPU_lamp_from_blender(scene, ob, par); if(lamp) { - GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_VIEW), obmat); + GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), obmat); GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy); if((ob->lay & v3d->lay) && GPU_lamp_has_shadow_buffer(lamp)) { -- cgit v1.2.3 From 0972d05b4b065213e95e79e9ad7ac4bf63e500e3 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 30 Jul 2010 15:44:26 +0000 Subject: Logic Editor: *Removed the old header menu code, replacing with Python menus. --- source/blender/editors/space_logic/logic_header.c | 120 ---------------------- source/blender/editors/space_logic/logic_intern.h | 3 - source/blender/editors/space_logic/space_logic.c | 12 +-- 3 files changed, 1 insertion(+), 134 deletions(-) delete mode 100644 source/blender/editors/space_logic/logic_header.c (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_logic/logic_header.c b/source/blender/editors/space_logic/logic_header.c deleted file mode 100644 index 3e38eb815fb..00000000000 --- a/source/blender/editors/space_logic/logic_header.c +++ /dev/null @@ -1,120 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2009 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include -#include - - -#include "MEM_guardedalloc.h" - -#include "BLI_blenlib.h" - -#include "BKE_context.h" -#include "BKE_screen.h" -#include "BKE_main.h" - -#include "ED_screen.h" -#include "ED_types.h" -#include "ED_util.h" - - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "UI_interface.h" -#include "UI_resources.h" -#include "UI_view2d.h" - -#include "logic_intern.h" - -/* ************************ header area region *********************** */ - - -static void do_logic_buttons(bContext *C, void *arg, int event) -{ -// SpaceLogic *slogic= CTX_wm_space_logic(C); -} - -static uiBlock *logic_addmenu(bContext *C, ARegion *ar, void *arg_unused) -{ -// SpaceLogic *slogic= CTX_wm_space_logic(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "logic_addmenu", UI_EMBOSSP); -// uiBlockSetButmFunc(block, do_logic_addmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiTextBoundsBlock(block, 50); - uiBlockSetDirection(block, UI_TOP); - uiEndBlock(C, block); - - return block; -} - -void logic_header_buttons(const bContext *C, ARegion *ar) -{ - ScrArea *sa= CTX_wm_area(C); -// SpaceLogic *slogic= CTX_wm_space_logic(C); - uiBlock *block; - short xco, yco= 3; - - block= uiBeginBlock(C, ar, "header logic", UI_EMBOSS); - uiBlockSetHandleFunc(block, do_logic_buttons, NULL); - - xco= ED_area_header_standardbuttons(C, block, yco); - - if((sa->flag & HEADER_NO_PULLDOWN)==0) { - int xmax; - - xmax= GetButStringLength("View"); - uiDefPulldownBut(block, logic_addmenu, NULL, - "View", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Select"); - uiDefPulldownBut(block, logic_addmenu, NULL, - "Select", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Add"); - uiDefPulldownBut(block, logic_addmenu, NULL, - "Add", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - - uiBlockSetEmboss(block, UI_EMBOSS); - - UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); - - uiEndBlock(C, block); - uiDrawBlock(C, block); -} - - diff --git a/source/blender/editors/space_logic/logic_intern.h b/source/blender/editors/space_logic/logic_intern.h index 3b2b6497cdc..0c30aa711f1 100644 --- a/source/blender/editors/space_logic/logic_intern.h +++ b/source/blender/editors/space_logic/logic_intern.h @@ -42,9 +42,6 @@ struct Scene; /* space_logic.c */ struct ARegion *logic_has_buttons_region(struct ScrArea *sa); -/* logic_header.c */ -void logic_header_buttons(const struct bContext *C, struct ARegion *ar); - /* logic_ops.c */ /* logic_buttons.c */ diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index ed3d956ce01..3f11c3e6bae 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -296,17 +296,7 @@ static void logic_header_area_init(wmWindowManager *wm, ARegion *ar) static void logic_header_area_draw(const bContext *C, ARegion *ar) { - /* clear */ - UI_ThemeClearColor(ED_screen_area_active(C)?TH_HEADER:TH_HEADERDESEL); - glClear(GL_COLOR_BUFFER_BIT); - - /* set view2d view matrix for scrolling (without scrollers) */ - UI_view2d_view_ortho(C, &ar->v2d); - - logic_header_buttons(C, ar); - - /* restore view matrix? */ - UI_view2d_view_restore(C); + ED_region_header(C, ar); } /**************************** spacetype *****************************/ -- cgit v1.2.3 From e4a16c8010f8bdf4bed4e2661929cd0858649d25 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 30 Jul 2010 16:15:56 +0000 Subject: Properties Window: * Deleted space_buttons.py file as I doubt that these buttons will be done in python. File was not used anyway. * Deleted some ifdef checks from space_buttons.c for the py header. --- source/blender/editors/space_buttons/space_buttons.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index b002bec2443..a775a0b6e6a 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -191,24 +191,14 @@ void buttons_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0); } -//#define PY_HEADER /* add handlers, stuff you only do once or on area/region changes */ static void buttons_header_area_init(wmWindowManager *wm, ARegion *ar) { -#ifdef PY_HEADER - ED_region_header_init(ar); -#else UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); -#endif } static void buttons_header_area_draw(const bContext *C, ARegion *ar) { -#ifdef PY_HEADER - ED_region_header(C, ar); -#else - - /* clear */ UI_ThemeClearColor(ED_screen_area_active(C)?TH_HEADER:TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); @@ -217,7 +207,6 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(C, &ar->v2d); buttons_header_buttons(C, ar); -#endif /* restore view matrix? */ UI_view2d_view_restore(C); -- cgit v1.2.3 From 1280b6f9024de7c7a3d67cd2dfb80820164bc802 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 31 Jul 2010 01:06:08 +0000 Subject: - add back prefix for ID lists (LF) for linked and fake user for search fields. - remove debug print for left/right name flipping & commented test from the sequencer. --- .../blender/editors/interface/interface_layout.c | 24 ++++++++++++++-------- .../editors/interface/interface_templates.c | 5 ++++- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index c2bcc673c1e..b6f4dcc0356 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1111,13 +1111,19 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui if(itemptr.data == but->rnapoin.id.data) continue; - if(itemptr.type && RNA_struct_is_ID(itemptr.type)) - iconid= ui_id_icon_get((bContext*)C, itemptr.data, 1); - else + if(itemptr.type && RNA_struct_is_ID(itemptr.type)) { + ID *id= itemptr.data; + char name_ui[32]; + + name_uiprefix_id(name_ui, id); + name= BLI_strdup(name_ui); + iconid= ui_id_icon_get((bContext*)C, id, 1); + } + else { + name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); iconid = 0; - - name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); - + } + if(name) { if(BLI_strcasestr(name, str)) { cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch"); @@ -1126,9 +1132,9 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui cis->iconid = iconid; BLI_addtail(items_list, cis); } - MEM_freeN(name); - } - + MEM_freeN(name); + } + i++; } RNA_PROP_END; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 488258d2a06..1b600a26001 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -218,9 +218,12 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea continue; if(BLI_strcasestr(id->name+2, str)) { + char name_ui[32]; + name_uiprefix_id(name_ui, id); + iconid= ui_id_icon_get((bContext*)C, id, 1); - if(!uiSearchItemAdd(items, id->name+2, id, iconid)) + if(!uiSearchItemAdd(items, name_ui, id, iconid)) break; } } -- cgit v1.2.3 From cc673669c749d56f4b3078cd831c2a0dd88bf6c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 31 Jul 2010 10:58:10 +0000 Subject: use more BLI math funcs (no functional changes) --- source/blender/editors/armature/editarmature.c | 16 +++---- source/blender/editors/object/object_transform.c | 53 +++++++-------------- source/blender/editors/space_view3d/drawobject.c | 56 ++++++++--------------- source/blender/editors/space_view3d/view3d_snap.c | 17 ++----- source/blender/editors/transform/transform.c | 12 ++--- 5 files changed, 53 insertions(+), 101 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 7db20fea6eb..989c5bdc0ba 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -428,7 +428,6 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) bArmature *arm= ob->data; float cent[3] = {0.0f, 0.0f, 0.0f}; float min[3], max[3]; - float omat[3][3]; /* Put the armature into editmode */ if(ob!=obedit) @@ -437,7 +436,7 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) /* Find the centerpoint */ if (centermode == 2) { float *fp= give_cursor(scene, v3d); - VECCOPY(cent, fp); + copy_v3_v3(cent, fp); invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); } @@ -448,10 +447,8 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) DO_MINMAX(ebone->head, min, max); DO_MINMAX(ebone->tail, min, max); } - - cent[0]= (min[0] + max[0]) / 2.0f; - cent[1]= (min[1] + max[1]) / 2.0f; - cent[2]= (min[2] + max[2]) / 2.0f; + + mid_v3_v3v3(cent, min, max); } /* Do the adjustments */ @@ -465,13 +462,12 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) /* Adjust object location for new centerpoint */ if(centermode && obedit==NULL) { - copy_m3_m4(omat, ob->obmat); - - mul_m3_v3(omat, cent); + mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */ add_v3_v3(ob->loc, cent); } - else + else { ED_armature_edit_free(ob); + } } /* ---------------------- */ diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index cd66b9ab2ba..bc8a2a2fc60 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -182,7 +182,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,ob->rotAxis, ob->rotAngle); } else { - VECCOPY(oldeul, ob->rot); + copy_v3_v3(oldeul, ob->rot); } eul[0]= eul[1]= eul[2]= 0.0f; @@ -706,8 +706,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; + View3D *v3d= CTX_wm_view3d(C); Object *obedit= CTX_data_edit_object(C); Object *tob; Mesh *me, *tme; @@ -716,7 +715,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) BPoint *bp; */ Nurb *nu, *nu1; EditVert *eve; - float cent[3], centn[3], min[3], max[3], omat[3][3]; + float cent[3], centn[3], min[3], max[3]; int a, total= 0; int centermode = RNA_enum_get(op->ptr, "type"); @@ -731,8 +730,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (obedit && centermode > 0) { BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode"); return OPERATOR_CANCELLED; - } - cent[0]= cent[1]= cent[2]= 0.0; + } + zero_v3(cent); if(obedit) { @@ -745,7 +744,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) for(eve= em->verts.first; eve; eve= eve->next) { if(v3d->around==V3D_CENTROID) { total++; - VECADD(cent, cent, eve->co); + add_v3_v3(cent, eve->co); } else { DO_MINMAX(eve->co, min, max); @@ -756,9 +755,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_v3_fl(cent, 1.0f/(float)total); } else { - cent[0]= (min[0]+max[0])/2.0f; - cent[1]= (min[1]+max[1])/2.0f; - cent[2]= (min[2]+max[2])/2.0f; + mid_v3_v3v3(cent, min, max); } for(eve= em->verts.first; eve; eve= eve->next) { @@ -792,7 +789,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tot_lib_error++; } else { if(centermode==2) { - VECCOPY(cent, give_cursor(scene, v3d)); + copy_v3_v3(cent, give_cursor(scene, v3d)); invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); } else { @@ -801,10 +798,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) for(a=0; atotvert; a++, mvert++) { DO_MINMAX(mvert->co, min, max); } - - cent[0]= (min[0]+max[0])/2.0f; - cent[1]= (min[1]+max[1])/2.0f; - cent[2]= (min[2]+max[2])/2.0f; + + mid_v3_v3v3(cent, min, max); } mvert= me->mvert; @@ -827,13 +822,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) me->id.flag |= LIB_DOIT; if(centermode) { - copy_m3_m4(omat, ob->obmat); - copy_v3_v3(centn, cent); - mul_m3_v3(omat, centn); - ob->loc[0]+= centn[0]; - ob->loc[1]+= centn[1]; - ob->loc[2]+= centn[2]; + mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */ + add_v3_v3(ob->loc, centn); where_is_object(scene, ob); ignore_parent_tx(bmain, scene, ob); @@ -848,12 +839,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) ob_other->flag |= OB_DONE; ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA; - copy_m3_m4(omat, ob_other->obmat); copy_v3_v3(centn, cent); - mul_m3_v3(omat, centn); - ob_other->loc[0]+= centn[0]; - ob_other->loc[1]+= centn[1]; - ob_other->loc[2]+= centn[2]; + mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */ + add_v3_v3(ob_other->loc, centn); where_is_object(scene, ob_other); ignore_parent_tx(bmain, scene, ob_other); @@ -920,9 +908,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) nu= nu->next; } - cent[0]= (min[0]+max[0])/2.0f; - cent[1]= (min[1]+max[1])/2.0f; - cent[2]= (min[2]+max[2])/2.0f; + mid_v3_v3v3(cent, min, max); } nu= nu1; @@ -944,13 +930,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } if(centermode && obedit==NULL) { - copy_m3_m4(omat, ob->obmat); - - mul_m3_v3(omat, cent); - ob->loc[0]+= cent[0]; - ob->loc[1]+= cent[1]; - ob->loc[2]+= cent[2]; - + mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */ + add_v3_v3(ob->loc, cent); where_is_object(scene, ob); ignore_parent_tx(bmain, scene, ob); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5bb1ea2cc9f..02a8709a1ac 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -446,11 +446,11 @@ void drawaxes(float size, int flag, char drawtype) for (axis=0; axis<4; axis++) { if (axis % 2 == 1) { - v2[0] *= -1; - v3[1] *= -1; + v2[0] = -v2[0]; + v3[1] = -v3[1]; } else { - v2[1] *= -1; - v3[0] *= -1; + v2[1] = -v2[1]; + v3[0] = -v3[0]; } glVertex3fv(v1); @@ -513,12 +513,10 @@ void drawcircball(int mode, float *cent, float rad, float tmat[][4]) { float vec[3], vx[3], vy[3]; int a, tot=32; - - VECCOPY(vx, tmat[0]); - VECCOPY(vy, tmat[1]); - mul_v3_fl(vx, rad); - mul_v3_fl(vy, rad); - + + mul_v3_v3fl(vx, tmat[0], rad); + mul_v3_v3fl(vy, tmat[1], rad); + glBegin(mode); for(a=0; aclipsta*lavec[0]; - sta[1]= mat[3][1]+ la->clipsta*lavec[1]; - sta[2]= mat[3][2]+ la->clipsta*lavec[2]; - - end[0]= mat[3][0]+ la->clipend*lavec[0]; - end[1]= mat[3][1]+ la->clipend*lavec[1]; - end[2]= mat[3][2]+ la->clipend*lavec[2]; - + madd_v3_v3v3fl(sta, mat[3], lavec, la->clipsta); + madd_v3_v3v3fl(end, mat[3], lavec, la->clipend); glBegin(GL_LINE_STRIP); glVertex3fv(sta); @@ -820,10 +812,7 @@ static void spotvolume(float *lvec, float *vvec, float inp) quat_to_mat3(mat1,q); /* rotate lamp vector now over acos(inp) degrees */ - - vvec[0] = lvec[0] ; - vvec[1] = lvec[1] ; - vvec[2] = lvec[2] ; + copy_v3_v3(vvec, lvec); unit_m3(mat2); co = inp; @@ -948,7 +937,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } /* Inner Circle */ - VECCOPY(vec, ob->obmat[3]); + copy_v3_v3(vec, ob->obmat[3]); glEnable(GL_BLEND); drawcircball(GL_LINE_LOOP, vec, lampsize, imat); glDisable(GL_BLEND); @@ -987,10 +976,8 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, vec_rot_to_mat3( mat,imat[2], M_PI/4.0f); /* vectors */ - VECCOPY(v1, imat[0]); - mul_v3_fl(v1, circrad*1.2f); - VECCOPY(v2, imat[0]); - mul_v3_fl(v2, circrad*2.5f); + mul_v3_v3fl(v1, imat[0], circrad * 1.2f); + mul_v3_v3fl(v2, imat[0], circrad * 2.5f); /* center */ glTranslatef(vec[0], vec[1], vec[2]); @@ -1018,7 +1005,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } glPopMatrix(); /* back in object space */ - vec[0]= vec[1]= vec[2]= 0.0f; + zero_v3(vec); if ((la->type==LA_SPOT) || (la->type==LA_YF_PHOTON)) { lvec[0]=lvec[1]= 0.0; @@ -1110,7 +1097,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* draw the hemisphere curves */ short axis, steps, dir; float outdist, zdist, mul; - vec[0]=vec[1]=vec[2]= 0.0; + zero_v3(vec); outdist = 0.14; mul = 1.4; dir = 1; setlinestyle(4); @@ -5246,8 +5233,8 @@ void get_local_bounds(Object *ob, float *center, float *size) BoundBox *bb= object_get_boundbox(ob); if(bb==NULL) { - center[0]= center[1]= center[2]= 0.0; - VECCOPY(size, ob->size); + zero_v3(center); + copy_v3_v3(size, ob->size); } else { size[0]= 0.5*fabs(bb->vec[0][0] - bb->vec[4][0]); @@ -5506,9 +5493,7 @@ void drawRBpivot(bRigidBodyJointConstraint *data) dir[axis] = 1.f; glBegin(GL_LINES); mul_m4_v3(mat,dir); - v[0] += dir[0]; - v[1] += dir[1]; - v[2] += dir[2]; + add_v3_v3(v, dir); glVertex3fv(v1); glVertex3fv(v); glEnd(); @@ -6154,9 +6139,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(dtflag2 & V3D_RENDER_OVERRIDE)==0) { if((ob->gameflag & OB_DYNAMIC) || ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) { - float imat[4][4], vec[3]; + float imat[4][4], vec[3]= {0.0f, 0.0f, 0.0f}; - vec[0]= vec[1]= vec[2]= 0.0; invert_m4_m4(imat, rv3d->viewmatob); setlinestyle(2); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 160306ef300..9928ba1983e 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -365,7 +365,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) while(ml) { if(ml->flag & SELECT) { tv->loc= &ml->x; - VECCOPY(tv->oldloc, tv->loc); + copy_v3_v3(tv->oldloc, tv->loc); tv->val= &(ml->rad); tv->oldval= ml->rad; tv->flag= 1; @@ -387,7 +387,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) while(a--) { if((mode & 1) || (bp->f1 & SELECT)) { if(bp->hide==0) { - VECCOPY(tv->oldloc, bp->vec); + copy_v3_v3(tv->oldloc, bp->vec); tv->loc= bp->vec; tv->flag= bp->f1 & SELECT; tv++; @@ -403,23 +403,16 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) total= 0.0; for(a=0; aflag & SELECT) { - centroid[0]+= tv->oldloc[0]; - centroid[1]+= tv->oldloc[1]; - centroid[2]+= tv->oldloc[2]; + add_v3_v3(centroid, tv->oldloc); total+= 1.0; DO_MINMAX(tv->oldloc, min, max); } } if(total!=0.0) { - centroid[0]/= total; - centroid[1]/= total; - centroid[2]/= total; + mul_v3_fl(centroid, 1.0f/total); } - center[0]= (min[0]+max[0])/2.0; - center[1]= (min[1]+max[1])/2.0; - center[2]= (min[2]+max[2])/2.0; - + mid_v3_v3v3(center, min, max); } /* *********************** operators ******************** */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 86fdb81e0d9..9743a4ef0f5 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2171,21 +2171,19 @@ void initWarp(TransInfo *t) /* we need min/max in view space */ for(i = 0; i < t->total; i++) { float center[3]; - VECCOPY(center, t->data[i].center); + copy_v3_v3(center, t->data[i].center); mul_m3_v3(t->data[i].mtx, center); mul_m4_v3(t->viewmat, center); sub_v3_v3(center, t->viewmat[3]); if (i) minmax_v3_v3v3(min, max, center); else { - VECCOPY(max, center); - VECCOPY(min, center); + copy_v3_v3(max, center); + copy_v3_v3(min, center); } } - - t->center[0]= (min[0]+max[0])/2.0f; - t->center[1]= (min[1]+max[1])/2.0f; - t->center[2]= (min[2]+max[2])/2.0f; + + mid_v3_v3v3(t->center, min, max); if (max[0] == min[0]) max[0] += 0.1; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */ t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */ -- cgit v1.2.3 From 327b4d588bf87c2f3aa5dc3891a75ade7f55d737 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sat, 31 Jul 2010 19:26:21 +0000 Subject: Separate proportional edit setting between edit and object mode. They are now used and toggled independently. --- source/blender/editors/curve/curve_ops.c | 2 +- source/blender/editors/include/ED_object.h | 8 ++++- source/blender/editors/mesh/mesh_ops.c | 2 +- source/blender/editors/object/object_ops.c | 34 +++++++++++++++------- source/blender/editors/physics/physics_ops.c | 2 +- source/blender/editors/transform/transform.c | 13 +++++---- .../blender/editors/transform/transform_generics.c | 21 +++++++++---- source/blender/editors/uvedit/uvedit_ops.c | 2 +- 8 files changed, 57 insertions(+), 27 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index d650cecdc3e..47b1fee3cf6 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -233,6 +233,6 @@ void ED_keymap_curve(wmKeyConfig *keyconf) /* menus */ WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); - ED_object_generic_keymap(keyconf, keymap, 2); + ED_object_generic_keymap(keyconf, keymap, 3); } diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index a03cd135f1c..efa5d6c5dad 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -55,7 +55,13 @@ void ED_operatortypes_object(void); void ED_operatormacros_object(void); void ED_keymap_object(struct wmKeyConfig *keyconf); -/* generic editmode keys like pet */ +/* generic editmode keys like pet + * do_pet + * 0: No + * 1: Object + * 2: Edit + * 3: Edit with connected + * */ void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int do_pet); /* send your own notifier for select! */ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index e143e4859f5..9eac347c893 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -314,6 +314,6 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0); - ED_object_generic_keymap(keyconf, keymap, 2); + ED_object_generic_keymap(keyconf, keymap, 3); } diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index e1ea7924916..610a82d964c 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -364,7 +364,10 @@ void ED_keymap_object(wmKeyConfig *keyconf) RNA_int_set(kmi->ptr, "level", i); } - /* Lattice -------------------------------------------------------------------- */ + /* ############################################################################ */ + /* ################################ LATTICE ################################### */ + /* ############################################################################ */ + keymap= WM_keymap_find(keyconf, "Lattice", 0, 0); keymap->poll= ED_operator_editlattice; @@ -375,7 +378,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) /* menus */ WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); - ED_object_generic_keymap(keyconf, keymap, 1); + ED_object_generic_keymap(keyconf, keymap, 2); } void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int do_pet) @@ -383,22 +386,31 @@ void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keym wmKeyMapItem *kmi; /* used by mesh, curve & lattice only */ - if(do_pet > 0) { + if(do_pet) { /* context ops */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing_falloff"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing"); - RNA_string_set(kmi->ptr, "value_1", "DISABLED"); - RNA_string_set(kmi->ptr, "value_2", "ENABLED"); + // Object mode + if (do_pet == 1) { + + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing_objects"); + + } else { // Edit mode - /* for modes/object types that allow 'conencted' mode, add the Alt O key */ - if (do_pet > 1) { - kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing"); RNA_string_set(kmi->ptr, "value_1", "DISABLED"); - RNA_string_set(kmi->ptr, "value_2", "CONNECTED"); + RNA_string_set(kmi->ptr, "value_2", "ENABLED"); + + /* for modes/object types that allow 'connected' mode, add the Alt O key */ + if (do_pet == 3) { + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing"); + RNA_string_set(kmi->ptr, "value_1", "DISABLED"); + RNA_string_set(kmi->ptr, "value_2", "CONNECTED"); + } } } } diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 5a51c36cd09..2b7f8e9d5a2 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -114,7 +114,7 @@ static void keymap_particle(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); - ED_object_generic_keymap(keyconf, keymap, 1); + ED_object_generic_keymap(keyconf, keymap, 2); } /******************************* boids *************************************/ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 9743a4ef0f5..926d8ffd007 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1367,17 +1367,17 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } - /* XXX convert stupid flag to enum */ + /* convert flag to enum */ switch(t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) { case (T_PROP_EDIT|T_PROP_CONNECTED): - proportional = 2; + proportional = PROP_EDIT_CONNECTED; break; case T_PROP_EDIT: - proportional = 1; + proportional = PROP_EDIT_ON; break; default: - proportional = 0; + proportional = PROP_EDIT_OFF; } // If modal, save settings back in scene if not set as operator argument @@ -1385,7 +1385,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) /* save settings if not set in operator */ if (RNA_struct_find_property(op->ptr, "proportional") && !RNA_property_is_set(op->ptr, "proportional")) { - ts->proportional = proportional; + if (t->obedit) + ts->proportional = proportional; + else + ts->proportional_objects = (proportional != PROP_EDIT_OFF); } if (RNA_struct_find_property(op->ptr, "proportional_size") && !RNA_property_is_set(op->ptr, "proportional_size")) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8d98255d3d9..920c5c12ea1 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -38,6 +38,7 @@ #include "DNA_armature_types.h" #include "DNA_lattice_types.h" #include "DNA_screen_types.h" +#include "DNA_scene_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" @@ -1033,9 +1034,9 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) { switch(RNA_enum_get(op->ptr, "proportional")) { - case 2: /* XXX connected constant */ + case PROP_EDIT_CONNECTED: t->flag |= T_PROP_CONNECTED; - case 1: /* XXX prop on constant */ + case PROP_EDIT_ON: t->flag |= T_PROP_EDIT; break; } @@ -1045,11 +1046,19 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) /* use settings from scene only if modal */ if (t->flag & T_MODAL) { - if ((t->options & CTX_NO_PET) == 0 && (ts->proportional != PROP_EDIT_OFF)) { - t->flag |= T_PROP_EDIT; + if ((t->options & CTX_NO_PET) == 0) + { + if (t->obedit && ts->proportional != PROP_EDIT_OFF) + { + t->flag |= T_PROP_EDIT; - if(ts->proportional == PROP_EDIT_CONNECTED) - t->flag |= T_PROP_CONNECTED; + if(ts->proportional == PROP_EDIT_CONNECTED) + t->flag |= T_PROP_CONNECTED; + } + else if (t->obedit == NULL && ts->proportional_objects) + { + t->flag |= T_PROP_EDIT; + } } } } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index bae8d4b7fcf..cbc0eb41f84 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -3241,7 +3241,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) /* menus */ WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - ED_object_generic_keymap(keyconf, keymap, 1); + ED_object_generic_keymap(keyconf, keymap, 2); transform_keymap_for_space(keyconf, keymap, SPACE_IMAGE); } -- cgit v1.2.3 From ea6730cdd1f3ad77d6cd9ba511b1c632ef225542 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Aug 2010 09:56:00 +0000 Subject: - font object x/yoffset was making text box's wrap text incorrectly. - draw text boxes with the offset applied. (abologies for making font.c even more confusing) --- source/blender/editors/space_view3d/drawobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 02a8709a1ac..9d0c5bcd898 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5802,8 +5802,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) UI_ThemeColor(TH_ACTIVE); else UI_ThemeColor(TH_WIRE); - vec1[0] = cu->tb[i].x; - vec1[1] = cu->tb[i].y + cu->fsize; + vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x; + vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize; vec1[2] = 0.001; glBegin(GL_LINE_STRIP); glVertex3fv(vec1); -- cgit v1.2.3 From e56913fe3961e9ab34b15e5317d83e9110e20857 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Aug 2010 10:36:02 +0000 Subject: fix for un-initialized layer (only bits between 1 and 20 were initialized) --- source/blender/editors/object/object_add.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index e08661b1795..50851b57a65 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -241,7 +241,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa if(RNA_property_is_set(op->ptr, "layer")) { RNA_boolean_get_array(op->ptr, "layer", layer_values); - + *layer= 0; for(a=0; a<20; a++) { if(layer_values[a]) *layer |= (1 << a); -- cgit v1.2.3 From d25747ee751096de2e417a7da1316bf5bf81c25a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Aug 2010 11:00:36 +0000 Subject: bugfix's [#23108] bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') dosen't work in console [#23115] Crash when moving armature origin - setting the armature in editmode would leave editdata in some cases. - transforming selected linked objects to account for the movement of the obdata was only done for meshes, now do for curves and text3d. - added utility functions for getting curve & mesh bounds. - text3d moving center wasn't working at all. - changed drawobject.c to use BLI_math funcs in more places. - remove some unused code from operator object.origin_set. --- source/blender/editors/armature/editarmature.c | 48 +-- source/blender/editors/include/ED_armature.h | 2 +- source/blender/editors/object/object_transform.c | 373 ++++++++++------------- source/blender/editors/space_view3d/drawobject.c | 149 +++++---- 4 files changed, 258 insertions(+), 314 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 989c5bdc0ba..480bade1dc3 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -421,34 +421,45 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) /* exported for use in editors/object/ */ /* 0 == do center, 1 == center new, 2 == center cursor */ -void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) +void docenter_armature (Scene *scene, Object *ob, float cursor[3], int centermode, int around) { Object *obedit= scene->obedit; // XXX get from context EditBone *ebone; bArmature *arm= ob->data; - float cent[3] = {0.0f, 0.0f, 0.0f}; - float min[3], max[3]; + float cent[3]; /* Put the armature into editmode */ - if(ob!=obedit) + if(ob != obedit) { ED_armature_to_edit(ob); + obedit= NULL; /* we cant use this so behave as if there is no obedit */ + } /* Find the centerpoint */ if (centermode == 2) { - float *fp= give_cursor(scene, v3d); - copy_v3_v3(cent, fp); + copy_v3_v3(cent, cursor); invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); } else { - INIT_MINMAX(min, max); - - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { - DO_MINMAX(ebone->head, min, max); - DO_MINMAX(ebone->tail, min, max); + if(around==V3D_CENTROID) { + int total= 0; + zero_v3(cent); + for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { + total+=2; + add_v3_v3(cent, ebone->head); + add_v3_v3(cent, ebone->tail); + } + mul_v3_fl(cent, 1.0f/(float)total); + } + else { + float min[3], max[3]; + INIT_MINMAX(min, max); + for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { + DO_MINMAX(ebone->head, min, max); + DO_MINMAX(ebone->tail, min, max); + } + mid_v3_v3v3(cent, min, max); } - - mid_v3_v3v3(cent, min, max); } /* Do the adjustments */ @@ -458,16 +469,16 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) } /* Turn the list into an armature */ - ED_armature_from_edit(ob); - + if(obedit==NULL) { + ED_armature_from_edit(ob); + ED_armature_edit_free(ob); + } + /* Adjust object location for new centerpoint */ if(centermode && obedit==NULL) { mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */ add_v3_v3(ob->loc, cent); } - else { - ED_armature_edit_free(ob); - } } /* ---------------------- */ @@ -2018,7 +2029,6 @@ void ED_armature_edit_free(struct Object *ob) BLI_freelistN(arm->edbo); } - MEM_freeN(arm->edbo); arm->edbo= NULL; } diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index d2d1e2a1d69..52db36e188d 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -120,7 +120,7 @@ void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone); void transform_armature_mirror_update(struct Object *obedit); void clear_armature(struct Scene *scene, struct Object *ob, char mode); -void docenter_armature (struct Scene *scene, struct View3D *v3d, struct Object *ob, int centermode); +void docenter_armature (struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around); void ED_armature_apply_transform(struct Object *ob, float mat[4][4]); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index bc8a2a2fc60..bd23d3a4b67 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -694,81 +694,73 @@ void texspace_edit(Scene *scene, View3D *v3d) /********************* Set Object Center ************************/ -static EnumPropertyItem prop_set_center_types[] = { - {0, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"}, - {1, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Move object origin to center of object geometry"}, - {2, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3d cursor"}, - {0, NULL, 0, NULL, NULL} +enum { + GEOMETRY_TO_ORIGIN=0, + ORIGIN_TO_GEOMETRY, + ORIGIN_TO_CURSOR }; -/* 0 == do center, 1 == center new, 2 == center cursor */ static int object_origin_set_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); Object *obedit= CTX_data_edit_object(C); Object *tob; - Mesh *me, *tme; - Curve *cu; -/* BezTriple *bezt; - BPoint *bp; */ - Nurb *nu, *nu1; - EditVert *eve; - float cent[3], centn[3], min[3], max[3]; - int a, total= 0; + float cursor[3], cent[3], cent_neg[3], centn[3], min[3], max[3]; int centermode = RNA_enum_get(op->ptr, "type"); - + int around = RNA_enum_get(op->ptr, "center"); /* initialized from v3d->around */ + /* keep track of what is changed */ int tot_change=0, tot_lib_error=0, tot_multiuser_arm_error=0; - MVert *mvert; - if(scene->id.lib || v3d==NULL){ - BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed on Lib data"); - return OPERATOR_CANCELLED; - } - if (obedit && centermode > 0) { + if (obedit && centermode != GEOMETRY_TO_ORIGIN) { BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode"); return OPERATOR_CANCELLED; } + else { + /* get the view settings if 'around' isnt set and the view is available */ + View3D *v3d= CTX_wm_view3d(C); + copy_v3_v3(cursor, give_cursor(scene, v3d)); + if(v3d && !RNA_property_is_set(op->ptr, "around")) + around= v3d->around; + } + zero_v3(cent); - - if(obedit) { + if(obedit) { INIT_MINMAX(min, max); - + if(obedit->type==OB_MESH) { Mesh *me= obedit->data; EditMesh *em = BKE_mesh_get_editmesh(me); + EditVert *eve; - for(eve= em->verts.first; eve; eve= eve->next) { - if(v3d->around==V3D_CENTROID) { + if(around==V3D_CENTROID) { + int total= 0; + for(eve= em->verts.first; eve; eve= eve->next) { total++; add_v3_v3(cent, eve->co); } - else { - DO_MINMAX(eve->co, min, max); - } - } - - if(v3d->around==V3D_CENTROID) { mul_v3_fl(cent, 1.0f/(float)total); } else { + for(eve= em->verts.first; eve; eve= eve->next) { + DO_MINMAX(eve->co, min, max); + } mid_v3_v3v3(cent, min, max); } - + for(eve= em->verts.first; eve; eve= eve->next) { - sub_v3_v3(eve->co, cent); + sub_v3_v3(eve->co, cent); } - + recalc_editnormals(em); tot_change++; DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); BKE_mesh_end_editmesh(me, em); } } - + /* reset flags */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { ob->flag &= ~OB_DONE; @@ -779,190 +771,93 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if(tob->data) ((ID *)tob->data)->flag &= ~LIB_DOIT; } - + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if((ob->flag & OB_DONE)==0) { ob->flag |= OB_DONE; - - if(obedit==NULL && (me=get_mesh(ob)) ) { - if (me->id.lib) { - tot_lib_error++; - } else { - if(centermode==2) { - copy_v3_v3(cent, give_cursor(scene, v3d)); - invert_m4_m4(ob->imat, ob->obmat); - mul_m4_v3(ob->imat, cent); - } else { - INIT_MINMAX(min, max); - mvert= me->mvert; - for(a=0; atotvert; a++, mvert++) { - DO_MINMAX(mvert->co, min, max); - } - - mid_v3_v3v3(cent, min, max); - } - mvert= me->mvert; - for(a=0; atotvert; a++, mvert++) { - sub_v3_v3(mvert->co, cent); - } - - if (me->key) { - KeyBlock *kb; - for (kb=me->key->block.first; kb; kb=kb->next) { - float *fp= kb->data; - - for (a=0; atotelem; a++, fp+=3) { - sub_v3_v3(fp, cent); - } - } - } + if(ob->data == NULL) { + /* pass */ + } + else if (((ID *)ob->data)->lib) { + tot_lib_error++; + } - tot_change++; - me->id.flag |= LIB_DOIT; - - if(centermode) { - copy_v3_v3(centn, cent); - mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */ - add_v3_v3(ob->loc, centn); - - where_is_object(scene, ob); - ignore_parent_tx(bmain, scene, ob); - - /* other users? */ - CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) { - if((ob_other->flag & OB_DONE)==0) { - tme= get_mesh(ob_other); - - if(tme==me) { - - ob_other->flag |= OB_DONE; - ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA; - - copy_v3_v3(centn, cent); - mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */ - add_v3_v3(ob_other->loc, centn); - - where_is_object(scene, ob_other); - ignore_parent_tx(bmain, scene, ob_other); - - if(!(tme->id.flag & LIB_DOIT)) { - mvert= tme->mvert; - for(a=0; atotvert; a++, mvert++) { - sub_v3_v3(mvert->co, cent); - } - - if (tme->key) { - KeyBlock *kb; - for (kb=tme->key->block.first; kb; kb=kb->next) { - float *fp= kb->data; - - for (a=0; atotelem; a++, fp+=3) { - sub_v3_v3(fp, cent); - } - } - } - - tot_change++; - tme->id.flag |= LIB_DOIT; - } - } - } - } - CTX_DATA_END; - } + if(obedit==NULL && ob->type==OB_MESH) { + Mesh *me= ob->data; + + if(centermode == ORIGIN_TO_CURSOR) { + copy_v3_v3(cent, cursor); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_v3(ob->imat, cent); + } else { + if(around==V3D_CENTROID) + mesh_center_median(me, cent); + else + mesh_center_bounds(me, cent); } + + negate_v3_v3(cent_neg, cent); + mesh_translate(me, cent_neg, 1); + + tot_change++; + me->id.flag |= LIB_DOIT; } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { - - /* weak code here... (ton) */ - if(obedit==ob) { - ListBase *editnurb= curve_get_editcurve(obedit); + Curve *cu= ob->data; - nu1= editnurb->first; - cu= obedit->data; + if(centermode == ORIGIN_TO_CURSOR) { + copy_v3_v3(cent, cursor); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_v3(ob->imat, cent); } else { - cu= ob->data; - nu1= cu->nurb.first; + if(around==V3D_CENTROID) + curve_center_median(cu, cent); + else + curve_center_bounds(cu, cent); } - - if (cu->id.lib) { - tot_lib_error++; - } else { - if(centermode==2) { - copy_v3_v3(cent, give_cursor(scene, v3d)); - invert_m4_m4(ob->imat, ob->obmat); - mul_m4_v3(ob->imat, cent); - /* don't allow Z change if curve is 2D */ - if( !( cu->flag & CU_3D ) ) - cent[2] = 0.0; - } - else { - INIT_MINMAX(min, max); - - nu= nu1; - while(nu) { - minmaxNurb(nu, min, max); - nu= nu->next; - } - - mid_v3_v3v3(cent, min, max); - } - - nu= nu1; - while(nu) { - if(nu->type == CU_BEZIER) { - a= nu->pntsu; - while (a--) { - sub_v3_v3(nu->bezt[a].vec[0], cent); - sub_v3_v3(nu->bezt[a].vec[1], cent); - sub_v3_v3(nu->bezt[a].vec[2], cent); - } - } - else { - a= nu->pntsu*nu->pntsv; - while (a--) - sub_v3_v3(nu->bp[a].vec, cent); - } - nu= nu->next; - } - - if(centermode && obedit==NULL) { - mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */ - add_v3_v3(ob->loc, cent); - where_is_object(scene, ob); - ignore_parent_tx(bmain, scene, ob); - } - - tot_change++; - cu->id.flag |= LIB_DOIT; + /* don't allow Z change if curve is 2D */ + if( !( cu->flag & CU_3D ) ) + cent[2] = 0.0; - if(obedit) { - if (centermode==0) { - DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - } - break; + negate_v3_v3(cent_neg, cent); + curve_translate(cu, cent_neg, 1); + + tot_change++; + cu->id.flag |= LIB_DOIT; + + if(obedit) { + if (centermode == GEOMETRY_TO_ORIGIN) { + DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); } + break; } } else if(ob->type==OB_FONT) { /* get from bb */ - - cu= ob->data; - - if(cu->bb==NULL) { + + Curve *cu= ob->data; + + if(cu->bb==NULL && (centermode != ORIGIN_TO_CURSOR)) { /* do nothing*/ - } else if (cu->id.lib) { - tot_lib_error++; - } else { - cu->xof= -0.5f*( cu->bb->vec[4][0] - cu->bb->vec[0][0]); - cu->yof= -0.5f -0.5f*( cu->bb->vec[0][1] - cu->bb->vec[2][1]); /* extra 0.5 is the height o above line */ - - /* not really ok, do this better once! */ - cu->xof /= cu->fsize; - cu->yof /= cu->fsize; + } + else { + if(centermode == ORIGIN_TO_CURSOR) { + copy_v3_v3(cent, cursor); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_v3(ob->imat, cent); + } + else { + cent[0]= 0.5f * ( cu->bb->vec[4][0] + cu->bb->vec[0][0]); + cent[1]= 0.5f * ( cu->bb->vec[0][1] + cu->bb->vec[2][1]) - 0.5f; /* extra 0.5 is the height o above line */ + } + + cent[2]= 0.0f; + + cu->xof= cu->xof - (cent[0] / cu->fsize); + cu->yof= cu->yof - (cent[1] / cu->fsize); tot_change++; cu->id.flag |= LIB_DOIT; @@ -970,29 +865,58 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } else if(ob->type==OB_ARMATURE) { bArmature *arm = ob->data; - - if (arm->id.lib) { - tot_lib_error++; - } else if(ID_REAL_USERS(arm) > 1) { + + if(ID_REAL_USERS(arm) > 1) { /*BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature"); return;*/ tot_multiuser_arm_error++; - } else { - /* Function to recenter armatures in editarmature.c + } + else { + /* Function to recenter armatures in editarmature.c * Bone + object locations are handled there. */ - docenter_armature(scene, v3d, ob, centermode); + docenter_armature(scene, ob, cursor, centermode, around); tot_change++; - cu->id.flag |= LIB_DOIT; - + arm->id.flag |= LIB_DOIT; + where_is_object(scene, ob); ignore_parent_tx(bmain, scene, ob); - - if(obedit) + + if(obedit) break; } } + + /* offset other selected objects */ + if(centermode != GEOMETRY_TO_ORIGIN) { + /* was the object data modified + * note: the functions above must set 'cent' */ + if(ob->data && (((ID *)ob->data)->flag && LIB_DOIT) && ob->type != OB_ARMATURE) { + copy_v3_v3(centn, cent); + mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */ + add_v3_v3(ob->loc, centn); + + where_is_object(scene, ob); + ignore_parent_tx(bmain, scene, ob); + + /* other users? */ + CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) { + if((ob_other->flag & OB_DONE)==0 && (ob_other->data == ob->data)) { + ob_other->flag |= OB_DONE; + ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA; + + copy_v3_v3(centn, cent); + mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */ + add_v3_v3(ob_other->loc, centn); + + where_is_object(scene, ob_other); + ignore_parent_tx(bmain, scene, ob_other); + } + } + CTX_DATA_END; + } + } } } CTX_DATA_END; @@ -1002,26 +926,39 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tob->recalc= OB_RECALC_OB|OB_RECALC_DATA; } } - + if (tot_change) { DAG_ids_flush_update(0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); } - + /* Warn if any errors occurred */ if (tot_lib_error+tot_multiuser_arm_error) { - BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:",tot_lib_error+tot_multiuser_arm_error, tot_change); + BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:",tot_lib_error+tot_multiuser_arm_error, tot_change); if (tot_lib_error) BKE_reportf(op->reports, RPT_WARNING, "|%i linked library objects",tot_lib_error); if (tot_multiuser_arm_error) BKE_reportf(op->reports, RPT_WARNING, "|%i multiuser armature object(s)",tot_multiuser_arm_error); } - + return OPERATOR_FINISHED; } void OBJECT_OT_origin_set(wmOperatorType *ot) { + static EnumPropertyItem prop_set_center_types[] = { + {GEOMETRY_TO_ORIGIN, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"}, + {ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Move object origin to center of object geometry"}, + {ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3d cursor"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem prop_set_bounds_types[] = { + {V3D_CENTROID, "MEDIAN", 0, "Median Center", ""}, + {V3D_CENTER, "BOUNDS", 0, "Bounds Center", ""}, + {0, NULL, 0, NULL, NULL} + }; + /* identifiers */ ot->name= "Set Origin"; ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3d cursor"; @@ -1031,12 +968,12 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= object_origin_set_exec; - ot->poll= ED_operator_view3d_active; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; ot->prop= RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", ""); - + RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_CENTROID, "Center", ""); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 9d0c5bcd898..54775affe3f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -146,7 +146,7 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int l return; } - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(rv3d->persmatob, vec4); @@ -175,7 +175,7 @@ static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr) adr[0]= IS_CLIPPED; - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(rv3d->persmatob, vec4); @@ -1146,7 +1146,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* and back to viewspace */ glLoadMatrixf(rv3d->viewmat); - VECCOPY(vec, ob->obmat[3]); + copy_v3_v3(vec, ob->obmat[3]); setlinestyle(0); @@ -3257,7 +3257,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix case PART_DRAW_DOT: { if(vd) { - VECCOPY(vd,state->co) pdd->vd+=3; + copy_v3_v3(vd,state->co); pdd->vd+=3; } if(cd) { cd[0]=ma_r; @@ -3282,7 +3282,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix cd[14]=cd[17]=1.0; pdd->cd+=18; - VECCOPY(vec2,state->co); + copy_v3_v3(vec2,state->co); } else { if(cd) { @@ -3291,47 +3291,47 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]=ma_b; pdd->cd+=18; } - VECSUB(vec2,state->co,vec); + sub_v3_v3v3(vec2, state->co, vec); } - VECADD(vec,state->co,vec); - VECCOPY(pdd->vd,vec); pdd->vd+=3; - VECCOPY(pdd->vd,vec2); pdd->vd+=3; + add_v3_v3(vec, state->co); + copy_v3_v3(pdd->vd,vec); pdd->vd+=3; + copy_v3_v3(pdd->vd,vec2); pdd->vd+=3; vec[1]=2.0f*pixsize; vec[0]=vec[2]=0.0; mul_qt_v3(state->rot,vec); if(draw_as==PART_DRAW_AXIS){ - VECCOPY(vec2,state->co); + copy_v3_v3(vec2,state->co); } - else VECSUB(vec2,state->co,vec); + else sub_v3_v3v3(vec2, state->co, vec); - VECADD(vec,state->co,vec); - VECCOPY(pdd->vd,vec); pdd->vd+=3; - VECCOPY(pdd->vd,vec2); pdd->vd+=3; + add_v3_v3(vec, state->co); + copy_v3_v3(pdd->vd,vec); pdd->vd+=3; + copy_v3_v3(pdd->vd,vec2); pdd->vd+=3; vec[2]=2.0f*pixsize; vec[0]=vec[1]=0.0; mul_qt_v3(state->rot,vec); if(draw_as==PART_DRAW_AXIS){ - VECCOPY(vec2,state->co); + copy_v3_v3(vec2,state->co); } - else VECSUB(vec2,state->co,vec); + else sub_v3_v3v3(vec2, state->co, vec); - VECADD(vec,state->co,vec); + add_v3_v3(vec, state->co); - VECCOPY(pdd->vd,vec); pdd->vd+=3; - VECCOPY(pdd->vd,vec2); pdd->vd+=3; + copy_v3_v3(pdd->vd,vec); pdd->vd+=3; + copy_v3_v3(pdd->vd,vec2); pdd->vd+=3; break; } case PART_DRAW_LINE: { - VECCOPY(vec,state->vel); + copy_v3_v3(vec,state->vel); normalize_v3(vec); if(draw & PART_DRAW_VEL_LENGTH) mul_v3_fl(vec,len_v3(state->vel)); - VECADDFAC(pdd->vd,state->co,vec,-draw_line[0]); pdd->vd+=3; - VECADDFAC(pdd->vd,state->co,vec,draw_line[1]); pdd->vd+=3; + madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd+=3; + madd_v3_v3v3fl(pdd->vd, state->co, vec, draw_line[1]); pdd->vd+=3; if(cd) { cd[0]=cd[3]=ma_r; cd[1]=cd[4]=ma_g; @@ -3358,27 +3358,27 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix } - VECCOPY(bb->vec, state->co); - VECCOPY(bb->vel, state->vel); + copy_v3_v3(bb->vec, state->co); + copy_v3_v3(bb->vel, state->vel); psys_make_billboard(bb, xvec, yvec, zvec, bb_center); - VECADD(pdd->vd,bb_center,xvec); - VECADD(pdd->vd,pdd->vd,yvec); pdd->vd+=3; + add_v3_v3v3(pdd->vd, bb_center, xvec); + add_v3_v3(pdd->vd, yvec); pdd->vd+=3; - VECSUB(pdd->vd,bb_center,xvec); - VECADD(pdd->vd,pdd->vd,yvec); pdd->vd+=3; + sub_v3_v3v3(pdd->vd, bb_center, vec); + add_v3_v3(pdd->vd, yvec); pdd->vd+=3; - VECSUB(pdd->vd,bb_center,xvec); - VECSUB(pdd->vd,pdd->vd,yvec); pdd->vd+=3; + sub_v3_v3v3(pdd->vd, bb_center, xvec); + sub_v3_v3v3(pdd->vd, pdd->vd,yvec); pdd->vd+=3; - VECADD(pdd->vd,bb_center,xvec); - VECSUB(pdd->vd,pdd->vd,yvec); pdd->vd+=3; + add_v3_v3v3(pdd->vd, bb_center, xvec); + sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd+=3; - VECCOPY(pdd->nd, zvec); pdd->nd+=3; - VECCOPY(pdd->nd, zvec); pdd->nd+=3; - VECCOPY(pdd->nd, zvec); pdd->nd+=3; - VECCOPY(pdd->nd, zvec); pdd->nd+=3; + copy_v3_v3(pdd->nd, zvec); pdd->nd+=3; + copy_v3_v3(pdd->nd, zvec); pdd->nd+=3; + copy_v3_v3(pdd->nd, zvec); pdd->nd+=3; + copy_v3_v3(pdd->nd, zvec); pdd->nd+=3; break; } } @@ -3787,11 +3787,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv /* additional things to draw for each particle */ /* (velocity, size and number) */ if((part->draw & PART_DRAW_VEL) && pdd->vedata){ - VECCOPY(pdd->ved,state.co); - pdd->ved+=3; - VECCOPY(vel,state.vel); - mul_v3_fl(vel,timestep); - VECADD(pdd->ved,state.co,vel); + copy_v3_v3(pdd->ved,state.co); + pdd->ved += 3; + mul_v3_v3fl(vel, state.vel, timestep); + add_v3_v3v3(pdd->ved, state.co, vel); pdd->ved+=3; totve++; @@ -4069,7 +4068,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj if(timed) { for(k=0, pcol=pathcol, pkey=path; kcol); + copy_v3_v3(pcol, pkey->col); pcol[3] = 1.0f - fabs((float)CFRA - pkey->time)/(float)pset->fade_frames; } @@ -4107,15 +4106,15 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj for(k=0, key=point->keys; ktotkey; k++, key++){ if(pd) { - VECCOPY(pd, key->co); + copy_v3_v3(pd, key->co); pd += 3; } if(key->flag&PEK_SELECT){ - VECCOPY(cd,sel_col); + copy_v3_v3(cd,sel_col); } else{ - VECCOPY(cd,nosel_col); + copy_v3_v3(cd,nosel_col); } if(timed) @@ -4189,12 +4188,12 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[1] = root[2] = 0.0f; root[0] = -drw_size; mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); tip[1] = tip[2] = 0.0f; tip[0] = drw_size; mul_m3_v3(tr,tip); - VECADD(tip,tip,com); + add_v3_v3(tip, com); glVertex3fv(tip); glEnd(); @@ -4202,7 +4201,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4211,7 +4210,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4220,7 +4219,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] =th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4229,7 +4228,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4240,12 +4239,12 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = root[2] = 0.0f; root[1] = -drw_size; mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); tip[0] = tip[2] = 0.0f; tip[1] = drw_size; mul_m3_v3(tr,tip); - VECADD(tip,tip,com); + add_v3_v3(tip, com); glVertex3fv(tip); glEnd(); @@ -4253,7 +4252,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[1] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4262,7 +4261,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[1] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4271,7 +4270,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[1] =th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4280,7 +4279,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[1] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4290,12 +4289,12 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = root[1] = 0.0f; root[2] = -drw_size; mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); tip[0] = tip[1] = 0.0f; tip[2] = drw_size; mul_m3_v3(tr,tip); - VECADD(tip,tip,com); + add_v3_v3(tip, com); glVertex3fv(tip); glEnd(); @@ -4303,7 +4302,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[2] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4312,7 +4311,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[2] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4321,7 +4320,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[2] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4330,7 +4329,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[2] = th; glBegin(GL_LINES); mul_m3_v3(tr,root); - VECADD(root,root,com); + add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); @@ -4869,12 +4868,10 @@ static void drawspiral(float *cent, float rad, float tmat[][4], int start) start *= -1; } - VECCOPY(vx, tmat[0]); - VECCOPY(vy, tmat[1]); - mul_v3_fl(vx, rad); - mul_v3_fl(vy, rad); + mul_v3_v3fl(vx, tmat[0], rad); + mul_v3_v3fl(vy, tmat[1], rad); - VECCOPY(vec, cent); + copy_v3_v3(vec, cent); if (inverse==0) { for(a=0; atype, OB_CURVE, OB_SURF, OB_FONT) { Curve *cu= ob->data; - VECCOPY(size, cu->size); - VECCOPY(loc, cu->loc); + copy_v3_v3(size, cu->size); + copy_v3_v3(loc, cu->loc); } else if(ob->type==OB_MBALL) { MetaBall *mb= ob->data; - VECCOPY(size, mb->size); - VECCOPY(loc, mb->loc); + copy_v3_v3(size, mb->size); + copy_v3_v3(loc, mb->loc); } else return; @@ -5781,8 +5778,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if (cu->linewidth != 0.0) { cpack(0xff44ff); UI_ThemeColor(TH_WIRE); - VECCOPY(vec1, ob->orig); - VECCOPY(vec2, ob->orig); + copy_v3_v3(vec1, ob->orig); + copy_v3_v3(vec2, ob->orig); vec1[0] += cu->linewidth; vec2[0] += cu->linewidth; vec1[1] += cu->linedist * cu->fsize; @@ -6071,7 +6068,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(density[index] > FLT_EPSILON) { float color[3]; - VECCOPY(tmp, smd->domain->p0); + copy_v3_v3(tmp, smd->domain->p0); tmp[0] += smd->domain->dx * x + smd->domain->dx * 0.5; tmp[1] += smd->domain->dx * y + smd->domain->dx * 0.5; tmp[2] += smd->domain->dx * z + smd->domain->dx * 0.5; -- cgit v1.2.3 From 5fa7d1c1b4e7bde1d173caa60af0e273c86b6f0b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 1 Aug 2010 12:47:49 +0000 Subject: 2.5: code changes to reduce the usage of G.main and pass it along or get it from the context instead. --- source/blender/editors/animation/drivers.c | 4 +- source/blender/editors/animation/keyframing.c | 16 ++- source/blender/editors/animation/keyingsets.c | 6 +- source/blender/editors/armature/editarmature.c | 8 +- source/blender/editors/curve/editcurve.c | 8 +- source/blender/editors/include/ED_object.h | 35 ++--- .../editors/interface/interface_templates.c | 3 +- source/blender/editors/interface/resources.c | 53 +++---- source/blender/editors/mesh/editmesh.c | 19 +-- source/blender/editors/mesh/meshtools.c | 9 +- source/blender/editors/object/object_add.c | 71 +++++---- source/blender/editors/object/object_constraint.c | 25 ++-- source/blender/editors/object/object_edit.c | 160 ++------------------- source/blender/editors/object/object_group.c | 16 ++- source/blender/editors/object/object_hook.c | 11 +- source/blender/editors/object/object_modifier.c | 26 ++-- source/blender/editors/object/object_relations.c | 82 ++++++----- source/blender/editors/object/object_transform.c | 18 ++- source/blender/editors/physics/particle_boids.c | 7 +- source/blender/editors/physics/particle_object.c | 8 +- source/blender/editors/render/render_internal.c | 16 ++- source/blender/editors/render/render_opengl.c | 8 +- source/blender/editors/render/render_preview.c | 4 +- source/blender/editors/screen/screen_edit.c | 3 +- source/blender/editors/screen/screen_ops.c | 4 +- source/blender/editors/space_graph/graph_buttons.c | 5 +- source/blender/editors/space_logic/logic_window.c | 47 +++--- source/blender/editors/space_node/drawnode.c | 12 +- source/blender/editors/space_node/node_edit.c | 3 +- source/blender/editors/space_outliner/outliner.c | 7 +- source/blender/editors/space_text/text_ops.c | 3 +- .../blender/editors/space_view3d/view3d_buttons.c | 4 +- .../blender/editors/space_view3d/view3d_header.c | 3 +- source/blender/editors/space_view3d/view3d_snap.c | 9 +- source/blender/editors/space_view3d/view3d_view.c | 12 +- .../editors/transform/transform_conversions.c | 4 +- source/blender/editors/util/ed_util.c | 3 +- 37 files changed, 342 insertions(+), 390 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 3fc228e1c15..9edcf637cdc 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -389,7 +389,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX } @@ -440,7 +440,7 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index f60181d7f6c..ea20a5c2c88 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -51,6 +51,7 @@ #include "BKE_constraint.h" #include "BKE_depsgraph.h" #include "BKE_fcurve.h" +#include "BKE_main.h" #include "BKE_nla.h" #include "BKE_global.h" #include "BKE_utildefines.h" @@ -1060,6 +1061,7 @@ static int modify_key_op_poll(bContext *C) static int insert_key_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks= NULL; int type= RNA_int_get(op->ptr, "type"); @@ -1106,7 +1108,7 @@ static int insert_key_exec (bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes"); /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); return OPERATOR_FINISHED; } @@ -1202,6 +1204,7 @@ void ANIM_OT_keyframe_insert_menu (wmOperatorType *ot) static int delete_key_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks= NULL; int type= RNA_int_get(op->ptr, "type"); @@ -1248,7 +1251,7 @@ static int delete_key_exec (bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes"); /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); return OPERATOR_FINISHED; } @@ -1287,6 +1290,7 @@ void ANIM_OT_keyframe_delete (wmOperatorType *ot) static int delete_key_v3d_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap @@ -1315,7 +1319,7 @@ static int delete_key_v3d_exec (bContext *C, wmOperator *op) CTX_DATA_END; /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL); @@ -1343,6 +1347,7 @@ void ANIM_OT_keyframe_delete_v3d (wmOperatorType *ot) static int insert_key_button_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); PointerRNA ptr; PropertyRNA *prop= NULL; @@ -1400,7 +1405,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); @@ -1430,6 +1435,7 @@ void ANIM_OT_keyframe_insert_button (wmOperatorType *ot) static int delete_key_button_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); PointerRNA ptr; PropertyRNA *prop= NULL; @@ -1470,7 +1476,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 301111d22fd..033c4713e01 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -289,6 +289,7 @@ void ANIM_OT_keying_set_path_remove (wmOperatorType *ot) static int add_keyingset_button_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks = NULL; PropertyRNA *prop= NULL; @@ -359,7 +360,7 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* for now, only send ND_KEYS for KeyingSets */ WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); @@ -389,6 +390,7 @@ void ANIM_OT_keyingset_button_add (wmOperatorType *ot) static int remove_keyingset_button_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks = NULL; PropertyRNA *prop= NULL; @@ -441,7 +443,7 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* for now, only send ND_KEYS for KeyingSets */ WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 480bade1dc3..3b5c07a8001 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -809,6 +809,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* join armature exec is exported for use in object->join objects operator... */ int join_armature_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); bArmature *arm= (ob)? ob->data: NULL; @@ -901,12 +902,12 @@ int join_armature_exec(bContext *C, wmOperator *op) free_pose_channels_hash(pose); } - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(bmain, scene, base); } } CTX_DATA_END; - DAG_scene_sort(scene); // because we removed object(s) + DAG_scene_sort(bmain, scene); // because we removed object(s) ED_armature_from_edit(ob); ED_armature_edit_free(ob); @@ -1118,6 +1119,7 @@ static void separate_armature_bones (Scene *scene, Object *ob, short sel) /* separate selected bones into their armature */ static int separate_armature_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); Object *oldob, *newob; @@ -1158,7 +1160,7 @@ static int separate_armature_exec (bContext *C, wmOperator *op) ED_armature_edit_free(obedit); /* 2) duplicate base */ - newbase= ED_object_add_duplicate(scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ + newbase= ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ newob= newbase->object; newbase->flag &= ~SELECT; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index d38c91da5c5..16204e9f199 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1119,6 +1119,7 @@ void CU_select_swap(Object *obedit) static int separate_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Nurb *nu, *nu1; Object *oldob, *newob; @@ -1139,7 +1140,7 @@ static int separate_exec(bContext *C, wmOperator *op) WM_cursor_wait(1); /* 1. duplicate the object and data */ - newbase= ED_object_add_duplicate(scene, oldbase, 0); /* 0 = fully linked */ + newbase= ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */ ED_base_object_select(newbase, BA_DESELECT); newob= newbase->object; @@ -5543,6 +5544,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) int join_curve_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); Curve *cu; @@ -5594,7 +5596,7 @@ int join_curve_exec(bContext *C, wmOperator *op) } } - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(bmain, scene, base); } } } @@ -5603,7 +5605,7 @@ int join_curve_exec(bContext *C, wmOperator *op) cu= ob->data; addlisttolist(&cu->nurb, &tempbase); - DAG_scene_sort(scene); // because we removed object(s), call before editmode! + DAG_scene_sort(bmain, scene); // because we removed object(s), call before editmode! ED_object_enter_editmode(C, EM_WAITCURSOR); ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index efa5d6c5dad..f243b4cc497 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -28,24 +28,25 @@ #ifndef ED_OBJECT_H #define ED_OBJECT_H -struct wmKeyConfig; -struct wmKeyMap; -struct Scene; -struct Object; -struct bContext; struct Base; -struct View3D; struct bConstraint; +struct bContext; struct bPoseChannel; +struct Curve; struct KeyBlock; struct Lattice; +struct Main; struct Mesh; -struct Curve; -struct ReportList; struct ModifierData; -struct wmOperatorType; -struct wmOperator; +struct Object; +struct ReportList; +struct Scene; +struct View3D; struct wmEvent; +struct wmKeyConfig; +struct wmKeyMap; +struct wmOperator; +struct wmOperatorType; /* object_edit.c */ struct Object *ED_object_active_context(struct bContext *C); @@ -69,10 +70,10 @@ void ED_base_object_select(struct Base *base, short mode); /* includes notifier */ void ED_base_object_activate(struct bContext *C, struct Base *base); -void ED_base_object_free_and_unlink(struct Scene *scene, struct Base *base); +void ED_base_object_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Base *base); /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */ -struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int dupflag); +struct Base *ED_object_add_duplicate(struct Main *bmain, struct Scene *scene, struct Base *base, int dupflag); void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr); @@ -97,7 +98,7 @@ int ED_object_add_generic_invoke(struct bContext *C, struct wmOperator *op, stru int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, float *loc, float *rot, int *enter_editmode, unsigned int *layer); struct Object *ED_object_add_type(struct bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer); -void ED_object_single_users(struct Scene *scene, int full); +void ED_object_single_users(struct Main *bmain, struct Scene *scene, int full); /* cleanup */ int object_is_libdata(struct Object *ob); @@ -116,7 +117,7 @@ void object_test_constraints(struct Object *ob); void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con); void ED_object_constraint_update(struct Object *ob); -void ED_object_constraint_dependency_update(struct Scene *scene, struct Object *ob); +void ED_object_constraint_dependency_update(struct Main *bmain, struct Scene *scene, struct Object *ob); /* object_lattice.c */ int mouse_lattice(struct bContext *C, short mval[2], int extend); @@ -132,11 +133,11 @@ enum { MODIFIER_APPLY_SHAPE, } eModifier_Apply_Mode; -struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, char *name, int type); -int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md); +struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, char *name, int type); +int ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md); int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md); int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md); -int ED_object_modifier_convert(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md); +int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md); int ED_object_modifier_apply(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md, int mode); int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1b600a26001..3d32030326f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -961,6 +961,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr, int void do_constraint_panels(bContext *C, void *arg, int event) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -972,7 +973,7 @@ void do_constraint_panels(bContext *C, void *arg, int event) break; // no handling case B_CONSTRAINT_CHANGETARGET: if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); break; default: break; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 3f943f7b1b0..4b02e4b1e65 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -979,6 +979,7 @@ void UI_make_axis_color(char *src_col, char *dst_col, char axis) /* patching UserDef struct and Themes */ void init_userdef_do_versions(void) { + Main *bmain= G.main; // countall(); /* the UserDef struct is not corrected with do_versions() .... ugh! */ @@ -1013,18 +1014,18 @@ void init_userdef_do_versions(void) if(U.flag & USER_CUSTOM_RANGE) vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */ - if (G.main->versionfile <= 191) { + if (bmain->versionfile <= 191) { strcpy(U.plugtexdir, U.textudir); strcpy(U.sounddir, "/"); } /* patch to set Dupli Armature */ - if (G.main->versionfile < 220) { + if (bmain->versionfile < 220) { U.dupflag |= USER_DUP_ARM; } /* added seam, normal color, undo */ - if (G.main->versionfile <= 234) { + if (bmain->versionfile <= 234) { bTheme *btheme; U.uiflag |= USER_GLOBALUNDO; @@ -1047,12 +1048,12 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 235) { + if (bmain->versionfile <= 235) { /* illegal combo... */ if (U.flag & USER_LMOUSESELECT) U.flag &= ~USER_TWOBUTTONMOUSE; } - if (G.main->versionfile <= 236) { + if (bmain->versionfile <= 236) { bTheme *btheme; /* new space type */ for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1069,7 +1070,7 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 237) { + if (bmain->versionfile <= 237) { bTheme *btheme; /* bone colors */ for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1080,7 +1081,7 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 238) { + if (bmain->versionfile <= 238) { bTheme *btheme; /* bone colors */ for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1091,7 +1092,7 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 239) { + if (bmain->versionfile <= 239) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1105,7 +1106,7 @@ void init_userdef_do_versions(void) } if(U.obcenter_dia==0) U.obcenter_dia= 6; } - if (G.main->versionfile <= 241) { + if (bmain->versionfile <= 241) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { /* Node editor theme, check for alpha==0 is safe, then color was never set */ @@ -1146,7 +1147,7 @@ void init_userdef_do_versions(void) } } - if (G.main->versionfile <= 242) { + if (bmain->versionfile <= 242) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1164,11 +1165,11 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 243) { + if (bmain->versionfile <= 243) { /* set default number of recently-used files (if not set) */ if (U.recent_files == 0) U.recent_files = 10; } - if (G.main->versionfile < 245 || (G.main->versionfile == 245 && G.main->subversionfile < 3)) { + if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128); @@ -1176,7 +1177,7 @@ void init_userdef_do_versions(void) if(U.coba_weight.tot==0) init_colorband(&U.coba_weight, 1); } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) { bTheme *btheme; for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* these should all use the same colour */ @@ -1189,7 +1190,7 @@ void init_userdef_do_versions(void) SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255); } } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 13)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) { bTheme *btheme; for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* action channel groups (recolor anyway) */ @@ -1262,10 +1263,10 @@ void init_userdef_do_versions(void) } } } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 16)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) { U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE; } - if ((G.main->versionfile < 247) || (G.main->versionfile == 247 && G.main->subversionfile <= 2)) { + if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) { bTheme *btheme; /* adjust themes */ @@ -1287,7 +1288,7 @@ void init_userdef_do_versions(void) SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255); } } - if (G.main->versionfile < 250) { + if (bmain->versionfile < 250) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1328,7 +1329,7 @@ void init_userdef_do_versions(void) U.ipo_new= BEZT_IPO_BEZ; } - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 1)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1351,7 +1352,7 @@ void init_userdef_do_versions(void) } } - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 3)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) { /* new audio system */ if(U.audiochannels == 0) U.audiochannels = 2; @@ -1369,10 +1370,10 @@ void init_userdef_do_versions(void) U.audiorate = 44100; } - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 5)) + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5)) U.gameflags |= USER_DISABLE_VBO; - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 8)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) { wmKeyMap *km; for(km=U.keymaps.first; km; km=km->next) { @@ -1412,16 +1413,16 @@ void init_userdef_do_versions(void) strcpy(km->idname, "Property Editor"); } } - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 16)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) { if(U.wmdrawmethod == USER_DRAW_TRIPLE) U.wmdrawmethod = USER_DRAW_AUTOMATIC; } - if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 3)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) { if (U.flag & USER_LMOUSESELECT) U.flag &= ~USER_TWOBUTTONMOUSE; } - if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 4)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) { bTheme *btheme; /* default new handle type is auto handles */ @@ -1454,7 +1455,7 @@ void init_userdef_do_versions(void) SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0); } } - if (G.main->versionfile <= 252) { + if (bmain->versionfile <= 252) { bTheme *btheme; /* init new curve colors */ @@ -1463,7 +1464,7 @@ void init_userdef_do_versions(void) SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); } } - if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 5)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) { bTheme *btheme; /* interface_widgets.c */ diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index cdcbb5cb461..a63f4995acc 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1330,7 +1330,7 @@ static EnumPropertyItem prop_separate_types[] = { }; /* return 1: success */ -static int mesh_separate_selected(Scene *scene, Base *editbase) +static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase) { EditMesh *em, *emnew; EditVert *eve, *v1; @@ -1372,7 +1372,7 @@ static int mesh_separate_selected(Scene *scene, Base *editbase) */ /* 1 */ - basenew= ED_object_add_duplicate(scene, editbase, 0); /* 0 = fully linked */ + basenew= ED_object_add_duplicate(bmain, scene, editbase, 0); /* 0 = fully linked */ ED_base_object_select(basenew, BA_DESELECT); /* 2 */ @@ -1441,7 +1441,7 @@ static int mesh_separate_selected(Scene *scene, Base *editbase) } /* return 1: success */ -static int mesh_separate_material(Scene *scene, Base *editbase) +static int mesh_separate_material(Main *bmain, Scene *scene, Base *editbase) { Mesh *me= editbase->object->data; EditMesh *em= BKE_mesh_get_editmesh(me); @@ -1453,7 +1453,7 @@ static int mesh_separate_material(Scene *scene, Base *editbase) /* select the material */ EM_select_by_material(em, curr_mat); /* and now separate */ - if(0==mesh_separate_selected(scene, editbase)) { + if(0==mesh_separate_selected(bmain, scene, editbase)) { BKE_mesh_end_editmesh(me, em); return 0; } @@ -1464,7 +1464,7 @@ static int mesh_separate_material(Scene *scene, Base *editbase) } /* return 1: success */ -static int mesh_separate_loose(Scene *scene, Base *editbase) +static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase) { Mesh *me; EditMesh *em; @@ -1504,7 +1504,7 @@ static int mesh_separate_loose(Scene *scene, Base *editbase) tot= BLI_countlist(&em->verts); /* and now separate */ - doit= mesh_separate_selected(scene, editbase); + doit= mesh_separate_selected(bmain, scene, editbase); /* with hidden verts this can happen */ if(tot == BLI_countlist(&em->verts)) @@ -1518,16 +1518,17 @@ static int mesh_separate_loose(Scene *scene, Base *editbase) static int mesh_separate_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Base *base= CTX_data_active_base(C); int retval= 0, type= RNA_enum_get(op->ptr, "type"); if(type == 0) - retval= mesh_separate_selected(scene, base); + retval= mesh_separate_selected(bmain, scene, base); else if(type == 1) - retval= mesh_separate_material (scene, base); + retval= mesh_separate_material(bmain, scene, base); else if(type == 2) - retval= mesh_separate_loose(scene, base); + retval= mesh_separate_loose(bmain, scene, base); if(retval) { WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 87b5c886b4a..47b7b89ff7a 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -92,6 +92,7 @@ return 0 if no join is made (error) and 1 of the join is done */ int join_mesh_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); Material **matar, *ma; @@ -443,7 +444,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* free base, now that data is merged */ if(base->object != ob) - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(bmain, scene, base); } } CTX_DATA_END; @@ -503,17 +504,17 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ if(nkey->ipo) { free_ipo(nkey->ipo); - BLI_remlink(&G.main->ipo, nkey->ipo); + BLI_remlink(&bmain->ipo, nkey->ipo); MEM_freeN(nkey->ipo); } #endif free_key(nkey); - BLI_remlink(&G.main->key, nkey); + BLI_remlink(&bmain->key, nkey); MEM_freeN(nkey); } - DAG_scene_sort(scene); // removed objects, need to rebuild dag before editmode call + DAG_scene_sort(bmain, scene); // removed objects, need to rebuild dag before editmode call ED_object_enter_editmode(C, EM_WAITCURSOR); ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 50851b57a65..67cae8d4155 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -284,6 +284,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa /* for object add primitive operators */ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob; @@ -300,8 +301,8 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int en /* more editor stuff */ ED_object_base_init_transform(C, BASACT, loc, rot); - DAG_scene_sort(scene); - ED_render_id_flush_update(G.main, ob->data); + DAG_scene_sort(bmain, scene); + ED_render_id_flush_update(bmain, ob->data); if(enter_editmode) ED_object_enter_editmode(C, EM_IGNORE_LAYER); @@ -750,6 +751,8 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; if(group) { + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); Object *ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); rename_id(&ob->id, group->id.name+2); ob->dup_group= group; @@ -757,7 +760,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) id_lib_extern(&group->id); /* works without this except if you try render right after, see: 22027 */ - DAG_scene_sort(CTX_data_scene(C)); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C)); @@ -797,16 +800,17 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) /* remove base from a specific scene */ /* note: now unlinks constraints as well */ -void ED_base_object_free_and_unlink(Scene *scene, Base *base) +void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base) { BLI_remlink(&scene->base, base); - free_libblock_us(&G.main->object, base->object); + free_libblock_us(&bmain->object, base->object); if(scene->basact==base) scene->basact= NULL; MEM_freeN(base); } static int object_delete_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); int islamp= 0; @@ -817,14 +821,14 @@ static int object_delete_exec(bContext *C, wmOperator *op) if(base->object->type==OB_LAMP) islamp= 1; /* remove from current scene only */ - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(bmain, scene, base); } CTX_DATA_END; if(islamp) reshadeall_displist(scene); /* only frees displist */ - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C)); @@ -859,6 +863,7 @@ static void copy_object__forwardModifierLinks(void *userData, Object *ob, /* after copying objects, copied data should get new pointers */ static void copy_object_set_idnew(bContext *C, int dupflag) { + Main *bmain= CTX_data_main(C); Material *ma, *mao; ID *id; int a; @@ -881,7 +886,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /* materials */ if( dupflag & USER_DUP_MAT) { - mao= G.main->mat.first; + mao= bmain->mat.first; while(mao) { if(mao->id.newid) { @@ -915,7 +920,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) #if 0 // XXX old animation system /* lamps */ if( dupflag & USER_DUP_IPO) { - Lamp *la= G.main->lamp.first; + Lamp *la= bmain->lamp.first; while(la) { if(la->id.newid) { Lamp *lan= (Lamp *)la->id.newid; @@ -931,7 +936,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) } /* ipos */ - ipo= G.main->ipo.first; + ipo= bmain->ipo.first; while(ipo) { if(ipo->id.lib==NULL && ipo->id.newid) { Ipo *ipon= (Ipo *)ipo->id.newid; @@ -1000,6 +1005,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base) static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); clear_id_newpoins(); @@ -1009,8 +1015,8 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); WM_main_add_notifier(NC_OBJECT|ND_DRAW, NULL); @@ -1089,6 +1095,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) static int convert_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Base *basen=NULL, *basact=NULL, *basedel=NULL; Object *ob, *ob1, *newob, *obact= CTX_data_active_object(C); @@ -1214,7 +1221,7 @@ static int convert_exec(bContext *C, wmOperator *op) if (!keep_original) { /* other users */ if(cu->id.us>1) { - for(ob1= G.main->object.first; ob1; ob1=ob1->id.next) { + for(ob1= bmain->object.first; ob1; ob1=ob1->id.next) { if(ob1->data==ob->data) { ob1->type= OB_CURVE; ob1->recalc |= OB_RECALC_ALL; @@ -1321,7 +1328,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* delete original if needed */ if(basedel) { if(!keep_original) - ED_base_object_free_and_unlink(scene, basedel); + ED_base_object_free_and_unlink(bmain, scene, basedel); basedel = NULL; } @@ -1337,13 +1344,13 @@ static int convert_exec(bContext *C, wmOperator *op) base= base->next; if (ob->type == OB_MBALL) { - ED_base_object_free_and_unlink(scene, tmpbase); + ED_base_object_free_and_unlink(bmain, scene, tmpbase); } } } /* delete object should renew depsgraph */ - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } // XXX ED_object_enter_editmode(C, 0); @@ -1357,7 +1364,7 @@ static int convert_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER|ND_DATA, BASACT->object); } - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */ return OPERATOR_FINISHED; @@ -1394,7 +1401,7 @@ void OBJECT_OT_convert(wmOperatorType *ot) /* used below, assumes id.new is correct */ /* leaves selection of base/object unaltered */ -static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag) +static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base, int dupflag) { Base *basen= NULL; Material ***matarar; @@ -1417,7 +1424,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag if(basen->flag & OB_FROMGROUP) { Group *group; - for(group= G.main->group.first; group; group= group->id.next) { + for(group= bmain->group.first; group; group= group->id.next) { if(object_in_group(ob, group)) add_to_group(group, obn, scene, basen); } @@ -1596,7 +1603,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */ /* leaves selection of base/object unaltered */ -Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag) +Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag) { Base *basen; Object *ob; @@ -1604,15 +1611,15 @@ Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag) clear_id_newpoins(); clear_sca_new_poins(); /* sensor/contr/act */ - basen= object_add_duplicate_internal(scene, base, dupflag); + basen= object_add_duplicate_internal(bmain, scene, base, dupflag); if (basen == NULL) { return NULL; } ob= basen->object; - DAG_scene_sort(scene); - ED_render_id_flush_update(G.main, ob->data); + DAG_scene_sort(bmain, scene); + ED_render_id_flush_update(bmain, ob->data); return basen; } @@ -1620,6 +1627,7 @@ Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag) /* contextual operator dupli */ static int duplicate_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); int linked= RNA_boolean_get(op->ptr, "linked"); int dupflag= (linked)? 0: U.dupflag; @@ -1628,7 +1636,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) clear_sca_new_poins(); /* sensor/contr/act */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { - Base *basen= object_add_duplicate_internal(scene, base, dupflag); + Base *basen= object_add_duplicate_internal(bmain, scene, base, dupflag); /* note that this is safe to do with this context iterator, the list is made in advance */ @@ -1642,14 +1650,14 @@ static int duplicate_exec(bContext *C, wmOperator *op) if(BASACT==base) ED_base_object_activate(C, basen); - ED_render_id_flush_update(G.main, basen->object->data); + ED_render_id_flush_update(bmain, basen->object->data); } CTX_DATA_END; copy_object_set_idnew(C, dupflag); - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); @@ -1697,6 +1705,7 @@ static int add_named_poll(bContext *C) static int add_named_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Base *basen, *base; Object *ob; @@ -1718,7 +1727,7 @@ static int add_named_exec(bContext *C, wmOperator *op) clear_id_newpoins(); clear_sca_new_poins(); /* sensor/contr/act */ - basen= object_add_duplicate_internal(scene, base, dupflag); + basen= object_add_duplicate_internal(bmain, scene, base, dupflag); if (basen == NULL) { MEM_freeN(base); @@ -1732,8 +1741,8 @@ static int add_named_exec(bContext *C, wmOperator *op) copy_object_set_idnew(C, dupflag); - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); MEM_freeN(base); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index b1dc41531ef..8f83a412c96 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -779,12 +779,12 @@ void ED_object_constraint_update(Object *ob) else DAG_id_flush_update(&ob->id, OB_RECALC_OB); } -void ED_object_constraint_dependency_update(Scene *scene, Object *ob) +void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *ob) { ED_object_constraint_update(ob); if(ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } static int constraint_poll(bContext *C) @@ -931,8 +931,9 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) static int pose_constraints_clear_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); /* free constraints for all selected bones */ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) @@ -943,7 +944,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since relationships removed */ - DAG_scene_sort(scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ /* do updates */ DAG_id_flush_update(&ob->id, OB_RECALC_DATA); @@ -967,6 +968,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) static int object_constraints_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); /* do freeing */ @@ -978,7 +980,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since relationships removed */ - DAG_scene_sort(scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ /* do updates */ WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); @@ -1002,8 +1004,9 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) static int pose_constraint_copy_exec(bContext *C, wmOperator *op) { - bPoseChannel *pchan = CTX_data_active_pose_bone(C); + Main *bmain= CTX_data_main(C); Scene *scene = CTX_data_scene(C); + bPoseChannel *pchan = CTX_data_active_pose_bone(C); /* don't do anything if bone doesn't exist or doesn't have any constraints */ if (ELEM(NULL, pchan, pchan->constraints.first)) { @@ -1021,7 +1024,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(scene); /* sort order of objects/bones */ + DAG_scene_sort(bmain, scene); /* sort order of objects/bones */ return OPERATOR_FINISHED; } @@ -1043,8 +1046,9 @@ void POSE_OT_constraints_copy(wmOperatorType *ot) static int object_constraint_copy_exec(bContext *C, wmOperator *op) { - Object *obact = ED_object_active_context(C); + Main *bmain= CTX_data_main(C); Scene *scene = CTX_data_scene(C); + Object *obact = ED_object_active_context(C); /* copy all constraints from active object to all selected objects */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) @@ -1056,7 +1060,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ return OPERATOR_FINISHED; } @@ -1219,6 +1223,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o /* used by add constraint operators to add the constraint required */ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase *list, int type, short setTarget) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); bPoseChannel *pchan; bConstraint *con; @@ -1316,7 +1321,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ if ((ob->type==OB_ARMATURE) && (pchan)) { ob->pose->flag |= POSE_RECALC; /* sort pose channels */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0d3ebc7f669..18da264336e 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -137,6 +137,7 @@ Object *ED_object_active_context(bContext *C) /* ********* clear/set restrict view *********/ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; Scene *scene= CTX_data_scene(C); @@ -153,7 +154,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) } } if (changed) { - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } @@ -178,6 +179,7 @@ void OBJECT_OT_hide_view_clear(wmOperatorType *ot) static int object_hide_view_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); short changed = 0; int unselected= RNA_boolean_get(op->ptr, "unselected"); @@ -204,7 +206,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; if (changed) { - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); @@ -965,144 +967,6 @@ void special_editmenu(Scene *scene, View3D *v3d) } -/* Change subdivision or particle properties of mesh object ob, if level==-1 - * then toggle subsurf, else set to level set allows to toggle multiple - * selections */ - -static void object_has_subdivision_particles(Object *ob, int *havesubdiv, int *havepart, int depth) -{ - if(ob->type==OB_MESH) { - if(modifiers_findByType(ob, eModifierType_Subsurf)) - *havesubdiv= 1; - if(modifiers_findByType(ob, eModifierType_ParticleSystem)) - *havepart= 1; - } - - if(ob->dup_group && depth <= 4) { - GroupObject *go; - - for(go= ob->dup_group->gobject.first; go; go= go->next) - object_has_subdivision_particles(go->ob, havesubdiv, havepart, depth+1); - } -} - -static void object_flip_subdivison_particles(Scene *scene, Object *ob, int *set, int level, int mode, int particles, int depth) -{ - ModifierData *md; - - if(ob->type==OB_MESH) { - if(particles) { - for(md=ob->modifiers.first; md; md=md->next) { - if(md->type == eModifierType_ParticleSystem) { - ParticleSystemModifierData *psmd = (ParticleSystemModifierData*)md; - - if(*set == -1) - *set= psmd->modifier.mode&(mode); - - if (*set) - psmd->modifier.mode &= ~(mode); - else - psmd->modifier.mode |= (mode); - } - } - } - else { - md = modifiers_findByType(ob, eModifierType_Subsurf); - - if (md) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - - if (level == -1) { - if(*set == -1) - *set= smd->modifier.mode&(mode); - - if (*set) - smd->modifier.mode &= ~(mode); - else - smd->modifier.mode |= (mode); - } else { - smd->levels = level; - } - } - else if(depth == 0 && *set != 0) { - SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf); - - BLI_addtail(&ob->modifiers, smd); - modifier_unique_name(&ob->modifiers, (ModifierData*)smd); - - if (level!=-1) { - smd->levels = level; - } - - if(*set == -1) - *set= 1; - } - } - - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - } - - if(ob->dup_group && depth<=4) { - GroupObject *go; - - for(go= ob->dup_group->gobject.first; go; go= go->next) - object_flip_subdivison_particles(scene, go->ob, set, level, mode, particles, depth+1); - } -} - -/* Change subdivision properties of mesh object ob, if -* level==-1 then toggle subsurf, else set to level. -*/ - -void flip_subdivison(Scene *scene, View3D *v3d, int level) -{ - Base *base; - int set= -1; - int mode, pupmode, particles= 0, havesubdiv= 0, havepart= 0; - int alt= 0; // XXX - - if(alt) - mode= eModifierMode_Realtime; - else - mode= eModifierMode_Render|eModifierMode_Realtime; - - if(level == -1) { - if (scene->obedit) { // XXX get from context - object_has_subdivision_particles(scene->obedit, &havesubdiv, &havepart, 0); - } else { - for(base= scene->base.first; base; base= base->next) { - if(((level==-1) && (TESTBASE(v3d, base))) || (TESTBASELIB(v3d, base))) { - object_has_subdivision_particles(base->object, &havesubdiv, &havepart, 0); - } - } - } - } - else - havesubdiv= 1; - - if(havesubdiv && havepart) { - pupmode= pupmenu("Switch%t|Subsurf %x1|Particle Systems %x2"); - if(pupmode <= 0) - return; - else if(pupmode == 2) - particles= 1; - } - else if(havepart) - particles= 1; - - if (scene->obedit) { // XXX get from context - object_flip_subdivison_particles(scene, scene->obedit, &set, level, mode, particles, 0); - } else { - for(base= scene->base.first; base; base= base->next) { - if(((level==-1) && (TESTBASE(v3d, base))) || (TESTBASELIB(v3d, base))) { - object_flip_subdivison_particles(scene, base->object, &set, level, mode, particles, 0); - } - } - } - - DAG_ids_flush_update(0); -} - static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) { //XXX no longer used - to be removed - replaced by game_properties_copy_exec @@ -1197,7 +1061,7 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob) } } -static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob) +static void copymenu_modifiers(Main *bmain, Scene *scene, View3D *v3d, Object *ob) { Base *base; int i, event; @@ -1296,7 +1160,7 @@ static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob) // if(errorstr) notice(errorstr); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } @@ -1344,7 +1208,7 @@ static void copy_texture_space(Object *to, Object *ob) } -void copy_attr(Scene *scene, View3D *v3d, short event) +void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) { Object *ob; Base *base; @@ -1369,7 +1233,7 @@ void copy_attr(Scene *scene, View3D *v3d, short event) return; } else if(event==24) { - copymenu_modifiers(scene, v3d, ob); + copymenu_modifiers(bmain, scene, v3d, ob); return; } @@ -1587,12 +1451,12 @@ void copy_attr(Scene *scene, View3D *v3d, short event) } if(do_scene_sort) - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); } -void copy_attr_menu(Scene *scene, View3D *v3d) +void copy_attr_menu(Main *bmain, Scene *scene, View3D *v3d) { Object *ob; short event; @@ -1643,7 +1507,7 @@ void copy_attr_menu(Scene *scene, View3D *v3d) event= pupmenu(str); if(event<= 0) return; - copy_attr(scene, v3d, event); + copy_attr(bmain, scene, v3d, event); } /* ********************************************** */ diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index ba609bd9bb3..b0a6c6471a2 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -60,6 +60,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= OBACT; Group *group; @@ -70,7 +71,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) /* linking to same group requires its own loop so we can avoid looking up the active objects groups each time */ - for(group= G.main->group.first; group; group=group->id.next) { + for(group= bmain->group.first; group; group=group->id.next) { if(object_in_group(ob, group)) { /* Assign groups to selected objects */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { @@ -83,7 +84,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -106,6 +107,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot) static int objects_remove_active_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= OBACT; Group *group; @@ -116,7 +118,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) /* linking to same group requires its own loop so we can avoid looking up the active objects groups each time */ - for(group= G.main->group.first; group; group=group->id.next) { + for(group= bmain->group.first; group; group=group->id.next) { if(object_in_group(ob, group)) { /* Assign groups to selected objects */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { @@ -129,7 +131,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -152,6 +154,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) static int group_objects_remove_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Group *group= NULL; @@ -162,7 +165,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -185,6 +188,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot) static int group_create_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Group *group= NULL; char name[32]; /* id name */ @@ -198,7 +202,7 @@ static int group_create_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 88e463039a1..fefefae586c 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -45,6 +45,7 @@ #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -413,7 +414,7 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit) return ob; } -static void add_hook_object(Scene *scene, Object *obedit, Object *ob, int mode) +static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob, int mode) { ModifierData *md=NULL; HookModifierData *hmd = NULL; @@ -459,11 +460,12 @@ static void add_hook_object(Scene *scene, Object *obedit, Object *ob, int mode) mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL, NULL, NULL, NULL, NULL, NULL); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } static int object_add_hook_selob_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); Object *obsel=NULL; @@ -482,7 +484,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - add_hook_object(scene, obedit, obsel, OBJECT_ADDHOOK_SELOB); + add_hook_object(bmain, scene, obedit, obsel, OBJECT_ADDHOOK_SELOB); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit); return OPERATOR_FINISHED; @@ -505,10 +507,11 @@ void OBJECT_OT_hook_add_selobj(wmOperatorType *ot) static int object_add_hook_newob_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); - add_hook_object(scene, obedit, NULL, OBJECT_ADDHOOK_NEWOB); + add_hook_object(bmain, scene, obedit, NULL, OBJECT_ADDHOOK_NEWOB); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 0661b675668..a54ed9bd239 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -53,6 +53,7 @@ #include "BKE_global.h" #include "BKE_key.h" #include "BKE_lattice.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" @@ -77,7 +78,7 @@ /******************************** API ****************************/ -ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, char *name, int type) +ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, char *name, int type) { ModifierData *md=NULL, *new_md=NULL; ModifierTypeInfo *mti = modifierType_getInfo(type); @@ -129,10 +130,10 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object * ob->pd= object_add_collision_fields(0); ob->pd->deflect= 1; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } else if(type == eModifierType_Surface) - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } DAG_id_flush_update(&ob->id, OB_RECALC_DATA); @@ -140,7 +141,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object * return new_md; } -int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) +int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) { ModifierData *obmd; @@ -175,13 +176,13 @@ int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, Mod if(ob->pd) ob->pd->deflect= 0; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } else if(md->type == eModifierType_Surface) { if(ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) ob->pd->shape = PFIELD_SHAPE_PLANE; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } else if(md->type == eModifierType_Smoke) { ob->dt = OB_TEXTURE; @@ -243,7 +244,7 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData * return 1; } -int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) +int ED_object_modifier_convert(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) { Object *obn; ParticleSystem *psys; @@ -341,7 +342,7 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo } } - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); return 1; } @@ -500,11 +501,12 @@ int ED_object_modifier_copy(ReportList *reports, Object *ob, ModifierData *md) static int modifier_add_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); int type= RNA_enum_get(op->ptr, "type"); - if(!ED_object_modifier_add(op->reports, scene, ob, NULL, type)) + if(!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); @@ -626,11 +628,12 @@ static ModifierData *edit_modifier_property_get(bContext *C, wmOperator *op, Obj static int modifier_remove_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(C, op, ob, 0); - if(!ob || !md || !ED_object_modifier_remove(op->reports, scene, ob, md)) + if(!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); @@ -792,11 +795,12 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) static int modifier_convert_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(C, op, ob, 0); - if(!ob || !md || !ED_object_modifier_convert(op->reports, scene, ob, md)) + if(!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; DAG_id_flush_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 8d488eeabac..463db871f55 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -97,6 +97,7 @@ static int vertex_parent_set_poll(bContext *C) static int vertex_parent_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); EditVert *eve; @@ -230,7 +231,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_OBJECT, NULL); @@ -295,6 +296,7 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) static int make_proxy_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Object *ob, *gob= CTX_data_active_object(C); GroupObject *go; Scene *scene= CTX_data_scene(C); @@ -338,7 +340,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op) object_make_proxy(newob, ob, gob); /* depsgraph flushes are needed for the new data */ - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&newob->id, OB_RECALC_ALL); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob); } @@ -413,6 +415,8 @@ static EnumPropertyItem prop_clear_parent_types[] = { /* note, poll should check for editable scene */ static int parent_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); int type= RNA_enum_get(op->ptr, "type"); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { @@ -431,8 +435,8 @@ static int parent_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(CTX_data_scene(C)); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -517,6 +521,7 @@ void ED_object_parent(Object *ob, Object *par, int type, const char *substr) static int parent_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *par= CTX_data_active_object(C); bPoseChannel *pchan= NULL; @@ -594,15 +599,15 @@ static int parent_set_exec(bContext *C, wmOperator *op) switch (partype) { case PAR_CURVE: /* curve deform */ - md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Curve); + md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Curve); ((CurveModifierData *)md)->object= par; break; case PAR_LATTICE: /* lattice deform */ - md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Lattice); + md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Lattice); ((LatticeModifierData *)md)->object= par; break; default: /* armature deform */ - md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Armature); + md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Armature); ((ArmatureModifierData *)md)->object= par; break; } @@ -657,8 +662,8 @@ static int parent_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -719,6 +724,7 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) static int parent_noinv_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Object *par= CTX_data_active_object(C); par->recalc |= OB_RECALC_OB; @@ -745,8 +751,8 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(CTX_data_scene(C)); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, CTX_data_scene(C)); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -772,6 +778,7 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot) static int object_slow_parent_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { @@ -786,7 +793,7 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); return OPERATOR_FINISHED; @@ -813,6 +820,7 @@ void OBJECT_OT_slow_parent_clear(wmOperatorType *ot) static int object_slow_parent_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { @@ -824,7 +832,7 @@ static int object_slow_parent_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); return OPERATOR_FINISHED; @@ -858,6 +866,8 @@ static EnumPropertyItem prop_clear_track_types[] = { /* note, poll should check for editable scene */ static int object_track_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); int type= RNA_enum_get(op->ptr, "type"); if(CTX_data_edit_object(C)) { @@ -883,8 +893,8 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); - DAG_scene_sort(CTX_data_scene(C)); + DAG_ids_flush_update(bmain, 0); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -920,6 +930,7 @@ static EnumPropertyItem prop_make_track_types[] = { static int track_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obact= CTX_data_active_object(C); @@ -987,8 +998,8 @@ static int track_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; } - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -1057,6 +1068,7 @@ static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event) static int move_to_layer_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); unsigned int lay, local; @@ -1097,7 +1109,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) /* warning, active object may be hidden now */ WM_event_add_notifier(C, NC_SCENE|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */ - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); return OPERATOR_FINISHED; } @@ -1123,10 +1135,10 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot) /************************** Link to Scene Operator *****************************/ -void link_to_scene(unsigned short nr) +void link_to_scene(Main *bmain, unsigned short nr) { #if 0 - Scene *sce= (Scene*) BLI_findlink(&G.main->scene, G.curscreen->scenenr-1); + Scene *sce= (Scene*) BLI_findlink(&bmain->scene, G.curscreen->scenenr-1); Base *base, *nbase; if(sce==0) return; @@ -1146,6 +1158,7 @@ void link_to_scene(unsigned short nr) static int make_links_scene_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); if(scene_to==NULL) { @@ -1174,7 +1187,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* one day multiple scenes will be visible, then we should have some update function for them */ return OPERATOR_FINISHED; @@ -1214,6 +1227,7 @@ static int allow_make_links_data(int ev, Object *ob, Object *obt) static int make_links_data_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); int event = RNA_int_get(op->ptr, "type"); Object *ob; ID *id; @@ -1266,7 +1280,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; } @@ -1396,7 +1410,7 @@ void new_id_matar(Material **matar, int totcol) } } -void single_obdata_users(Scene *scene, int flag) +void single_obdata_users(Main *bmain, Scene *scene, int flag) { Object *ob; Lamp *la; @@ -1512,7 +1526,7 @@ void single_obdata_users(Scene *scene, int flag) } } - me= G.main->mesh.first; + me= bmain->mesh.first; while(me) { ID_NEW(me->texcomesh); me= me->id.next; @@ -1610,10 +1624,9 @@ void do_single_tex_user(Tex **from) } } -void single_tex_users_expand() +void single_tex_users_expand(Main *bmain) { /* only when 'parent' blocks are LIB_NEW */ - Main *bmain= G.main; Material *ma; Lamp *la; World *wo; @@ -1650,10 +1663,9 @@ void single_tex_users_expand() } } -static void single_mat_users_expand(void) +static void single_mat_users_expand(Main *bmain) { /* only when 'parent' blocks are LIB_NEW */ - Main *bmain= G.main; Object *ob; Mesh *me; Curve *cu; @@ -1686,14 +1698,14 @@ static void single_mat_users_expand(void) } /* used for copying scenes */ -void ED_object_single_users(Scene *scene, int full) +void ED_object_single_users(Main *bmain, Scene *scene, int full) { single_object_users(scene, NULL, 0); if(full) { - single_obdata_users(scene, 0); - single_mat_users_expand(); - single_tex_users_expand(); + single_obdata_users(bmain, scene, 0); + single_mat_users_expand(bmain); + single_tex_users_expand(bmain); } clear_id_newpoins(); @@ -1828,6 +1840,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot) static int make_single_user_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); /* ok if this is NULL */ int flag= RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */ @@ -1836,7 +1849,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op) single_object_users(scene, v3d, flag); if(RNA_boolean_get(op->ptr, "obdata")) - single_obdata_users(scene, flag); + single_obdata_users(bmain, scene, flag); if(RNA_boolean_get(op->ptr, "material")) single_mat_users(scene, flag, FALSE); @@ -1885,6 +1898,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *event) { + Main *bmain= CTX_data_main(C); Base *base= ED_view3d_give_base_under_cursor(C, event->mval); Material *ma; char name[32]; @@ -1896,7 +1910,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even assign_material(base->object, ma, 1); - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index bd23d3a4b67..d7961a8cd2b 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -68,6 +68,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Location"); @@ -102,7 +103,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* this is needed so children are also updated */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -126,6 +127,7 @@ void OBJECT_OT_location_clear(wmOperatorType *ot) static int object_rotation_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Rotation"); @@ -244,7 +246,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* this is needed so children are also updated */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -268,6 +270,7 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot) static int object_scale_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Scaling"); @@ -307,7 +310,7 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* this is needed so children are also updated */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -331,6 +334,7 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot) static int object_origin_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); float *v1, *v3, mat[3][3]; int armature_clear= 0; @@ -348,7 +352,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; if(armature_clear==0) /* in this case flush was done */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -767,7 +771,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - for (tob= G.main->object.first; tob; tob= tob->id.next) { + for (tob= bmain->object.first; tob; tob= tob->id.next) { if(tob->data) ((ID *)tob->data)->flag &= ~LIB_DOIT; } @@ -921,14 +925,14 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - for (tob= G.main->object.first; tob; tob= tob->id.next) { + for (tob= bmain->object.first; tob; tob= tob->id.next) { if(tob->data && (((ID *)tob->data)->flag & LIB_DOIT)) { tob->recalc= OB_RECALC_OB|OB_RECALC_DATA; } } if (tot_change) { - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); } diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index 37de0d8f873..a18890881a8 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -35,6 +35,7 @@ #include "BKE_boids.h" #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "BKE_particle.h" #include "BLI_listbase.h" @@ -99,6 +100,7 @@ void BOID_OT_rule_add(wmOperatorType *ot) } static int rule_del_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; @@ -125,7 +127,7 @@ static int rule_del_exec(bContext *C, wmOperator *op) if(rule) rule->flag |= BOIDRULE_CURRENT; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -266,6 +268,7 @@ void BOID_OT_state_add(wmOperatorType *ot) } static int state_del_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; @@ -297,7 +300,7 @@ static int state_del_exec(bContext *C, wmOperator *op) state->flag |= BOIDSTATE_CURRENT; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 059805fdf2d..ba5d1ee5250 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -166,7 +166,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op) psys_check_boid_data(psys); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); @@ -193,6 +193,7 @@ void PARTICLE_OT_new(wmOperatorType *ot) static int new_particle_target_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; @@ -214,7 +215,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *op) BLI_addtail(&psys->targets, pt); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); @@ -238,6 +239,7 @@ void PARTICLE_OT_new_target(wmOperatorType *ot) static int remove_particle_target_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; @@ -262,7 +264,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *op) if(pt) pt->flag |= PTARGET_CURRENT; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 7110c3aa7a7..b5392f6dede 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -403,6 +403,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) Render *re= RE_NewRender(scene->id.name); Image *ima; View3D *v3d= CTX_wm_view3d(C); + Main *mainp= G.main; //BKE_undo_get_main(&scene); int lay= (v3d)? v3d->lay: scene->lay; if(re==NULL) { @@ -418,9 +419,11 @@ static int screen_render_exec(bContext *C, wmOperator *op) BKE_image_backup_render(scene, ima); if(RNA_boolean_get(op->ptr, "animation")) - RE_BlenderAnim(re, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports); + RE_BlenderAnim(re, mainp, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports); else - RE_BlenderFrame(re, scene, NULL, lay, scene->r.cfra); + RE_BlenderFrame(re, mainp, scene, NULL, lay, scene->r.cfra); + + //free_main(mainp); // no redraw needed, we leave state as we entered it ED_update_for_newframe(C, 1); @@ -555,19 +558,18 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec static void render_startjob(void *rjv, short *stop, short *do_update, float *progress) { RenderJob *rj= rjv; -// Main *mainp= BKE_undo_get_main(&rj->scene); + Main *mainp= G.main; //BKE_undo_get_main(&rj->scene); rj->stop= stop; rj->do_update= do_update; rj->progress= progress; if(rj->anim) - RE_BlenderAnim(rj->re, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports); + RE_BlenderAnim(rj->re, mainp, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports); else - RE_BlenderFrame(rj->re, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra); + RE_BlenderFrame(rj->re, mainp, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra); -// if(mainp) -// free_main(mainp); + //free_main(mainp); } static void render_endjob(void *rjv) diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 5881d50c309..524e36b3fc9 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -241,6 +241,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) { + Main *bmain= CTX_data_main(C); Scene *scene= oglrender->scene; if(oglrender->mh) { @@ -250,7 +251,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) if(oglrender->timer) { /* exec will not have a timer */ scene->r.cfra= oglrender->cfrao; - scene_update_for_newframe(scene, screen_opengl_layers(oglrender)); + scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer); } @@ -297,6 +298,7 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) } static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); OGLRender *oglrender= op->customdata; Scene *scene= oglrender->scene; ImBuf *ibuf; @@ -316,11 +318,11 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if(lay & 0xFF000000) lay &= 0xFF000000; - scene_update_for_newframe(scene, lay); + scene_update_for_newframe(bmain, scene, lay); CFRA++; } - scene_update_for_newframe(scene, screen_opengl_layers(oglrender)); + scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); if(view_context) { if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 4bb1f630dad..d4c90a7f24e 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -704,7 +704,7 @@ void BIF_view3d_previewrender_clear(ScrArea *sa) } /* afterqueue call */ -void BIF_view3d_previewrender(Scene *scene, ScrArea *sa) +void BIF_view3d_previewrender(Main *bmain, Scene *scene, ScrArea *sa) { View3D *v3d= sa->spacedata.first; RegionView3D *rv3d= NULL; // XXX @@ -804,7 +804,7 @@ void BIF_view3d_previewrender(Scene *scene, ScrArea *sa) /* database can have created render-resol data... */ if(rstats->convertdone) - DAG_scene_flush_update(scene, scene->lay, 0); + DAG_scene_flush_update(bmain, scene, scene->lay, 0); //printf("dbase update\n"); } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 5082992aaba..78ec4fe3a01 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1727,6 +1727,7 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) /* results in fully updated anim system */ void ED_update_for_newframe(const bContext *C, int mute) { + Main *bmain= CTX_data_main(C); bScreen *screen= CTX_wm_screen(C); Scene *scene= CTX_data_scene(C); @@ -1750,7 +1751,7 @@ void ED_update_for_newframe(const bContext *C, int mute) /* this function applies the changes too */ /* XXX future: do all windows */ - scene_update_for_newframe(scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ + scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) // audiostream_scrub( CFRA ); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index c8192996127..b085c8178b0 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2838,9 +2838,9 @@ static int scene_new_exec(bContext *C, wmOperator *op) /* these can't be handled in blenkernel curently, so do them here */ if(type == SCE_COPY_LINK_DATA) - ED_object_single_users(newscene, 0); + ED_object_single_users(bmain, newscene, 0); else if(type == SCE_COPY_FULL) - ED_object_single_users(newscene, 1); + ED_object_single_users(bmain, newscene, 1); WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index bf433923707..a6c57126cfe 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -299,16 +299,17 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) static void do_graph_region_driver_buttons(bContext *C, void *arg, int event) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); switch (event) { case B_IPO_DEPCHANGE: { /* rebuild depsgraph for the new deps */ - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); /* force an update of depsgraph */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); } break; } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 98422ec2d9f..ae2cee64a23 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -359,6 +359,7 @@ static void old_sca_move_actuator(bContext *C, void *datav, void *move_up) void do_logic_buts(bContext *C, void *arg, int event) { + Main *bmain= CTX_data_main(C); bSensor *sens; bController *cont; bActuator *act; @@ -382,7 +383,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_ADD_SENS: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_ADDSENS) { ob->scaflag &= ~OB_ADDSENS; sens= new_sensor(SENS_ALWAYS); @@ -396,7 +397,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_CHANGE_SENS: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { sens= ob->sensors.first; while(sens) { if(sens->type != sens->otype) { @@ -410,7 +411,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_DEL_SENS: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { sens= ob->sensors.first; while(sens) { if(sens->flag & SENS_DEL) { @@ -425,7 +426,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_ADD_CONT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_ADDCONT) { ob->scaflag &= ~OB_ADDCONT; cont= new_controller(CONT_LOGIC_AND); @@ -450,7 +451,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_SET_STATE_BIT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_ALLSTATE) { ob->scaflag &= ~OB_ALLSTATE; ob->state = 0x3FFFFFFF; @@ -459,7 +460,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_INIT_STATE_BIT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_INITSTBIT) { ob->scaflag &= ~OB_INITSTBIT; ob->state = ob->init_state; @@ -470,7 +471,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_CHANGE_CONT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { cont= ob->controllers.first; while(cont) { if(cont->type != cont->otype) { @@ -485,7 +486,7 @@ void do_logic_buts(bContext *C, void *arg, int event) case B_DEL_CONT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { cont= ob->controllers.first; while(cont) { if(cont->flag & CONT_DEL) { @@ -501,7 +502,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_ADD_ACT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_ADDACT) { ob->scaflag &= ~OB_ADDACT; act= new_actuator(ACT_OBJECT); @@ -514,7 +515,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_CHANGE_ACT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { if(act->type != act->otype) { @@ -528,7 +529,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_DEL_ACT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { if(act->flag & ACT_DEL) { @@ -546,7 +547,7 @@ void do_logic_buts(bContext *C, void *arg, int event) case B_SOUNDACT_BROWSE: /* since we don't know which... */ didit= 0; - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { @@ -555,11 +556,11 @@ void do_logic_buts(bContext *C, void *arg, int event) bSoundActuator *sa= act->data; if(sa->sndnr) { - bSound *sound= G.main->sound.first; + bSound *sound= bmain->sound.first; int nr= 1; if(sa->sndnr == -2) { -// XXX activate_databrowse((ID *)G.main->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE, +// XXX activate_databrowse((ID *)bmain->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE, // &sa->sndnr, do_logic_buts); break; } @@ -768,6 +769,7 @@ static void set_sca_ob(Object *ob) static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisflag) { Base *base; + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob, *obt, *obact= CTX_data_active_object(C); ID **idar; @@ -784,7 +786,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf if(scene==NULL) return NULL; - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { ob->scavisflag= 0; set_sca_ob(ob); @@ -818,7 +820,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf while(doit) { doit= 0; - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { /* 1st case: select sensor when controller selected */ @@ -899,7 +901,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf } /* now we count */ - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if( ob->scavisflag ) (*count)++; ob= ob->id.next; @@ -910,7 +912,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf idar= MEM_callocN( (*count)*sizeof(void *), "idar"); - ob= G.main->object.first; + ob= bmain->object.first; nr= 0; /* make the active object always the first one of the list */ @@ -1817,7 +1819,7 @@ static void check_armature_actuator(bContext *C, void *arg1_but, void *arg2_act) } -static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) +static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) { bSoundActuator *sa = NULL; bObjectActuator *oa = NULL; @@ -2142,8 +2144,8 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - if(G.main->sound.first) { - IDnames_to_pupstring(&str, "Sound files", NULL, &(G.main->sound), (ID *)sa->sound, &(sa->sndnr)); + if(bmain->sound.first) { + IDnames_to_pupstring(&str, "Sound files", NULL, &(bmain->sound), (ID *)sa->sound, &(sa->sndnr)); /* reset this value, it is for handling the event */ sa->sndnr = 0; uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10,yco-22,20,19, &(sa->sndnr), 0, 0, 0, 0, ""); @@ -4709,6 +4711,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) void logic_buttons(bContext *C, ARegion *ar) { + Main *bmain= CTX_data_main(C); SpaceLogic *slogic= CTX_wm_space_logic(C); Object *ob= CTX_data_active_object(C); ID **idar; @@ -5033,7 +5036,7 @@ void logic_buttons(bContext *C, ARegion *ar) uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0); ycoo= yco; - yco= draw_actuatorbuttons(ob, act, block, xco, yco, width); + yco= draw_actuatorbuttons(bmain, ob, act, block, xco, yco, width); if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; } else { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 082f3f97dfd..01992d225c7 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -190,6 +190,7 @@ static void node_buts_normal(uiLayout *layout, bContext *C, PointerRNA *ptr) #if 0 // not used in 2.5x yet static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) { + Main *bmain= CTX_data_main(C); bNodeTree *ntree= ntree_v; bNode *node= node_v; Tex *tex; @@ -200,7 +201,7 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) node->id->us--; node->id= NULL; } - tex= BLI_findlink(&G.main->tex, node->menunr-1); + tex= BLI_findlink(&bmain->tex, node->menunr-1); node->id= &tex->id; id_us_plus(node->id); @@ -220,6 +221,7 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) #endif static void node_dynamic_update_cb(bContext *C, void *ntree_v, void *node_v) { + Main *bmain= CTX_data_main(C); Material *ma; bNode *node= (bNode *)node_v; ID *id= node->id; @@ -229,7 +231,7 @@ static void node_dynamic_update_cb(bContext *C, void *ntree_v, void *node_v) /* Users only have to press the "update" button in one pynode * and we also update all others sharing the same script */ - for (ma= G.main->mat.first; ma; ma= ma->id.next) { + for (ma= bmain->mat.first; ma; ma= ma->id.next) { if (ma->nodetree) { bNode *nd; for (nd= ma->nodetree->nodes.first; nd; nd= nd->next) { @@ -277,6 +279,7 @@ static void node_buts_math(uiLayout *layout, bContext *C, PointerRNA *ptr) static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v) { + Main *bmain= CTX_data_main(C); bNodeTree *ntree= ntree_v; bNode *node= node_v; ID *oldid; @@ -287,7 +290,7 @@ static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v) node->id->us--; } oldid= node->id; - node->id= BLI_findlink(&G.main->text, node->menunr-1); + node->id= BLI_findlink(&bmain->text, node->menunr-1); id_us_plus(node->id); BLI_strncpy(node->name, node->id->name+2, 21); /* huh? why 21? */ @@ -368,6 +371,7 @@ static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr) { + Main *bmain= CTX_data_main(C); uiBlock *block= uiLayoutAbsoluteBlock(layout); bNode *node= ptr->data; bNodeTree *ntree= ptr->id.data; @@ -380,7 +384,7 @@ static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA * /* B_NODE_EXEC is handled in butspace.c do_node_buts */ if(!node->id) { char *strp; - IDnames_to_pupstring(&strp, NULL, "", &(G.main->text), NULL, NULL); + IDnames_to_pupstring(&strp, NULL, "", &(bmain->text), NULL, NULL); node->menunr= 0; bt= uiDefButS(block, MENU, B_NODE_EXEC/*+node->nr*/, strp, butr->xmin, dy, 19, 19, diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index cea88c33c5b..dcd87b89ea0 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1852,6 +1852,7 @@ void NODE_OT_links_cut(wmOperatorType *ot) /* goes over all scenes, reads render layers */ static int node_read_renderlayers_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); Scene *curscene= CTX_data_scene(C), *scene; bNode *node; @@ -1859,7 +1860,7 @@ static int node_read_renderlayers_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); /* first tag scenes unread */ - for(scene= G.main->scene.first; scene; scene= scene->id.next) + for(scene= bmain->scene.first; scene; scene= scene->id.next) scene->id.flag |= LIB_DOIT; for(node= snode->edittree->nodes.first; node; node= node->next) { diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 3cdc2437c45..ad04e28ee4a 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -3186,7 +3186,7 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto if(scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); te->directdata= NULL; tselem->id= NULL; } @@ -3337,7 +3337,7 @@ void outliner_del(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops) ;// del_seq(); else { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); - DAG_scene_sort(scene); + DAG_scene_sort(CTX_data_main(C), scene); ED_undo_push(C, "Delete Objects"); } } @@ -3356,6 +3356,7 @@ static EnumPropertyItem prop_object_op_types[] = { static int outliner_object_operation_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; @@ -3382,7 +3383,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) } else if(event==4) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); str= "Delete Objects"; } else if(event==5) { /* disabled, see above (ton) */ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 5638cb6daf5..7a3f0ff80e5 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2359,6 +2359,7 @@ void TEXT_OT_insert(wmOperatorType *ot) static int find_and_replace(bContext *C, wmOperator *op, short mode) { + Main *bmain= CTX_data_main(C); SpaceText *st= CTX_wm_space_text(C); Text *start= NULL, *text= st->text; int flags, first= 1; @@ -2420,7 +2421,7 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) if(text->id.next) text= st->text= text->id.next; else - text= st->text= G.main->text.first; + text= st->text= bmain->text.first; txt_move_toline(text, 0, 0); text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 19aaff2cea9..f4ae87c5b60 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -53,6 +53,7 @@ #include "BKE_customdata.h" #include "BKE_depsgraph.h" #include "BKE_idprop.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_global.h" @@ -997,6 +998,7 @@ static int test_parent_loop(Object *par, Object *ob) static void do_view3d_region_buttons(bContext *C, void *arg, int event) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); // Object *obedit= CTX_data_edit_object(C); View3D *v3d= CTX_wm_view3d(C); @@ -1028,7 +1030,7 @@ static void do_view3d_region_buttons(bContext *C, void *arg, int event) if(ob->id.lib || test_parent_loop(ob->parent, ob) ) ob->parent= NULL; else { - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&ob->id, OB_RECALC_OB); } } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 14b769fdf39..761ef436d48 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -152,6 +152,7 @@ static void handle_view3d_lock(bContext *C) static int layers_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; @@ -213,7 +214,7 @@ static int layers_exec(bContext *C, wmOperator *op) if(v3d->scenelock) handle_view3d_lock(C); /* new layers might need unflushed events events */ - DAG_scene_update_flags(scene, v3d->lay); /* tags all that moves and flushes */ + DAG_scene_update_flags(bmain, scene, v3d->lay); /* tags all that moves and flushes */ ED_area_tag_redraw(sa); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 9928ba1983e..b3763d6cb90 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -45,14 +45,15 @@ #include "BKE_action.h" #include "BKE_anim.h" -#include "BKE_context.h" #include "BKE_armature.h" +#include "BKE_context.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_lattice.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -420,6 +421,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) static int snap_sel_to_grid(bContext *C, wmOperator *op) { extern float originmat[3][3]; /* XXX object.c */ + Main *bmain= CTX_data_main(C); Object *obedit= CTX_data_edit_object(C); Scene *scene= CTX_data_scene(C); RegionView3D *rv3d= CTX_wm_region_data(C); @@ -526,7 +528,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op) CTX_DATA_END; } - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -553,6 +555,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) static int snap_sel_to_curs(bContext *C, wmOperator *op) { extern float originmat[3][3]; /* XXX object.c */ + Main *bmain= CTX_data_main(C); Object *obedit= CTX_data_edit_object(C); Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); @@ -651,7 +654,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op) CTX_DATA_END; } - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 8ec226ef57e..4de6a270245 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1344,7 +1344,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b /* ********************** local view operator ******************** */ -static unsigned int free_localbit(void) +static unsigned int free_localbit(Main *bmain) { unsigned int lay; ScrArea *sa; @@ -1354,7 +1354,7 @@ static unsigned int free_localbit(void) /* sometimes we loose a localview: when an area is closed */ /* check all areas: which localviews are in use? */ - for(sc= G.main->screen.first; sc; sc= sc->id.next) { + for(sc= bmain->screen.first; sc; sc= sc->id.next) { for(sa= sc->areabase.first; sa; sa= sa->next) { SpaceLink *sl= sa->spacedata.first; for(; sl; sl= sl->next) { @@ -1416,7 +1416,7 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active) return lay; } -static void initlocalview(Scene *scene, ScrArea *sa) +static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) { View3D *v3d= sa->spacedata.first; Base *base; @@ -1428,7 +1428,7 @@ static void initlocalview(Scene *scene, ScrArea *sa) INIT_MINMAX(min, max); - locallay= free_localbit(); + locallay= free_localbit(bmain); if(locallay==0) { printf("Sorry, no more than 8 localviews\n"); // XXX error @@ -1592,7 +1592,7 @@ static int localview_exec(bContext *C, wmOperator *unused) if(v3d->localvd) endlocalview(CTX_data_scene(C), CTX_wm_area(C)); else - initlocalview(CTX_data_scene(C), CTX_wm_area(C)); + initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); ED_area_tag_redraw(CTX_wm_area(C)); @@ -1806,7 +1806,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) //XXX restore_all_scene_cfra(scene_cfra_store); set_scene_bg(startscene); - //XXX scene_update_for_newframe(G.scene, G.scene->lay); + //XXX scene_update_for_newframe(bmain, scene, scene->lay); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 2f8da7c2dd6..e71b9bd66e0 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4403,7 +4403,7 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t) } /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ - DAG_scene_flush_update(t->scene, -1, 0); + DAG_scene_flush_update(G.main, t->scene, -1, 0); /* and we store them temporal in base (only used for transform code) */ /* this because after doing updates, the object->recalc is cleared */ @@ -4481,7 +4481,7 @@ static int count_proportional_objects(TransInfo *t) /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ - DAG_scene_flush_update(t->scene, -1, 0); + DAG_scene_flush_update(G.main, t->scene, -1, 0); /* and we store them temporal in base (only used for transform code) */ /* this because after doing updates, the object->recalc is cleared */ diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index fbf2051f962..cd2b6a793b7 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -77,13 +77,14 @@ void ED_editors_init(bContext *C) /* frees all editmode stuff */ void ED_editors_exit(bContext *C) { + Main *bmain= CTX_data_main(C); Scene *sce; /* frees all editmode undos */ undo_editmode_clear(); ED_undo_paint_free(); - for(sce=G.main->scene.first; sce; sce= sce->id.next) { + for(sce=bmain->scene.first; sce; sce= sce->id.next) { if(sce->obedit) { Object *ob= sce->obedit; -- cgit v1.2.3 From f3cca3e1929a59ea8dbf715645bef4712a530ef5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 1 Aug 2010 12:57:01 +0000 Subject: 2.5: more G.main changes. --- source/blender/editors/screen/screen_edit.c | 2 +- source/blender/editors/space_view3d/view3d_view.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 78ec4fe3a01..8cee4a24dcc 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1426,7 +1426,7 @@ void ED_screen_set_scene(bContext *C, Scene *scene) } CTX_data_scene_set(C, scene); - set_scene_bg(scene); + set_scene_bg(CTX_data_main(C), scene); ED_update_for_newframe(C, 1); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 4de6a270245..5e00d17cfab 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1805,7 +1805,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) RestoreState(C); //XXX restore_all_scene_cfra(scene_cfra_store); - set_scene_bg(startscene); + set_scene_bg(CTX_data_main(C), startscene); //XXX scene_update_for_newframe(bmain, scene, scene->lay); ED_area_tag_redraw(CTX_wm_area(C)); -- cgit v1.2.3 From 4a63d2a2d28df692e57a2795b03bbd918f3f50e7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 1 Aug 2010 14:08:33 +0000 Subject: Fix for crash due to last commit. --- source/blender/editors/util/ed_util.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index cd2b6a793b7..3491c1b4df2 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -79,6 +79,9 @@ void ED_editors_exit(bContext *C) { Main *bmain= CTX_data_main(C); Scene *sce; + + if(!bmain) + return; /* frees all editmode undos */ undo_editmode_clear(); -- cgit v1.2.3 From 7524967238698ca770a76365a782f299c5d2ac86 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Aug 2010 14:23:06 +0000 Subject: - new __main__ module wasnt de-referenced after adding into sys.modules - made int buttons round floats better 10.6 --> 11 --- source/blender/editors/interface/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7b67a458ae2..38c11e507cc 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1644,7 +1644,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) value= atof(str); #endif - if(!ui_is_but_float(but)) value= (int)value; + if(!ui_is_but_float(but)) value= (int)floor(value + 0.5); if(but->type==NUMABS) value= fabs(value); /* not that we use hard limits here */ -- cgit v1.2.3 From 7e555711752cd00ed0d613f3c89a457512031b12 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Aug 2010 15:42:22 +0000 Subject: bugfix [#23134] uv project modifier not working. own recent commit introduced this bug. would like to have this working correctly but for now commenting. --- source/blender/editors/interface/interface_layout.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b6f4dcc0356..c56b3c31222 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1115,7 +1115,11 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui ID *id= itemptr.data; char name_ui[32]; +#if 0 /* this name is used for a string comparison and can't be modified, TODO */ name_uiprefix_id(name_ui, id); +#else + strcpy(name_ui, id->name+2); +#endif name= BLI_strdup(name_ui); iconid= ui_id_icon_get((bContext*)C, id, 1); } -- cgit v1.2.3 From 9b006d6d00c72de51b97e1b2c96b2df09db6b72b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 1 Aug 2010 20:36:24 +0000 Subject: Fix preview render crash after recent G.main changes. --- source/blender/editors/object/object_bake.c | 8 ++++++-- source/blender/editors/render/render_preview.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 9f9d41147b6..6261c33a6f7 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -94,6 +94,7 @@ static ScrArea *biggest_image_area(bScreen *screen) typedef struct BakeRender { Render *re; + Main *main; Scene *scene; struct Object *actob; int tot, ready; @@ -139,6 +140,7 @@ static void init_bake_internal(BakeRender *bkr, bContext *C) Scene *scene= CTX_data_scene(C); bkr->sa= biggest_image_area(CTX_wm_screen(C)); /* can be NULL */ + bkr->main= CTX_data_main(C); bkr->scene= scene; bkr->actob= (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL; bkr->re= RE_NewRender("_Bake View_"); @@ -196,6 +198,7 @@ static void bake_startjob(void *bkv, short *stop, short *do_update, float *progr { BakeRender *bkr= bkv; Scene *scene= bkr->scene; + Main *bmain= bkr->main; bkr->stop= stop; bkr->do_update= do_update; @@ -204,7 +207,7 @@ static void bake_startjob(void *bkv, short *stop, short *do_update, float *progr RE_test_break_cb(bkr->re, NULL, thread_break); G.afbreek= 0; /* blender_test_break uses this global */ - RE_Database_Baking(bkr->re, scene, scene->lay, scene->r.bake_mode, bkr->actob); + RE_Database_Baking(bkr->re, bmain, scene, scene->lay, scene->r.bake_mode, bkr->actob); /* baking itself is threaded, cannot use test_break in threads. we also update optional imagewindow */ bkr->tot= RE_bake_shade_all_selected(bkr->re, scene->r.bake_mode, bkr->actob, bkr->do_update, bkr->progress); @@ -284,6 +287,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *_eve static int bake_image_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); @@ -302,7 +306,7 @@ static int bake_image_exec(bContext *C, wmOperator *op) RE_test_break_cb(bkr.re, NULL, thread_break); G.afbreek= 0; /* blender_test_break uses this global */ - RE_Database_Baking(bkr.re, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE)? OBACT: NULL); + RE_Database_Baking(bkr.re, bmain, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE)? OBACT: NULL); /* baking itself is threaded, cannot use test_break in threads */ BLI_init_threads(&threads, do_bake_render, 1); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index d4c90a7f24e..49395f7fb56 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -975,7 +975,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs ((Camera *)sce->camera->data)->lens *= (float)sp->sizey/(float)sizex; /* entire cycle for render engine */ - RE_PreviewRender(re, sce); + RE_PreviewRender(re, G.main, sce); ((Camera *)sce->camera->data)->lens= oldlens; -- cgit v1.2.3