forked from bartvdbraak/blender
Merge branch 'master' into blender2.8
Conflicts: source/blender/modifiers/intern/MOD_normal_edit.c source/blender/windowmanager/intern/wm_files.c
This commit is contained in:
commit
4bf751be70
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user