diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-22 14:50:17 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-22 14:50:17 +0300 |
commit | 5d2b3a966eb2bce71c1effb4c79cf0f23c1d5bf5 (patch) | |
tree | 3d16bf1c7727eb29739863bf788200199bf9200a /source | |
parent | 4e6f86942cd4f99e73e81e3cc7fa00aa16932986 (diff) | |
parent | 69b5165902d3e433af5b3ece633903162cbc292a (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_blendfile.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 10 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 108 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 141 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_KeyingOperation.cpp | 17 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_utils.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 83 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 29 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 47 |
13 files changed, 221 insertions, 236 deletions
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h index d9fff5343b0..0a8eac7961a 100644 --- a/source/blender/blenkernel/BKE_blendfile.h +++ b/source/blender/blenkernel/BKE_blendfile.h @@ -58,13 +58,12 @@ struct UserDef *BKE_blendfile_userdef_read_from_memory( const void *filebuf, int filelength, struct ReportList *reports); -int BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports); +bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports); struct WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, struct ReportList *reports); bool BKE_blendfile_workspace_config_write(struct Main *bmain, const char *filepath, struct ReportList *reports); void BKE_blendfile_workspace_config_data_free(struct WorkspaceConfigFileData *workspace_config); - /* partial blend file writing */ void BKE_blendfile_write_partial_tag_ID(struct ID *id, bool set); void BKE_blendfile_write_partial_begin(struct Main *bmain_src); diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 211f92c2e78..6df008e7ac9 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -521,19 +521,22 @@ UserDef *BKE_blendfile_userdef_read_from_memory( } -/* only write the userdef in a .blend */ -int BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) +/** + * Only write the userdef in a .blend + * \return success + */ +bool BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) { Main *mainb = MEM_callocN(sizeof(Main), "empty main"); - int retval = 0; + bool ok = false; if (BLO_write_file(mainb, filepath, G_FILE_USERPREFS, reports, NULL)) { - retval = 1; + ok = true; } MEM_freeN(mainb); - return retval; + return ok; } WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, ReportList *reports) diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 382b26abbc6..9c85a26b58a 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1775,7 +1775,7 @@ void driver_variable_name_validate(DriverVar *dvar) /* 1) Must start with a letter */ /* XXX: We assume that valid unicode letters in other languages are ok too, hence the blacklisting */ - if (ELEM(dvar->name[0], '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')) { + if (IN_RANGE_INCL(dvar->name[0], '0', '9')) { dvar->flag |= DVAR_FLAG_INVALID_START_NUM; } else if (dvar->name[0] == '_') { diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index fbb64f3ece2..2f961701801 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -508,14 +508,16 @@ void BLI_spin_unlock(SpinLock *spin) #endif } -void BLI_spin_end(SpinLock *spin) +#if defined(__APPLE__) || defined(_MSC_VER) +void BLI_spin_end(SpinLock *UNUSED(spin)) { -#if defined(__APPLE__) -#elif defined(_MSC_VER) +} #else +void BLI_spin_end(SpinLock *spin) +{ pthread_spin_destroy(spin); -#endif } +#endif /* Read/Write Mutex Lock */ diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 7f2032d5f53..432c82afe4a 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -57,7 +57,6 @@ static void recount_totsels(BMesh *bm) tots[1] = &bm->totedgesel; tots[2] = &bm->totfacesel; -#pragma omp parallel for schedule(static) if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { BMIter iter; BMElem *ele; @@ -253,44 +252,34 @@ void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode) if (selectmode & SCE_SELECT_VERTEX) { /* both loops only set edge/face flags and read off verts */ -#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT) - { -#pragma omp section + BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && + BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { - BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) - { - BM_elem_flag_enable(e, BM_ELEM_SELECT); - } - else { - BM_elem_flag_disable(e, BM_ELEM_SELECT); - } - } + BM_elem_flag_enable(e, BM_ELEM_SELECT); } -#pragma omp section - { - BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - bool ok = true; - if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { - ok = false; - break; - } - } while ((l_iter = l_iter->next) != l_first); - } - else { + else { + BM_elem_flag_disable(e, BM_ELEM_SELECT); + } + } + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + bool ok = true; + if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { ok = false; + break; } - - BM_elem_flag_set(f, BM_ELEM_SELECT, ok); - } + } while ((l_iter = l_iter->next) != l_first); } + else { + ok = false; + } + + BM_elem_flag_set(f, BM_ELEM_SELECT, ok); } - /* end sections */ } else if (selectmode & SCE_SELECT_EDGE) { BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { @@ -375,42 +364,31 @@ void BM_mesh_select_flush(BMesh *bm) bool ok; - /* we can use 2 sections here because the second loop isnt checking edge selection */ -#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT) - { -#pragma omp section + BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && + BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { - BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) - { - BM_elem_flag_enable(e, BM_ELEM_SELECT); - } - } + BM_elem_flag_enable(e, BM_ELEM_SELECT); } - -#pragma omp section - { - BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - ok = true; - if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { - ok = false; - break; - } - } while ((l_iter = l_iter->next) != l_first); - } - else { + } + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + ok = true; + if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { ok = false; + break; } + } while ((l_iter = l_iter->next) != l_first); + } + else { + ok = false; + } - if (ok) { - BM_elem_flag_enable(f, BM_ELEM_SELECT); - } - } + if (ok) { + BM_elem_flag_enable(f, BM_ELEM_SELECT); } } @@ -1107,8 +1085,6 @@ void BM_mesh_elem_hflag_disable_test( { /* fast path for deselect all, avoid topology loops * since we know all will be de-selected anyway. */ - -#pragma omp parallel for schedule(static) if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { BMIter iter; BMElem *ele; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 44445aae25a..3e12a43e457 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -550,37 +550,30 @@ static int bmo_mesh_flag_count( { int count_vert = 0, count_edge = 0, count_face = 0; -#pragma omp parallel sections if ((bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) && \ - (ELEM(htype, BM_VERT, BM_EDGE, BM_FACE) == 0)) - { -#pragma omp section - if (htype & BM_VERT) { - BMIter iter; - BMVert *ele; - BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { - if (BMO_vert_flag_test_bool(bm, ele, oflag) == test_for_enabled) { - count_vert++; - } + if (htype & BM_VERT) { + BMIter iter; + BMVert *ele; + BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { + if (BMO_vert_flag_test_bool(bm, ele, oflag) == test_for_enabled) { + count_vert++; } } -#pragma omp section - if (htype & BM_EDGE) { - BMIter iter; - BMEdge *ele; - BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { - if (BMO_edge_flag_test_bool(bm, ele, oflag) == test_for_enabled) { - count_edge++; - } + } + if (htype & BM_EDGE) { + BMIter iter; + BMEdge *ele; + BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { + if (BMO_edge_flag_test_bool(bm, ele, oflag) == test_for_enabled) { + count_edge++; } } -#pragma omp section - if (htype & BM_FACE) { - BMIter iter; - BMFace *ele; - BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { - if (BMO_face_flag_test_bool(bm, ele, oflag) == test_for_enabled) { - count_face++; - } + } + if (htype & BM_FACE) { + BMIter iter; + BMFace *ele; + BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { + if (BMO_face_flag_test_bool(bm, ele, oflag) == test_for_enabled) { + count_face++; } } } @@ -601,33 +594,25 @@ int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag) void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char htype, const short oflag) { - -#pragma omp parallel sections if ((bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) && \ - (ELEM(htype, BM_VERT, BM_EDGE, BM_FACE) == 0)) - { -#pragma omp section - if (htype & BM_VERT) { - BMIter iter; - BMVert *ele; - BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { - BMO_vert_flag_disable(bm, ele, oflag); - } + if (htype & BM_VERT) { + BMIter iter; + BMVert *ele; + BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { + BMO_vert_flag_disable(bm, ele, oflag); } -#pragma omp section - if (htype & BM_EDGE) { - BMIter iter; - BMEdge *ele; - BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { - BMO_edge_flag_disable(bm, ele, oflag); - } + } + if (htype & BM_EDGE) { + BMIter iter; + BMEdge *ele; + BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { + BMO_edge_flag_disable(bm, ele, oflag); } -#pragma omp section - if (htype & BM_FACE) { - BMIter iter; - BMFace *ele; - BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { - BMO_face_flag_disable(bm, ele, oflag); - } + } + if (htype & BM_FACE) { + BMIter iter; + BMFace *ele; + BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { + BMO_face_flag_disable(bm, ele, oflag); } } } @@ -1383,38 +1368,32 @@ static void bmo_flag_layer_clear(BMesh *bm) const int totflags_offset = bm->totflags - 1; -#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) + /* now go through and memcpy all the flag */ { - /* now go through and memcpy all the flag */ -#pragma omp section - { - BMIter iter; - BMVert_OFlag *ele; - int i; - BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) { - ele->oflags[totflags_offset] = zero_flag; - BM_elem_index_set(&ele->base, i); /* set_inline */ - } + BMIter iter; + BMVert_OFlag *ele; + int i; + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) { + ele->oflags[totflags_offset] = zero_flag; + BM_elem_index_set(&ele->base, i); /* set_inline */ } -#pragma omp section - { - BMIter iter; - BMEdge_OFlag *ele; - int i; - BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) { - ele->oflags[totflags_offset] = zero_flag; - BM_elem_index_set(&ele->base, i); /* set_inline */ - } + } + { + BMIter iter; + BMEdge_OFlag *ele; + int i; + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) { + ele->oflags[totflags_offset] = zero_flag; + BM_elem_index_set(&ele->base, i); /* set_inline */ } -#pragma omp section - { - BMIter iter; - BMFace_OFlag *ele; - int i; - BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) { - ele->oflags[totflags_offset] = zero_flag; - BM_elem_index_set(&ele->base, i); /* set_inline */ - } + } + { + BMIter iter; + BMFace_OFlag *ele; + int i; + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) { + ele->oflags[totflags_offset] = zero_flag; + BM_elem_index_set(&ele->base, i); /* set_inline */ } } diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index e2566d2f4f0..fa0ef70fca6 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -67,15 +67,16 @@ void KeyingOperation::deinitExecution() void KeyingOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { - float pixelColor[4]; - float screenColor[4]; + float pixel_color[4]; + float screen_color[4]; - this->m_pixelReader->readSampled(pixelColor, x, y, sampler); - this->m_screenReader->readSampled(screenColor, x, y, sampler); + this->m_pixelReader->readSampled(pixel_color, x, y, sampler); + this->m_screenReader->readSampled(screen_color, x, y, sampler); - const int primary_channel = max_axis_v3(screenColor); + const int primary_channel = max_axis_v3(screen_color); + const float min_pixel_color = min_fff(pixel_color[0], pixel_color[1], pixel_color[2]); - if (pixelColor[primary_channel] > 1.0f) { + if (min_pixel_color > 1.0f) { /* overexposure doesn't happen on screen itself and usually happens * on light sources in the shot, this need to be checked separately * because saturation and falloff calculation is based on the fact @@ -84,8 +85,8 @@ void KeyingOperation::executePixelSampled(float output[4], float x, float y, Pix output[0] = 1.0f; } else { - float saturation = get_pixel_saturation(pixelColor, this->m_screenBalance, primary_channel); - float screen_saturation = get_pixel_saturation(screenColor, this->m_screenBalance, primary_channel); + float saturation = get_pixel_saturation(pixel_color, this->m_screenBalance, primary_channel); + float screen_saturation = get_pixel_saturation(screen_color, this->m_screenBalance, primary_channel); if (saturation < 0) { /* means main channel of pixel is different from screen, diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 0ad73dd45c8..230f46abad1 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -1236,7 +1236,6 @@ void EDBM_mesh_reveal(BMEditMesh *em, bool select) /* Use tag flag to remember what was hidden before all is revealed. * BM_ELEM_HIDDEN --> BM_ELEM_TAG */ -#pragma omp parallel for schedule(static) if (em->bm->totvert + em->bm->totedge + em->bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { BMIter iter; BMElem *ele; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 49c687632f8..0b6bacfbe68 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -361,7 +361,7 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); - RNA_def_enum_funcs(prop, RNA_scene_itemf); + RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf); RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); ot->prop = prop; } diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 760ddb34368..c8995e7a2ad 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -238,6 +238,7 @@ const EnumPropertyItem *RNA_group_local_itemf(struct bContext *C, struct Pointer const EnumPropertyItem *RNA_image_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_image_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_scene_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); +const EnumPropertyItem *RNA_scene_without_active_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_scene_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_movieclip_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_movieclip_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index bc24b76c137..62360ea34a3 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -596,99 +596,100 @@ static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[2] = (&mcol[0].r)[0] / 255.0f; - values[1] = (&mcol[0].r)[1] / 255.0f; - values[0] = (&mcol[0].r)[2] / 255.0f; + values[3] = mcol[0].a / 255.0f; + values[2] = mcol[0].r / 255.0f; + values[1] = mcol[0].g / 255.0f; + values[0] = mcol[0].b / 255.0f; } static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[0].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol[0].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol[0].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol[0].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[0].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[0].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[0].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[0].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[3] = (&mcol[1].r)[3] / 255.0f; - values[2] = (&mcol[1].r)[0] / 255.0f; - values[1] = (&mcol[1].r)[1] / 255.0f; - values[0] = (&mcol[1].r)[2] / 255.0f; + values[3] = mcol[1].a / 255.0f; + values[2] = mcol[1].r / 255.0f; + values[1] = mcol[1].g / 255.0f; + values[0] = mcol[1].b / 255.0f; } static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[1].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol[1].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol[1].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol[1].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[1].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[1].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[1].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[1].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[3] = (&mcol[2].r)[3] / 255.0f; - values[2] = (&mcol[2].r)[0] / 255.0f; - values[1] = (&mcol[2].r)[1] / 255.0f; - values[0] = (&mcol[2].r)[2] / 255.0f; + values[3] = mcol[2].a / 255.0f; + values[2] = mcol[2].r / 255.0f; + values[1] = mcol[2].g / 255.0f; + values[0] = mcol[2].b / 255.0f; } static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[2].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol[2].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol[2].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol[2].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[2].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[2].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[2].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[2].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[2] = (&mcol[3].r)[0] / 255.0f; - values[1] = (&mcol[3].r)[1] / 255.0f; - values[0] = (&mcol[3].r)[2] / 255.0f; - values[3] = (&mcol[3].r)[3] / 255.0f; + values[3] = mcol[3].a / 255.0f; + values[2] = mcol[3].r / 255.0f; + values[1] = mcol[3].g / 255.0f; + values[0] = mcol[3].b / 255.0f; } static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[3].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol[3].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol[3].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol[3].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[3].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[3].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[3].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[3].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values) { - MLoopCol *mcol = (MLoopCol *)ptr->data; + MLoopCol *mlcol = (MLoopCol *)ptr->data; - values[0] = (&mcol->r)[0] / 255.0f; - values[1] = (&mcol->r)[1] / 255.0f; - values[2] = (&mcol->r)[2] / 255.0f; - values[3] = (&mcol->r)[3] / 255.0f; + values[0] = mlcol->r / 255.0f; + values[1] = mlcol->g / 255.0f; + values[2] = mlcol->b / 255.0f; + values[3] = mlcol->a / 255.0f; } static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values) { - MLoopCol *mcol = (MLoopCol *)ptr->data; + MLoopCol *mlcol = (MLoopCol *)ptr->data; - (&mcol->r)[0] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol->r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol->r)[2] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol->r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mlcol->r = round_fl_to_uchar_clamp(values[0] * 255.0f); + mlcol->g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mlcol->b = round_fl_to_uchar_clamp(values[2] * 255.0f); + mlcol->a = round_fl_to_uchar_clamp(values[3] * 255.0f); } static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info)) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 81c6443b2d9..f9bf47daf30 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1478,7 +1478,7 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op) wmWindowManager *wm = CTX_wm_manager(C); char filepath[FILE_MAX]; const char *cfgdir; - bool ok = false; + bool ok = true; /* update keymaps in user preferences */ WM_keyconfig_update(wm); @@ -1488,31 +1488,34 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op) printf("trying to save userpref at %s ", filepath); if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) { printf("ok\n"); - ok = true; } else { printf("fail\n"); + ok = false; } } else { BKE_report(op->reports, RPT_ERROR, "Unable to create userpref path"); } - if (U.app_template[0] && (cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) { - /* Also save app-template prefs */ - BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); - printf("trying to save app-template userpref at %s ", filepath); - if (BKE_blendfile_userdef_write(filepath, op->reports) == 0) { - printf("fail\n"); - ok = true; + if (U.app_template[0]) { + if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) { + /* Also save app-template prefs */ + BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); + printf("trying to save app-template userpref at %s ", filepath); + if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) { + printf("ok\n"); + } + else { + printf("fail\n"); + ok = false; + } } else { - printf("ok\n"); + BKE_report(op->reports, RPT_ERROR, "Unable to create app-template userpref path"); + ok = false; } } - else if (U.app_template[0]) { - BKE_report(op->reports, RPT_ERROR, "Unable to create app-template userpref path"); - } return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d98d66f178d..7785278d77f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3993,14 +3993,29 @@ void wm_window_keymap(wmKeyConfig *keyconf) gesture_straightline_modal_keymap(keyconf); } +/** + * Filter functions that can be used with rna_id_itemf() below. + * Should return false if 'id' should be excluded. + */ +static bool rna_id_enum_filter_single(ID *id, void *user_data) +{ + return (id != user_data); +} + /* Generic itemf's for operators that take library args */ -static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), bool *r_free, ID *id, bool local) +static const EnumPropertyItem *rna_id_itemf( + bContext *UNUSED(C), PointerRNA *UNUSED(ptr), + bool *r_free, ID *id, bool local, + bool (*filter_ids)(ID *id, void *user_data), void *user_data) { EnumPropertyItem item_tmp = {0}, *item = NULL; int totitem = 0; int i = 0; for (; id; id = id->next) { + if ((filter_ids != NULL) && filter_ids(user_data, id) == false) { + continue; + } if (local == false || !ID_IS_LINKED(id)) { item_tmp.identifier = item_tmp.name = id->name + 2; item_tmp.value = i++; @@ -4017,7 +4032,7 @@ static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNU /* can add more as needed */ const EnumPropertyItem *RNA_action_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, false, NULL, NULL); } #if 0 /* UNUSED */ const EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) @@ -4028,45 +4043,51 @@ const EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, Pro const EnumPropertyItem *RNA_group_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_group_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, true, NULL, NULL); } const EnumPropertyItem *RNA_image_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_image_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, true, NULL, NULL); } const EnumPropertyItem *RNA_scene_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_scene_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true, NULL, NULL); +} +const EnumPropertyItem *RNA_scene_without_active_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +{ + Scene *scene_active = C ? CTX_data_scene(C) : NULL; + return rna_id_itemf( + C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true, + rna_id_enum_filter_single, scene_active); } - const EnumPropertyItem *RNA_movieclip_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_movieclip_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, true, NULL, NULL); } const EnumPropertyItem *RNA_mask_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_mask_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, true, NULL, NULL); } |