diff options
Diffstat (limited to 'source/blender/editors')
27 files changed, 432 insertions, 111 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index bd02df2ddba..2dd8ef4da94 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -105,9 +105,9 @@ typedef struct tGPsdata { short flags; /* flags that can get set during runtime */ float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space - to region space */ + * to region space */ - float custom_color[3]; /* custom color for */ + float custom_color[4]; /* custom color for (?) */ } tGPsdata; /* values for tGPsdata->status */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 35fabb3b80e..01273b291a2 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -688,6 +688,7 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv); void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr); const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PropertyRNA *), const char label_align, const short flag); +struct MenuType *uiButGetMenuType(uiBut *but); void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); void uiLayoutSetActive(uiLayout *layout, int active); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 81b42277055..be8bee7452d 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -48,6 +48,8 @@ #include "BKE_context.h" #include "BKE_library.h" #include "BKE_unit.h" +#include "BKE_screen.h" +#include "BKE_idprop.h" #include "BKE_utildefines.h" /* FILE_MAX */ #include "BIF_gl.h" @@ -793,26 +795,61 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) { uiBut *but; - IDProperty *prop; char buf[512]; + /* for menu's */ + MenuType *mt; + IDProperty *prop_menu= NULL; + IDProperty *prop_menu_name= NULL; + /* only do it before bounding */ if(block->minx != block->maxx) return; + +#define UI_MENU_KEY_STR_CAT \ + char *butstr_orig= BLI_strdup(but->str); \ + BLI_snprintf(but->strdata, \ + sizeof(but->strdata), \ + "%s|%s", \ + butstr_orig, buf); \ + MEM_freeN(butstr_orig); \ + but->str= but->strdata; \ + ui_check_but(but); \ + + for(but=block->buttons.first; but; but=but->next) { if(but->optype) { - prop= (but->opptr)? but->opptr->data: NULL; - - if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) { - char *butstr_orig= BLI_strdup(but->str); - BLI_snprintf(but->strdata, sizeof(but->strdata), "%s|%s", butstr_orig, buf); - MEM_freeN(butstr_orig); - but->str= but->strdata; - ui_check_but(but); + IDProperty *prop= (but->opptr)? but->opptr->data: NULL; + + if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) { + UI_MENU_KEY_STR_CAT + } + } + else if ((mt= uiButGetMenuType(but))) { + /* only allocate menu property once */ + if (prop_menu == NULL) { + /* annoying, create a property */ + IDPropertyTemplate val = {0}; + prop_menu= IDP_New(IDP_GROUP, val, __func__); /* dummy, name is unimportant */ + IDP_AddToGroup(prop_menu, (prop_menu_name= IDP_NewString("", "name", sizeof(mt->idname)))); + } + + IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname)); + + if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, buf, sizeof(buf))) { + UI_MENU_KEY_STR_CAT } } } + + if (prop_menu) { + IDP_FreeProperty(prop_menu); + MEM_freeN(prop_menu); + } + +#undef UI_MENU_KEY_STR_CAT + } void uiEndBlock(const bContext *C, uiBlock *block) @@ -3545,7 +3582,7 @@ void UI_init_userdef(void) uiStyleInit(); } -void UI_reinit_font() +void UI_reinit_font(void) { uiStyleInit(); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 7338aa1983f..ee1f9617813 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4357,7 +4357,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) IDProperty *prop= (but->opptr)? but->opptr->data: NULL; /* complex code to change name of button */ - if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) { + if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) { char *butstr_orig; // XXX but->str changed... should not, remove the hotkey from it diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 32bcfe51afc..a6f93101fdc 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2821,3 +2821,14 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in } } } + +/* this is a bit of a hack but best keep it in one place at least */ +MenuType *uiButGetMenuType(uiBut *but) +{ + if(but->menu_create_func == ui_item_menutype_func) { + return (MenuType *)but->poin; + } + else { + return NULL; + } +} diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 5803054caa7..2a75c2a26c1 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -494,7 +494,7 @@ struct uiEditSourceButStore { } uiEditSourceButStore; /* should only ever be set while the edit source operator is running */ -struct uiEditSourceStore *ui_editsource_info= NULL; +static struct uiEditSourceStore *ui_editsource_info= NULL; int UI_editsource_enable_check(void) { diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 34b62155314..837a9d12af1 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -408,7 +408,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* operator keymap (not menus, they already have it) */ prop= (but->opptr)? but->opptr->data: NULL; - if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) { + if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), buf); data->color[data->totline]= 0x888888; data->totline++; @@ -493,8 +493,8 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } else if (ELEM(but->type, MENU, PULLDOWN)) { if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { - if(but->menu_create_func && WM_menutype_contains((MenuType *)but->poin)) { - MenuType *mt= (MenuType *)but->poin; + MenuType *mt= uiButGetMenuType(but); + if (mt) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), mt->idname); data->color[data->totline]= 0x888888; data->totline++; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 795446e76ef..eb7e06623f7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2458,7 +2458,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char /* check for hotkey */ if(len < 256-6) { - if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, &name[len+1], 256-len-1)) + if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], 256-len-1)) name[len]= '|'; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index aa407bbf6d4..c9fcb7f1d24 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -810,6 +810,11 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) } +static int ui_but_draw_menu_icon(uiBut *but) +{ + return (but->flag & UI_ICON_SUBMENU) && (but->dt == UI_EMBOSSP); +} + /* icons have been standardized... and this call draws in untransformed coordinates */ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect) @@ -888,8 +893,8 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect else UI_icon_draw_aspect(xs, ys, icon, aspect, alpha); } - - if((but->flag & UI_ICON_SUBMENU) && (but->dt == UI_EMBOSSP)) { + + if (ui_but_draw_menu_icon(but)) { xs= rect->xmax-17; ys= (rect->ymin+rect->ymax- height)/2; @@ -1139,7 +1144,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b /* part text right aligned */ if(cpoin) { fstyle->align= UI_STYLE_TEXT_RIGHT; - rect->xmax-=5; + rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 5; uiStyleFontDraw(fstyle, rect, cpoin+1); *cpoin= '|'; } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 4ce7b8843ca..68a58ae9223 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -1033,8 +1033,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0); Mesh *me= (Mesh*)ob->data; - if(ob->mode==OB_MODE_SCULPT) *lvl= mmd->sculptlvl; - else *lvl= mmd->lvl; + *lvl= mmd->lvl; if(*lvl==0) { DerivedMesh *tmp_dm= CDDM_from_mesh(me, ob); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 0fbf5a8bd92..3c84b2df1d2 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -736,7 +736,7 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) where_is_pose(scene, ob); } else if (ob) { - Object workob = {{0}}; + Object workob = {{NULL}}; /* use what_does_parent to find inverse - just like for normal parenting */ what_does_parent(scene, ob, &workob); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index b0f4304ea89..035d2dfcff8 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -159,6 +159,7 @@ void OBJECT_OT_multires_external_save(struct wmOperatorType *ot); void OBJECT_OT_multires_external_pack(struct wmOperatorType *ot); void OBJECT_OT_meshdeform_bind(struct wmOperatorType *ot); void OBJECT_OT_explode_refresh(struct wmOperatorType *ot); +void OBJECT_OT_ocean_bake(struct wmOperatorType *ot); void OBJECT_OT_test_multires(struct wmOperatorType *ot); /* object_constraint.c */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index d84d5ea6537..2f9f5e08911 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -34,6 +34,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" @@ -48,6 +49,7 @@ #include "BLI_editVert.h" #include "BLI_utildefines.h" +#include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -63,6 +65,7 @@ #include "BKE_multires.h" #include "BKE_report.h" #include "BKE_object.h" +#include "BKE_ocean.h" #include "BKE_particle.h" #include "BKE_softbody.h" #include "BKE_tessmesh.h" @@ -1475,3 +1478,220 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; edit_modifier_properties(ot); } + + +/****************** ocean bake operator *********************/ + +static int ocean_bake_poll(bContext *C) +{ + return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0); +} + +/* copied from init_ocean_modifier, MOD_ocean.c */ +static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData *omd) +{ + int do_heightfield, do_chop, do_normals, do_jacobian; + + if (!omd || !oc) return; + + do_heightfield = TRUE; + do_chop = (omd->chop_amount > 0); + do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); + do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); + + BKE_init_ocean(oc, omd->resolution*omd->resolution, omd->resolution*omd->resolution, omd->spatial_size, omd->spatial_size, + omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, + omd->depth, omd->time, + do_heightfield, do_chop, do_normals, do_jacobian, + omd->seed); +} + +typedef struct OceanBakeJob { + /* from wmJob */ + void *owner; + short *stop, *do_update; + float *progress; + int current_frame; + struct OceanCache *och; + struct Ocean *ocean; + struct OceanModifierData *omd; +} OceanBakeJob; + +static void oceanbake_free(void *customdata) +{ + OceanBakeJob *oj= customdata; + MEM_freeN(oj); +} + +/* called by oceanbake, only to check job 'stop' value */ +static int oceanbake_breakjob(void *UNUSED(customdata)) +{ + //OceanBakeJob *ob= (OceanBakeJob *)customdata; + //return *(ob->stop); + + /* this is not nice yet, need to make the jobs list template better + * for identifying/acting upon various different jobs */ + /* but for now we'll reuse the render break... */ + return (G.afbreek); +} + +/* called by oceanbake, wmJob sends notifier */ +static void oceanbake_update(void *customdata, float progress, int *cancel) +{ + OceanBakeJob *oj= customdata; + + if (oceanbake_breakjob(oj)) + *cancel = 1; + + *(oj->do_update)= 1; + *(oj->progress)= progress; +} + +static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress) +{ + OceanBakeJob *oj= customdata; + + oj->stop= stop; + oj->do_update = do_update; + oj->progress = progress; + + G.afbreek= 0; /* XXX shared with render - replace with job 'stop' switch */ + + BKE_bake_ocean(oj->ocean, oj->och, oceanbake_update, (void *)oj); + + *do_update= 1; + *stop = 0; +} + +static void oceanbake_endjob(void *customdata) +{ + OceanBakeJob *oj= customdata; + + if (oj->ocean) { + BKE_free_ocean(oj->ocean); + oj->ocean = NULL; + } + + oj->omd->oceancache = oj->och; + oj->omd->cached = TRUE; +} + +static int ocean_bake_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_active_context(C); + OceanModifierData *omd = (OceanModifierData *)edit_modifier_property_get(op, ob, eModifierType_Ocean); + Scene *scene = CTX_data_scene(C); + OceanCache *och; + struct Ocean *ocean; + int f, cfra, i=0; + int free= RNA_boolean_get(op->ptr, "free"); + + wmJob *steve; + OceanBakeJob *oj; + + if (!omd) + return OPERATOR_CANCELLED; + + if (free) { + omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + return OPERATOR_FINISHED; + } + + och = BKE_init_ocean_cache(omd->cachepath, omd->bakestart, omd->bakeend, omd->wave_scale, + omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); + + och->time = MEM_mallocN(och->duration*sizeof(float), "foam bake time"); + + cfra = scene->r.cfra; + + /* precalculate time variable before baking */ + for (f=omd->bakestart; f<=omd->bakeend; f++) { + /* from physics_fluid.c: + + * XXX: This can't be used due to an anim sys optimisation that ignores recalc object animation, + * leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ ) + * --> BKE_animsys_evaluate_all_animation(G.main, eval_time); + * This doesn't work with drivers: + * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL); + */ + + /* Modifying the global scene isn't nice, but we can do it in + * this part of the process before a threaded job is created */ + + //scene->r.cfra = f; + //ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1); + + /* ok, this doesn't work with drivers, but is way faster. + * let's use this for now and hope nobody wants to drive the time value... */ + BKE_animsys_evaluate_animdata(scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM); + + och->time[i] = omd->time; + i++; + } + + /* make a copy of ocean to use for baking - threadsafety */ + ocean = BKE_add_ocean(); + init_ocean_modifier_bake(ocean, omd); + + /* + BKE_bake_ocean(ocean, och); + + omd->oceancache = och; + omd->cached = TRUE; + + scene->r.cfra = cfra; + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + */ + + /* job stuff */ + + scene->r.cfra = cfra; + + /* setup job */ + steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", WM_JOB_PROGRESS); + oj= MEM_callocN(sizeof(OceanBakeJob), "ocean bake job"); + oj->ocean = ocean; + oj->och = och; + oj->omd = omd; + + WM_jobs_customdata(steve, oj, oceanbake_free); + WM_jobs_timer(steve, 0.1, NC_OBJECT|ND_MODIFIER, NC_OBJECT|ND_MODIFIER); + WM_jobs_callbacks(steve, oceanbake_startjob, NULL, NULL, oceanbake_endjob); + + WM_jobs_start(CTX_wm_manager(C), steve); + + + + return OPERATOR_FINISHED; +} + +static int ocean_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + if (edit_modifier_invoke_properties(C, op)) + return ocean_bake_exec(C, op); + else + return OPERATOR_CANCELLED; +} + + +void OBJECT_OT_ocean_bake(wmOperatorType *ot) +{ + ot->name= "Bake Ocean"; + ot->description= "Bake an image sequence of ocean data"; + ot->idname= "OBJECT_OT_ocean_bake"; + + ot->poll= ocean_bake_poll; + ot->invoke= ocean_bake_invoke; + ot->exec= ocean_bake_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + edit_modifier_properties(ot); + + RNA_def_boolean(ot->srna, "free", FALSE, "Free", "Free the bake, rather than generating it"); +} + diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index fb403d92d93..4bad1f90326 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -142,6 +142,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_multires_external_pack); WM_operatortype_append(OBJECT_OT_meshdeform_bind); WM_operatortype_append(OBJECT_OT_explode_refresh); + WM_operatortype_append(OBJECT_OT_ocean_bake); WM_operatortype_append(OBJECT_OT_constraint_add); WM_operatortype_append(OBJECT_OT_constraint_add_with_targets); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 9894f53f719..8e18e8693fe 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -802,7 +802,7 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count) } } if(!length) { - return 0; + return NULL; } tverts = MEM_mallocN(sizeof(int)*length, "tempSurroundingVerts"); mf = me->mface; diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 550da63d7aa..a12a9c8720b 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -53,9 +53,11 @@ #include "WM_types.h" #include "WM_api.h" +#include "physics_intern.h" /* own include */ + static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) { - DynamicPaintModifierData *pmd = 0; + DynamicPaintModifierData *pmd = NULL; Object *cObject = CTX_data_pointer_get_type(C, "object", &RNA_Object).data; DynamicPaintCanvasSettings *canvas; DynamicPaintSurface *surface; @@ -97,7 +99,7 @@ void DPAINT_OT_surface_slot_add(wmOperatorType *ot) static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - DynamicPaintModifierData *pmd = 0; + DynamicPaintModifierData *pmd = NULL; Object *cObject = CTX_data_pointer_get_type(C, "object", &RNA_Object).data; DynamicPaintCanvasSettings *canvas; DynamicPaintSurface *surface; @@ -181,7 +183,7 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot) /* identifiers */ ot->name= "Toggle Type Active"; ot->idname= "DPAINT_OT_type_toggle"; - ot->description = "Toggles whether given type is active or not"; + ot->description = "Toggle whether given type is active or not"; /* api callbacks */ ot->exec= type_toggle_exec; @@ -197,24 +199,23 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot) static int output_toggle_exec(bContext *C, wmOperator *op) { - Object *ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Scene *scene = CTX_data_scene(C); DynamicPaintSurface *surface; DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); - int index= RNA_int_get(op->ptr, "index"); + int output= RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */ if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED; surface = get_activeSurface(pmd->canvas); /* if type is already enabled, toggle it off */ if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { - int exists = dynamicPaint_outputLayerExists(surface, ob, index); - char *name; + int exists = dynamicPaint_outputLayerExists(surface, ob, output); + const char *name; - if (index == 0) + if (output == 0) name = surface->output_name; - else if (index == 1) + else name = surface->output_name2; /* Vertex Color Layer */ @@ -226,8 +227,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op) } /* Vertex Weight Layer */ else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) { - if (!exists) + if (!exists) { ED_vgroup_add_name(ob, name); + } else { bDeformGroup *defgroup = defgroup_find_name(ob, name); if (defgroup) ED_vgroup_delete(ob, defgroup); @@ -240,12 +242,16 @@ static int output_toggle_exec(bContext *C, wmOperator *op) void DPAINT_OT_output_toggle(wmOperatorType *ot) { - PropertyRNA *prop; + static EnumPropertyItem prop_output_toggle_types[] = { + {0, "A", 0, "Output A", ""}, + {1, "B", 0, "Output B", ""}, + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name= "Toggle Output Layer"; ot->idname= "DPAINT_OT_output_toggle"; - ot->description = "Adds or removes Dynamic Paint output data layer"; + ot->description = "Add or remove Dynamic Paint output data layer"; /* api callbacks */ ot->exec= output_toggle_exec; @@ -255,8 +261,7 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - prop= RNA_def_int(ot->srna, "index", 0, 0, 1, "Index", "", 0, 1); - ot->prop= prop; + ot->prop= RNA_def_enum(ot->srna, "output", prop_output_toggle_types, 0, "Output Toggle", ""); } @@ -333,9 +338,9 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf /* -* Bake Dynamic Paint image sequence surface -*/ -int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) + * Bake Dynamic Paint image sequence surface + */ +static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) { DynamicPaintModifierData *pmd = NULL; DynamicPaintCanvasSettings *canvas; diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index c8113c5ea7b..fe09c5cd829 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -50,6 +50,8 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "clip_intern.h" /* own include */ + /* ************************ header area region *********************** */ /************************** properties ******************************/ diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index e9006f5b1e9..1b08a9aee4c 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1504,24 +1504,6 @@ void CLIP_OT_track_markers(wmOperatorType *ot) /********************** solve camera operator *********************/ -static int check_solve_track_count(MovieTracking *tracking) -{ - int tot= 0; - int frame1= tracking->settings.keyframe1, frame2= tracking->settings.keyframe2; - MovieTrackingTrack *track; - - track= tracking->tracks.first; - while(track) { - if(BKE_tracking_has_marker(track, frame1)) - if(BKE_tracking_has_marker(track, frame2)) - tot++; - - track= track->next; - } - - return tot>=8; -} - static int solve_camera_exec(bContext *C, wmOperator *op) { SpaceClip *sc= CTX_wm_space_clip(C); @@ -1530,9 +1512,11 @@ static int solve_camera_exec(bContext *C, wmOperator *op) MovieTracking *tracking= &clip->tracking; int width, height; float error; + char error_msg[255]; + + if(!BKE_tracking_can_solve(tracking, error_msg, sizeof(error_msg))) { + BKE_report(op->reports, RPT_ERROR, error_msg); - if(!check_solve_track_count(tracking)) { - BKE_report(op->reports, RPT_ERROR, "At least 8 tracks on both of keyframes are needed for reconstruction"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 529e976a904..d9418509830 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -40,6 +40,7 @@ #include "BLI_utildefines.h" #include "BKE_anim.h" +#include "BKE_blender.h" #include "BKE_curve.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" @@ -353,7 +354,6 @@ static void stats_update(Scene *scene) static void stats_string(Scene *scene) { - extern char versionstr[]; /* from blender.c */ SceneStats *stats= scene->stats; Object *ob= (scene->basact)? scene->basact->object: NULL; uintptr_t mem_in_use, mmap_in_use; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index e2e47338eee..92592a7c071 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -947,28 +947,27 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - PointerRNA mappingptr = RNA_pointer_get(ptr, "mapping"); uiLayout *row; uiItemL(layout, "Location:", ICON_NONE); row= uiLayoutRow(layout, 1); - uiItemR(row, &mappingptr, "location", 0, "", ICON_NONE); + uiItemR(row, ptr, "location", 0, "", ICON_NONE); uiItemL(layout, "Rotation:", ICON_NONE); row= uiLayoutRow(layout, 1); - uiItemR(row, &mappingptr, "rotation", 0, "", ICON_NONE); + uiItemR(row, ptr, "rotation", 0, "", ICON_NONE); uiItemL(layout, "Scale:", ICON_NONE); row= uiLayoutRow(layout, 1); - uiItemR(row, &mappingptr, "scale", 0, "", ICON_NONE); + uiItemR(row, ptr, "scale", 0, "", ICON_NONE); row= uiLayoutRow(layout, 1); - uiItemR(row, &mappingptr, "use_min", 0, "Min", ICON_NONE); - uiItemR(row, &mappingptr, "min", 0, "", ICON_NONE); + uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE); + uiItemR(row, ptr, "min", 0, "", ICON_NONE); row= uiLayoutRow(layout, 1); - uiItemR(row, &mappingptr, "use_max", 0, "Max", ICON_NONE); - uiItemR(row, &mappingptr, "max", 0, "", ICON_NONE); + uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE); + uiItemR(row, ptr, "max", 0, "", ICON_NONE); } static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index fedb12f747c..c99a0be15dc 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -552,6 +552,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *lnode; char label[UI_MAX_NAME_STR]; int indent = (depth > 1)? 2*(depth - 1): 0; + int dependency_loop; if(input->flag & SOCK_UNAVAIL) return; @@ -560,6 +561,10 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, node->flag |= NODE_TEST; lnode = (input->link)? input->link->fromnode: NULL; + dependency_loop = (lnode && (lnode->flag & NODE_TEST)); + if(dependency_loop) + lnode = NULL; + /* socket RNA pointer */ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, input, &inputptr); @@ -593,7 +598,11 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bt= block->buttons.last; bt->flag= UI_TEXT_LEFT; - if(lnode) { + if(dependency_loop) { + row = uiLayoutRow(split, 0); + uiItemL(row, "Dependency Loop", ICON_ERROR); + } + else if(lnode) { /* input linked to a node */ uiTemplateNodeLink(split, ntree, node, input); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 58f41b63b66..44bacd7a20e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2819,28 +2819,34 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object if(dt>OB_WIRE) { if(CHECK_OB_DRAWTEXTURE(v3d, dt)) { if(draw_glsl_material(scene, ob, v3d, dt)) { - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + /* if em has no faces the drawMappedFaces callback will fail */ + if(em->bm->totface) { + glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); - finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material, - draw_em_fancy__setGLSLFaceOpts, em); - GPU_disable_material(); + finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material, + draw_em_fancy__setGLSLFaceOpts, em); + GPU_disable_material(); - glFrontFace(GL_CCW); + glFrontFace(GL_CCW); + } } else { draw_mesh_textured(scene, v3d, rv3d, ob, finalDM, 0); } } else { - /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */ - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED); + /* if em has no faces the drawMappedFaces callback will fail */ + if(em->bm->totface) { + /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */ + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED); - glEnable(GL_LIGHTING); - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); - finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, me->edit_btmesh, 0, GPU_enable_material, NULL); + glEnable(GL_LIGHTING); + glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, me->edit_btmesh, 0, GPU_enable_material, NULL); - glFrontFace(GL_CCW); - glDisable(GL_LIGHTING); + glFrontFace(GL_CCW); + glDisable(GL_LIGHTING); + } } // Setup for drawing wire over, disable zbuffer diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index edcaed43de6..7ce758d4f47 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2878,6 +2878,10 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha else draw_view_icon(rv3d); + ob= OBACT; + if(U.uiflag & USER_DRAWVIEWINFO) + draw_selected_name(scene, ob); + if(rv3d->render_engine) { view3d_main_area_draw_engine_info(rv3d, ar); return; @@ -2899,10 +2903,6 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha BLF_draw_default_ascii(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, tstr[0]?tstr : grid_unit, sizeof(tstr)); /* XXX, use real length */ } - - ob= OBACT; - if(U.uiflag & USER_DRAWVIEWINFO) - draw_selected_name(scene, ob); } void view3d_main_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 0329b6c3739..7eaa5d42dd0 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1031,21 +1031,17 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event rv3d->view = RV3D_VIEW_USER; if (U.flag & USER_TRACKBALL) { - const int invert_roll = U.ndof_flag & NDOF_ROLL_INVERT_AXIS; - const int invert_tilt = U.ndof_flag & NDOF_TILT_INVERT_AXIS; - const int invert_rot = U.ndof_flag & NDOF_ROTATE_INVERT_AXIS; - float rot[4]; float axis[3]; float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); - if (invert_roll) + if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) axis[2] = -axis[2]; - if (invert_tilt) + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) axis[0] = -axis[0]; - if (invert_rot) + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) axis[1] = -axis[1]; // transform rotation axis from view to world coordinates @@ -1061,8 +1057,6 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); } else { /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ - const int invert = U.ndof_flag & NDOF_ORBIT_INVERT_AXES; - float angle, rot[4]; float xvec[3] = {1,0,0}; @@ -1071,7 +1065,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event /* Perform the up/down rotation */ angle = rot_sensitivity * dt * ndof->rvec[0]; - if (invert) + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) angle = -angle; rot[0] = cos(angle); mul_v3_v3fl(rot+1, xvec, sin(angle)); @@ -1079,7 +1073,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event /* Perform the orbital rotation */ angle = rot_sensitivity * dt * ndof->rvec[1]; - if (invert) + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) angle = -angle; // update the onscreen doo-dad @@ -1164,23 +1158,19 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) const float vertical_sensitivity = 0.4f; const float lateral_sensitivity = 0.6f; - const int invert_panx = U.ndof_flag & NDOF_PANX_INVERT_AXIS; - const int invert_pany = U.ndof_flag & NDOF_PANY_INVERT_AXIS; - const int invert_panz = U.ndof_flag & NDOF_PANZ_INVERT_AXIS; - float pan_vec[3]; - if (invert_panx) + if (U.ndof_flag & NDOF_PANX_INVERT_AXIS) pan_vec[0] = -lateral_sensitivity * ndof->tvec[0]; else pan_vec[0] = lateral_sensitivity * ndof->tvec[0]; - if (invert_panz) + if (U.ndof_flag & NDOF_PANZ_INVERT_AXIS) pan_vec[1] = -vertical_sensitivity * ndof->tvec[1]; else pan_vec[1] = vertical_sensitivity * ndof->tvec[1]; - if (invert_pany) + if (U.ndof_flag & NDOF_PANY_INVERT_AXIS) pan_vec[2] = -forward_sensitivity * ndof->tvec[2]; else pan_vec[2] = forward_sensitivity * ndof->tvec[2]; diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index fa2d5db21df..775cb45066a 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -155,7 +155,8 @@ void VIEW3D_OT_select_border(struct wmOperatorType *ot); void VIEW3D_OT_select_lasso(struct wmOperatorType *ot); void VIEW3D_OT_smoothview(struct wmOperatorType *ot); -void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot); +void VIEW3D_OT_camera_to_view(struct wmOperatorType *ot); +void VIEW3D_OT_camera_to_view_selected(struct wmOperatorType *ot); void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot); void VIEW3D_OT_localview(struct wmOperatorType *ot); void VIEW3D_OT_game_start(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 6e26fb15873..aeb850243c5 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -85,7 +85,8 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_enable_manipulator); WM_operatortype_append(VIEW3D_OT_cursor3d); WM_operatortype_append(VIEW3D_OT_select_lasso); - WM_operatortype_append(VIEW3D_OT_setcameratoview); + WM_operatortype_append(VIEW3D_OT_camera_to_view); + WM_operatortype_append(VIEW3D_OT_camera_to_view_selected); WM_operatortype_append(VIEW3D_OT_object_as_camera); WM_operatortype_append(VIEW3D_OT_localview); WM_operatortype_append(VIEW3D_OT_game_start); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index ca03ee56260..1b4b26aeaaa 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -43,6 +43,7 @@ #include "BKE_anim.h" #include "BKE_action.h" +#include "BKE_camera.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_object.h" @@ -406,9 +407,8 @@ static int view3d_setcameratoview_poll(bContext *C) return 0; } -void VIEW3D_OT_setcameratoview(wmOperatorType *ot) +void VIEW3D_OT_camera_to_view(wmOperatorType *ot) { - /* identifiers */ ot->name= "Align Camera To View"; ot->description= "Set camera view to active view"; @@ -422,6 +422,55 @@ void VIEW3D_OT_setcameratoview(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* unlike VIEW3D_OT_view_selected this is for framing a render and not + * meant to take into account vertex/bone selection for eg. */ +static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene= CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + Object *camera_ob= v3d->camera; + + float r_co[3]; /* the new location to apply */ + + /* this function does all the important stuff */ + if (camera_view_frame_fit_to_scene(scene, v3d, camera_ob, r_co)) { + + ObjectTfmProtectedChannels obtfm; + float obmat_new[4][4]; + + copy_m4_m4(obmat_new, camera_ob->obmat); + copy_v3_v3(obmat_new[3], r_co); + + /* only touch location */ + object_tfm_protected_backup(camera_ob, &obtfm); + object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); + object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); + + /* notifiers */ + DAG_id_tag_update(&camera_ob->id, OB_RECALC_OB); + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, camera_ob); + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Camera Fit Frame to Selected"; + ot->description= "Move the camera so selected objects are framed"; + ot->idname= "VIEW3D_OT_camera_to_view_selected"; + + /* api callbacks */ + ot->exec= view3d_camera_to_view_selected_exec; + // ot->poll= view3d_setcameratoview_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -461,7 +510,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) ot->idname= "VIEW3D_OT_object_as_camera"; /* api callbacks */ - ot->exec= view3d_setobjectascamera_exec; + ot->exec= view3d_setobjectascamera_exec; ot->poll= ED_operator_rv3d_unlock_poll; /* flags */ |