diff options
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_modifier.py | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 8 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_normal_edit.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 34 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_files.h | 3 |
11 files changed, 50 insertions, 32 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 685d69ceacc..f5f1339ed97 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -1503,6 +1503,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): def NORMAL_EDIT(self, layout, ob, md): has_vgroup = bool(md.vertex_group) + do_polynors_fix = not md.no_polynors_fix needs_object_offset = (((md.mode == 'RADIAL') and not md.target) or ((md.mode == 'DIRECTIONAL') and md.use_direction_parallel)) @@ -1532,7 +1533,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): sub = row.row(align=True) sub.active = has_vgroup sub.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT') - subcol.prop(md, "mix_limit") + row = subcol.row(align=True) + row.prop(md, "mix_limit") + row.prop(md, "no_polynors_fix", text="", icon='UNLOCKED' if do_polynors_fix else 'LOCKED') def CORRECTIVE_SMOOTH(self, layout, ob, md): is_bind = md.is_bind diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 93ab7a035bc..fd05f5584ec 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1567,6 +1567,7 @@ enum { enum { MOD_NORMALEDIT_INVERT_VGROUP = (1 << 0), MOD_NORMALEDIT_USE_DIRECTION_PARALLEL = (1 << 1), + MOD_NORMALEDIT_NO_POLYNORS_FIX = (1 << 2), }; /* NormalEditModifierData.mix_mode */ diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index bfc90557374..e41fe513314 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -4840,6 +4840,14 @@ static void rna_def_modifier_normaledit(BlenderRNA *brna) RNA_def_property_subtype(prop, PROP_ANGLE); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "no_polynors_fix", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_NORMALEDIT_NO_POLYNORS_FIX); + RNA_def_property_boolean_default(prop, false); + RNA_def_property_ui_text(prop, "Lock Polygon Normals", + "Do not flip polygons when their normals are not consistent " + "with their newly computed custom vertex normals"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for selecting/weighting the affected areas"); diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c index 08dbcf81256..935d99e4a21 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.c @@ -201,6 +201,7 @@ static void normalEditModifier_do_radial( MVert *mvert, const int num_verts, MEdge *medge, const int num_edges, MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys) { + const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; int i; float (*cos)[3] = MEM_malloc_arrayN((size_t)num_verts, sizeof(*cos), __func__); @@ -278,7 +279,7 @@ static void normalEditModifier_do_radial( mix_limit, mix_mode, num_verts, mloop, loopnors, nos, num_loops); } - if (polygons_check_flip(mloop, nos, &mesh->ldata, mpoly, polynors, num_polys)) { + if (do_polynors_fix && polygons_check_flip(mloop, nos, &mesh->ldata, mpoly, polynors, num_polys)) { /* XXX TODO is this still needed? */ // mesh->dirty |= DM_DIRTY_TESS_CDLAYERS; /* We need to recompute vertex normals! */ @@ -301,6 +302,7 @@ static void normalEditModifier_do_directional( MVert *mvert, const int num_verts, MEdge *medge, const int num_edges, MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys) { + const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; const bool use_parallel_normals = (enmd->flag & MOD_NORMALEDIT_USE_DIRECTION_PARALLEL) != 0; float (*nos)[3] = MEM_malloc_arrayN((size_t)num_loops, sizeof(*nos), __func__); @@ -357,7 +359,7 @@ static void normalEditModifier_do_directional( mix_limit, mix_mode, num_verts, mloop, loopnors, nos, num_loops); } - if (polygons_check_flip(mloop, nos, &mesh->ldata, mpoly, polynors, num_polys)) { + if (do_polynors_fix && polygons_check_flip(mloop, nos, &mesh->ldata, mpoly, polynors, num_polys)) { mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL; } diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index f13dac9cb4c..eaeaac45f89 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -194,7 +194,7 @@ void WM_cursor_modal_restore(wmWindow *win) void WM_cursor_wait(bool val) { if (!G.background) { - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = G_MAIN->wm.first; wmWindow *win = wm ? wm->windows.first : NULL; for (; win; win = win->next) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 00f5f6c1368..5fd7c3a24c0 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -210,7 +210,7 @@ void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference void WM_main_add_notifier(unsigned int type, void *reference) { - Main *bmain = G.main; + Main *bmain = G_MAIN; wmWindowManager *wm = bmain->wm.first; wmNotifier *note; @@ -235,7 +235,7 @@ void WM_main_add_notifier(unsigned int type, void *reference) */ void WM_main_remove_notifier_reference(const void *reference) { - Main *bmain = G.main; + Main *bmain = G_MAIN; wmWindowManager *wm = bmain->wm.first; if (wm) { @@ -263,7 +263,7 @@ void WM_main_remove_notifier_reference(const void *reference) void WM_main_remap_editor_id_reference(ID *old_id, ID *new_id) { - Main *bmain = G.main; + Main *bmain = G_MAIN; bScreen *sc; for (sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -714,7 +714,7 @@ void WM_event_print(const wmEvent *event) */ void WM_report_banner_show(void) { - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = G_MAIN->wm.first; ReportList *wm_reports = &wm->reports; ReportTimerInfo *rti; @@ -749,7 +749,7 @@ static void wm_add_reports(ReportList *reports) { /* if the caller owns them, handle this */ if (reports->list.first && (reports->flag & RPT_OP_HOLD) == 0) { - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = G_MAIN->wm.first; /* add reports to the global list, otherwise they are not seen */ BLI_movelisttolist(&wm->reports.list, &reports->list); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 3aaec875627..5e58571cdbf 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -153,8 +153,8 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) wmWindowManager *wm; wmWindow *win, *active_win; - *wmlist = G.main->wm; - BLI_listbase_clear(&G.main->wm); + *wmlist = G_MAIN->wm; + BLI_listbase_clear(&G_MAIN->wm); active_win = CTX_wm_window(C); @@ -440,12 +440,12 @@ void WM_file_autoexec_init(const char *filepath) } } -void wm_file_read_report(bContext *C) +void wm_file_read_report(bContext *C, Main *bmain) { ReportList *reports = NULL; Scene *sce; - for (sce = G.main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->r.engine[0] && BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL) { @@ -472,6 +472,7 @@ void wm_file_read_report(bContext *C) */ static void wm_file_read_post(bContext *C, const bool is_startup_file, const bool use_userdef) { + Main *bmain = CTX_data_main(C); bool addons_loaded = false; wmWindowManager *wm = CTX_wm_manager(C); @@ -483,7 +484,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo CTX_wm_window_set(C, wm->windows.first); ED_editors_init(C); - DEG_on_visible_update(CTX_data_main(C), true); + DEG_on_visible_update(bmain, true); #ifdef WITH_PYTHON if (is_startup_file) { @@ -513,8 +514,8 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo WM_operatortype_last_properties_clear_all(); /* important to do before NULL'ing the context */ - BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE); - BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST); #if 1 WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL); @@ -525,7 +526,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo /* report any errors. * currently disabled if addons aren't yet loaded */ if (addons_loaded) { - wm_file_read_report(C); + wm_file_read_report(C, bmain); } if (!G.background) { @@ -535,7 +536,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo else { BKE_undosys_stack_clear(wm->undo_stack); } - BKE_undosys_stack_init_from_main(wm->undo_stack, CTX_data_main(C)); + BKE_undosys_stack_init_from_main(wm->undo_stack, bmain); BKE_undosys_stack_init_from_context(wm->undo_stack, C); } @@ -677,7 +678,7 @@ int wm_homefile_read( bool use_factory_settings, bool use_empty_data, bool use_userdef, const char *filepath_startup_override, const char *app_template_override) { - Main *bmain = G.main; /* Context does not always have valid main pointer here... */ + Main *bmain = G_MAIN; /* Context does not always have valid main pointer here... */ ListBase wmbase; bool success = false; @@ -1099,7 +1100,7 @@ bool write_crash_blend(void) BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path)); BLI_replace_extension(path, sizeof(path), "_crash.blend"); - if (BLO_write_file(G.main, path, fileflags, NULL, NULL)) { + if (BLO_write_file(G_MAIN, path, fileflags, NULL, NULL)) { printf("written: %s\n", path); return 1; } @@ -1234,7 +1235,7 @@ void wm_autosave_location(char *filepath) const char *savedir; #endif - if (G.main && G.relbase_valid) { + if (G_MAIN && G.relbase_valid) { const char *basename = BLI_path_basename(BKE_main_blendfile_path_from_global()); int len = strlen(basename) - 6; BLI_snprintf(path, sizeof(path), "%.*s.blend", len, basename); @@ -1384,7 +1385,7 @@ void wm_open_init_use_scripts(wmOperator *op, bool use_prefs) void WM_file_tag_modified(void) { - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = G_MAIN->wm.first; if (wm->file_saved) { wm->file_saved = 0; /* notifier that data changed, for save-over warning or header */ @@ -1401,6 +1402,7 @@ void WM_file_tag_modified(void) */ static int wm_homefile_write_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); char filepath[FILE_MAX]; @@ -1413,7 +1415,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_PRE); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_PRE); /* check current window and close it if temp */ if (win && WM_window_is_temp_screen(win)) @@ -1431,7 +1433,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op) /* force save as regular blend file */ fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY); - if (BLO_write_file(CTX_data_main(C), filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) { + if (BLO_write_file(bmain, filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) { printf("fail\n"); return OPERATOR_CANCELLED; } @@ -1440,7 +1442,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op) G.save_over = 0; - BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_POST); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_POST); return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index c5a57147dd6..ebaa51e7906 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -296,7 +296,7 @@ void WM_init(bContext *C, int argc, const char **argv) /* allow a path of "", this is what happens when making a new file */ #if 0 if (BKE_main_blendfile_path_from_global()[0] == '\0') - BLI_make_file_string("/", G.main->name, BKE_appdir_folder_default(), "untitled.blend"); + BLI_make_file_string("/", G_MAIN->name, BKE_appdir_folder_default(), "untitled.blend"); #endif BLI_strncpy(G.lib, BKE_main_blendfile_path_from_global(), sizeof(G.lib)); @@ -314,6 +314,7 @@ void WM_init(bContext *C, int argc, const char **argv) /* that prevents loading both the kept session, and the file on the command line */ } else { + Main *bmain = CTX_data_main(C); /* note, logic here is from wm_file_read_post, * call functions that depend on Python being initialized. */ @@ -324,10 +325,10 @@ void WM_init(bContext *C, int argc, const char **argv) * note that recovering the last session does its own callbacks. */ CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); - BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE); - BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST); - wm_file_read_report(C); + wm_file_read_report(C, bmain); if (!G.background) { CTX_wm_window_set(C, NULL); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 67493454e8f..bbc7e6fbb69 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -828,7 +828,7 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, const Enu if (!items) { /* init modal items from default config */ - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = G_MAIN->wm.first; if (wm->defaultconf) { wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index e1528551c12..38d51c2b1da 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -553,7 +553,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) char str[sizeof(((Main *)NULL)->name) + 24]; BLI_snprintf(str, sizeof(str), "Blender%s [%s%s]", wm->file_saved ? "" : "*", BKE_main_blendfile_path_from_global(), - G.main->recovered ? " (Recovered)" : ""); + G_MAIN->recovered ? " (Recovered)" : ""); GHOST_SetTitle(win->ghostwin, str); } else diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h index 4e87202ef5f..5b6022658db 100644 --- a/source/blender/windowmanager/wm_files.h +++ b/source/blender/windowmanager/wm_files.h @@ -31,6 +31,7 @@ #ifndef __WM_FILES_H__ #define __WM_FILES_H__ +struct Main; struct wmOperatorType; /* wm_files.c */ @@ -39,7 +40,7 @@ int wm_homefile_read( struct bContext *C, struct ReportList *reports, bool use_factory_settings, bool use_empty_data, bool use_userdef, const char *filepath_startup_override, const char *app_template_override); -void wm_file_read_report(bContext *C); +void wm_file_read_report(bContext *C, struct Main *bmain); void WM_OT_save_homefile(struct wmOperatorType *ot); void WM_OT_userpref_autoexec_path_add(struct wmOperatorType *ot); |