diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt index ede0818e948..217e57452e2 100644 --- a/source/blender/editors/io/CMakeLists.txt +++ b/source/blender/editors/io/CMakeLists.txt @@ -28,27 +28,27 @@ set(INC_SYS ) set(SRC - io_alembic.c - io_cache.c - io_collada.c - io_gpencil_export.c - io_gpencil_import.c - io_gpencil_utils.c - io_obj.c - io_ops.c - io_ply_ops.c - io_stl_ops.c - io_usd.c + io_alembic.cc + io_cache.cc + io_collada.cc + io_gpencil_export.cc + io_gpencil_import.cc + io_gpencil_utils.cc + io_obj.cc + io_ops.cc + io_ply_ops.cc + io_stl_ops.cc + io_usd.cc - io_alembic.h - io_cache.h - io_collada.h - io_gpencil.h - io_obj.h + io_alembic.hh + io_cache.hh + io_collada.hh + io_gpencil.hh + io_obj.hh io_ops.h - io_ply_ops.h - io_stl_ops.h - io_usd.h + io_ply_ops.hh + io_stl_ops.hh + io_usd.hh ) set(LIB diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.cc similarity index 83% rename from source/blender/editors/io/io_alembic.c rename to source/blender/editors/io/io_alembic.cc index 4d396deb7d2..aea3e0e14c3 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.cc @@ -15,8 +15,8 @@ # include "BLI_winstuff.h" # endif -# include -# include +# include +# include # include "MEM_guardedalloc.h" @@ -51,7 +51,7 @@ # include "DEG_depsgraph.h" -# include "io_alembic.h" +# include "io_alembic.hh" # include "ABC_alembic.h" @@ -66,10 +66,10 @@ const EnumPropertyItem rna_enum_abc_export_evaluation_mode_items[] = { 0, "Viewport", "Use Viewport settings for object visibility, modifier settings, etc"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; -static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *event) +static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { if (!RNA_struct_property_is_set(op->ptr, "as_background_job")) { RNA_boolean_set(op->ptr, "as_background_job", true); @@ -82,8 +82,6 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent * WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - - UNUSED_VARS(event); } static int wm_alembic_export_exec(bContext *C, wmOperator *op) @@ -96,39 +94,38 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op) char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - struct AlembicExportParams params = { - .frame_start = RNA_int_get(op->ptr, "start"), - .frame_end = RNA_int_get(op->ptr, "end"), + AlembicExportParams params{}; + params.frame_start = RNA_int_get(op->ptr, "start"); + params.frame_end = RNA_int_get(op->ptr, "end"); - .frame_samples_xform = RNA_int_get(op->ptr, "xsamples"), - .frame_samples_shape = RNA_int_get(op->ptr, "gsamples"), + params.frame_samples_xform = RNA_int_get(op->ptr, "xsamples"); + params.frame_samples_shape = RNA_int_get(op->ptr, "gsamples"); - .shutter_open = RNA_float_get(op->ptr, "sh_open"), - .shutter_close = RNA_float_get(op->ptr, "sh_close"), + params.shutter_open = RNA_float_get(op->ptr, "sh_open"); + params.shutter_close = RNA_float_get(op->ptr, "sh_close"); - .selected_only = RNA_boolean_get(op->ptr, "selected"), - .uvs = RNA_boolean_get(op->ptr, "uvs"), - .normals = RNA_boolean_get(op->ptr, "normals"), - .vcolors = RNA_boolean_get(op->ptr, "vcolors"), - .orcos = RNA_boolean_get(op->ptr, "orcos"), - .apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"), - .curves_as_mesh = RNA_boolean_get(op->ptr, "curves_as_mesh"), - .flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"), - .visible_objects_only = RNA_boolean_get(op->ptr, "visible_objects_only"), - .face_sets = RNA_boolean_get(op->ptr, "face_sets"), - .use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"), - .export_hair = RNA_boolean_get(op->ptr, "export_hair"), - .export_particles = RNA_boolean_get(op->ptr, "export_particles"), - .export_custom_properties = RNA_boolean_get(op->ptr, "export_custom_properties"), - .use_instancing = RNA_boolean_get(op->ptr, "use_instancing"), - .packuv = RNA_boolean_get(op->ptr, "packuv"), - .triangulate = RNA_boolean_get(op->ptr, "triangulate"), - .quad_method = RNA_enum_get(op->ptr, "quad_method"), - .ngon_method = RNA_enum_get(op->ptr, "ngon_method"), - .evaluation_mode = RNA_enum_get(op->ptr, "evaluation_mode"), + params.selected_only = RNA_boolean_get(op->ptr, "selected"); + params.uvs = RNA_boolean_get(op->ptr, "uvs"); + params.normals = RNA_boolean_get(op->ptr, "normals"); + params.vcolors = RNA_boolean_get(op->ptr, "vcolors"); + params.orcos = RNA_boolean_get(op->ptr, "orcos"); + params.apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"); + params.curves_as_mesh = RNA_boolean_get(op->ptr, "curves_as_mesh"); + params.flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"); + params.visible_objects_only = RNA_boolean_get(op->ptr, "visible_objects_only"); + params.face_sets = RNA_boolean_get(op->ptr, "face_sets"); + params.use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"); + params.export_hair = RNA_boolean_get(op->ptr, "export_hair"); + params.export_particles = RNA_boolean_get(op->ptr, "export_particles"); + params.export_custom_properties = RNA_boolean_get(op->ptr, "export_custom_properties"); + params.use_instancing = RNA_boolean_get(op->ptr, "use_instancing"); + params.packuv = RNA_boolean_get(op->ptr, "packuv"); + params.triangulate = RNA_boolean_get(op->ptr, "triangulate"); + params.quad_method = RNA_enum_get(op->ptr, "quad_method"); + params.ngon_method = RNA_enum_get(op->ptr, "ngon_method"); + params.evaluation_mode = eEvaluationMode(RNA_enum_get(op->ptr, "evaluation_mode")); - .global_scale = RNA_float_get(op->ptr, "global_scale"), - }; + params.global_scale = RNA_float_get(op->ptr, "global_scale"); /* Take some defaults from the scene, if not specified explicitly. */ Scene *scene = CTX_data_scene(C); @@ -155,7 +152,7 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) box = uiLayoutBox(layout); uiItemL(box, IFACE_("Manual Transform"), ICON_NONE); - uiItemR(box, imfptr, "global_scale", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "global_scale", 0, nullptr, ICON_NONE); /* Scene Options */ box = uiLayoutBox(layout); @@ -172,12 +169,12 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) uiItemR(col, imfptr, "gsamples", 0, IFACE_("Geometry"), ICON_NONE); sub = uiLayoutColumn(col, true); - uiItemR(sub, imfptr, "sh_open", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(sub, imfptr, "sh_open", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); uiItemR(sub, imfptr, "sh_close", UI_ITEM_R_SLIDER, IFACE_("Close"), ICON_NONE); uiItemS(col); - uiItemR(col, imfptr, "flatten", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "flatten", 0, nullptr, ICON_NONE); uiItemR(sub, imfptr, "use_instancing", 0, IFACE_("Use Instancing"), ICON_NONE); uiItemR(sub, imfptr, "export_custom_properties", 0, IFACE_("Custom Properties"), ICON_NONE); @@ -186,7 +183,7 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) uiItemR(sub, imfptr, "visible_objects_only", 0, IFACE_("Visible Objects"), ICON_NONE); col = uiLayoutColumn(box, true); - uiItemR(col, imfptr, "evaluation_mode", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "evaluation_mode", 0, nullptr, ICON_NONE); /* Object Data */ box = uiLayoutBox(layout); @@ -195,16 +192,16 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "uvs", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "uvs", 0, nullptr, ICON_NONE); row = uiLayoutRow(col, false); uiLayoutSetActive(row, RNA_boolean_get(imfptr, "uvs")); - uiItemR(row, imfptr, "packuv", 0, NULL, ICON_NONE); + uiItemR(row, imfptr, "packuv", 0, nullptr, ICON_NONE); - uiItemR(col, imfptr, "normals", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "vcolors", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "orcos", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "face_sets", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "curves_as_mesh", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "normals", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "vcolors", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "orcos", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "face_sets", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "curves_as_mesh", 0, nullptr, ICON_NONE); uiItemS(col); @@ -215,7 +212,7 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) uiItemS(col); col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "triangulate", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "triangulate", 0, nullptr, ICON_NONE); sub = uiLayoutColumn(col, false); uiLayoutSetActive(sub, RNA_boolean_get(imfptr, "triangulate")); uiItemR(sub, imfptr, "quad_method", 0, IFACE_("Method Quads"), ICON_NONE); @@ -227,8 +224,8 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) uiItemL(row, IFACE_("Particle Systems"), ICON_PARTICLE_DATA); col = uiLayoutColumn(box, true); - uiItemR(col, imfptr, "export_hair", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "export_particles", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "export_hair", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "export_particles", 0, nullptr, ICON_NONE); } static void wm_alembic_export_draw(bContext *C, wmOperator *op) @@ -236,7 +233,7 @@ static void wm_alembic_export_draw(bContext *C, wmOperator *op) /* Conveniently set start and end frame to match the scene's frame range. */ Scene *scene = CTX_data_scene(C); - if (scene != NULL && RNA_boolean_get(op->ptr, "init_scene_frame_range")) { + if (scene != nullptr && RNA_boolean_get(op->ptr, "init_scene_frame_range")) { RNA_int_set(op->ptr, "start", scene->r.sfra); RNA_int_set(op->ptr, "end", scene->r.efra); @@ -246,7 +243,7 @@ static void wm_alembic_export_draw(bContext *C, wmOperator *op) ui_alembic_export_settings(op->layout, op->ptr); } -static bool wm_alembic_export_check(bContext *UNUSED(C), wmOperator *op) +static bool wm_alembic_export_check(bContext * /*C*/, wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); @@ -475,15 +472,15 @@ void WM_OT_alembic_export(wmOperatorType *ot) /* TODO(kevin): check on de-duplicating all this with code in image_ops.c */ -typedef struct CacheFrame { +struct CacheFrame { struct CacheFrame *next, *prev; int framenr; -} CacheFrame; +}; static int cmp_frame(const void *a, const void *b) { - const CacheFrame *frame_a = a; - const CacheFrame *frame_b = b; + const CacheFrame *frame_a = static_cast(a); + const CacheFrame *frame_b = static_cast(b); if (frame_a->framenr < frame_b->framenr) { return -1; @@ -515,7 +512,7 @@ static int get_sequence_len(const char *filepath, int *ofs) } DIR *dir = opendir(dirpath); - if (dir == NULL) { + if (dir == nullptr) { fprintf(stderr, "Error opening directory '%s': %s\n", dirpath, @@ -527,11 +524,11 @@ static int get_sequence_len(const char *filepath, int *ofs) const char *basename = BLI_path_basename(filepath); const int len = strlen(basename) - (numdigit + strlen(ext)); - ListBase frames; + ListBase frames{}; BLI_listbase_clear(&frames); - struct dirent *fname; - while ((fname = readdir(dir)) != NULL) { + dirent *fname; + while ((fname = readdir(dir)) != nullptr) { /* do we have the right extension? */ if (!strstr(fname->d_name, ext)) { continue; @@ -541,7 +538,7 @@ static int get_sequence_len(const char *filepath, int *ofs) continue; } - CacheFrame *cache_frame = MEM_callocN(sizeof(CacheFrame), "abc_frame"); + CacheFrame *cache_frame = MEM_cnew("abc_frame"); BLI_path_frame_get(fname->d_name, &cache_frame->framenr, &numdigit); @@ -552,9 +549,9 @@ static int get_sequence_len(const char *filepath, int *ofs) BLI_listbase_sort(&frames, cmp_frame); - CacheFrame *cache_frame = frames.first; + CacheFrame *cache_frame = static_cast(frames.first); - if (cache_frame) { + if (cache_frame != nullptr) { int frame_curr = cache_frame->framenr; (*ofs) = frame_curr; @@ -583,21 +580,21 @@ static void ui_alembic_import_settings(uiLayout *layout, PointerRNA *imfptr) uiLayout *row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Manual Transform"), ICON_NONE); - uiItemR(box, imfptr, "scale", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "scale", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Options"), ICON_NONE); uiLayout *col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "relative_path", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "set_frame_range", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "is_sequence", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "validate_meshes", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "always_add_cache_reader", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "relative_path", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "set_frame_range", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "is_sequence", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "validate_meshes", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "always_add_cache_reader", 0, nullptr, ICON_NONE); } -static void wm_alembic_import_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_alembic_import_draw(bContext * /*C*/, wmOperator *op) { ui_alembic_import_settings(op->layout, op->ptr); } @@ -645,7 +642,7 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op) ED_object_mode_set(C, OB_MODE_OBJECT); } - struct AlembicImportParams params = {0}; + AlembicImportParams params = {0}; params.global_scale = scale; params.sequence_len = sequence_len; params.sequence_offset = offset; diff --git a/source/blender/editors/io/io_alembic.h b/source/blender/editors/io/io_alembic.hh similarity index 100% rename from source/blender/editors/io/io_alembic.h rename to source/blender/editors/io/io_alembic.hh diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.cc similarity index 87% rename from source/blender/editors/io/io_cache.c rename to source/blender/editors/io/io_cache.cc index afb6c1fa9dc..ee012b35ec2 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.cc @@ -31,7 +31,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "io_cache.h" +#include "io_cache.hh" static void reload_cachefile(bContext *C, CacheFile *cache_file) { @@ -43,11 +43,11 @@ static void cachefile_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; - op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); + op->customdata = pprop = MEM_cnew("OpenPropertyPointerRNA"); UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop); } -static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent *event) +static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; @@ -63,14 +63,12 @@ static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent *eve WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - - UNUSED_VARS(event); } -static void open_cancel(bContext *UNUSED(C), wmOperator *op) +static void open_cancel(bContext * /*C*/, wmOperator *op) { MEM_freeN(op->customdata); - op->customdata = NULL; + op->customdata = nullptr; } static int cachefile_open_exec(bContext *C, wmOperator *op) @@ -85,22 +83,23 @@ static int cachefile_open_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); - CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filepath), 0); + CacheFile *cache_file = static_cast( + BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filepath), 0)); STRNCPY(cache_file->filepath, filepath); DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE); /* Will be set when running invoke, not exec directly. */ - if (op->customdata != NULL) { + if (op->customdata != nullptr) { /* hook into UI */ - PropertyPointerRNA *pprop = op->customdata; - if (pprop->prop) { + PropertyPointerRNA *pprop = static_cast(op->customdata); + if (pprop->prop != nullptr) { /* When creating new ID blocks, use is already 1, but RNA * pointer see also increases user, so this compensates it. */ id_us_min(&cache_file->id); PointerRNA idptr; RNA_id_pointer_create(&cache_file->id, &idptr); - RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, NULL); + RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, nullptr); RNA_property_update(C, &pprop->ptr, pprop->prop); } @@ -131,11 +130,11 @@ void CACHEFILE_OT_open(wmOperatorType *ot) /* ***************************** Reload Operator **************************** */ -static int cachefile_reload_exec(bContext *C, wmOperator *UNUSED(op)) +static int cachefile_reload_exec(bContext *C, wmOperator * /*op*/) { CacheFile *cache_file = CTX_data_edit_cachefile(C); - if (!cache_file) { + if (cache_file == nullptr) { return OPERATOR_CANCELLED; } @@ -159,7 +158,7 @@ void CACHEFILE_OT_reload(wmOperatorType *ot) /* ***************************** Add Layer Operator **************************** */ -static int cachefile_layer_open_invoke(bContext *C, wmOperator *op, const wmEvent *event) +static int cachefile_layer_open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; @@ -176,8 +175,6 @@ static int cachefile_layer_open_invoke(bContext *C, wmOperator *op, const wmEven WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - - UNUSED_VARS(event); } static int cachefile_layer_add_exec(bContext *C, wmOperator *op) @@ -187,9 +184,9 @@ static int cachefile_layer_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - CacheFile *cache_file = op->customdata; + CacheFile *cache_file = static_cast(op->customdata); - if (!cache_file) { + if (cache_file == nullptr) { return OPERATOR_CANCELLED; } @@ -198,13 +195,13 @@ static int cachefile_layer_add_exec(bContext *C, wmOperator *op) CacheFileLayer *layer = BKE_cachefile_add_layer(cache_file, filepath); - if (!layer) { + if (layer == nullptr) { WM_report(RPT_ERROR, "Could not add a layer to the cache file"); return OPERATOR_CANCELLED; } reload_cachefile(C, cache_file); - WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, nullptr); return OPERATOR_FINISHED; } @@ -229,11 +226,11 @@ void CACHEFILE_OT_layer_add(wmOperatorType *ot) /* ***************************** Remove Layer Operator **************************** */ -static int cachefile_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) +static int cachefile_layer_remove_exec(bContext *C, wmOperator * /*op*/) { CacheFile *cache_file = CTX_data_edit_cachefile(C); - if (!cache_file) { + if (cache_file == nullptr) { return OPERATOR_CANCELLED; } @@ -241,7 +238,7 @@ static int cachefile_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) BKE_cachefile_remove_layer(cache_file, layer); reload_cachefile(C, cache_file); - WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, nullptr); return OPERATOR_FINISHED; } @@ -264,13 +261,13 @@ static int cachefile_layer_move_exec(bContext *C, wmOperator *op) { CacheFile *cache_file = CTX_data_edit_cachefile(C); - if (!cache_file) { + if (cache_file == nullptr) { return OPERATOR_CANCELLED; } CacheFileLayer *layer = BKE_cachefile_get_active_layer(cache_file); - if (!layer) { + if (layer == nullptr) { return OPERATOR_CANCELLED; } @@ -280,7 +277,7 @@ static int cachefile_layer_move_exec(bContext *C, wmOperator *op) cache_file->active_layer = BLI_findindex(&cache_file->layers, layer) + 1; /* Only reload if something moved, might be expensive. */ reload_cachefile(C, cache_file); - WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, nullptr); } return OPERATOR_FINISHED; @@ -291,7 +288,7 @@ void CACHEFILE_OT_layer_move(wmOperatorType *ot) static const EnumPropertyItem layer_slot_move[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; ot->name = "Move layer"; diff --git a/source/blender/editors/io/io_cache.h b/source/blender/editors/io/io_cache.hh similarity index 100% rename from source/blender/editors/io/io_cache.h rename to source/blender/editors/io/io_cache.hh diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.cc similarity index 89% rename from source/blender/editors/io/io_collada.c rename to source/blender/editors/io/io_collada.cc index 6672223f26b..23c6f21693e 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.cc @@ -34,9 +34,9 @@ # include "collada.h" -# include "io_collada.h" +# include "io_collada.hh" -static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { ED_fileselect_ensure_default_filepath(C, op, ".dae"); @@ -156,16 +156,16 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) // Scene *scene = CTX_data_scene(C); - ExportSettings export_settings; + ExportSettings export_settings{}; export_settings.filepath = filepath; export_settings.apply_modifiers = apply_modifiers != 0; - export_settings.global_forward = global_forward; - export_settings.global_up = global_up; + export_settings.global_forward = BC_global_forward_axis(global_forward); + export_settings.global_up = BC_global_up_axis(global_up); export_settings.apply_global_orientation = apply_global_orientation != 0; - export_settings.export_mesh_type = export_mesh_type; + export_settings.export_mesh_type = BC_export_mesh_type(export_mesh_type); export_settings.selected = selected != 0; export_settings.include_children = include_children != 0; export_settings.include_armatures = include_armatures != 0; @@ -178,15 +178,17 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) export_settings.keep_flat_curves = keep_flat_curves != 0; export_settings.active_uv_only = active_uv_only != 0; - export_settings.export_animation_type = export_animation_type; + export_settings.export_animation_type = BC_export_animation_type(export_animation_type); export_settings.use_texture_copies = use_texture_copies != 0; export_settings.triangulate = triangulate != 0; export_settings.use_object_instantiation = use_object_instantiation != 0; export_settings.use_blender_profile = use_blender_profile != 0; export_settings.sort_by_name = sort_by_name != 0; - export_settings.object_transformation_type = export_object_transformation_type; - export_settings.animation_transformation_type = export_animation_transformation_type; + export_settings.object_transformation_type = BC_export_transformation_type( + export_object_transformation_type); + export_settings.animation_transformation_type = BC_export_transformation_type( + export_animation_transformation_type); export_settings.keep_smooth_curves = keep_smooth_curves != 0; if (export_animation_type != BC_ANIMATION_EXPORT_SAMPLES) { @@ -230,17 +232,17 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) bool include_animations = RNA_boolean_get(imfptr, "include_animations"); int ui_section = RNA_enum_get(imfptr, "prop_bc_export_ui_section"); - BC_export_animation_type animation_type = RNA_enum_get(imfptr, - "export_animation_type_selection"); + BC_export_animation_type animation_type = BC_export_animation_type( + RNA_enum_get(imfptr, "export_animation_type_selection")); - BC_export_transformation_type animation_transformation_type = RNA_enum_get( - imfptr, "export_animation_transformation_type_selection"); + BC_export_transformation_type animation_transformation_type = BC_export_transformation_type( + RNA_enum_get(imfptr, "export_animation_transformation_type_selection")); bool sampling = animation_type == BC_ANIMATION_EXPORT_SAMPLES; /* Export Options: */ row = uiLayoutRow(layout, false); - uiItemR(row, imfptr, "prop_bc_export_ui_section", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, imfptr, "prop_bc_export_ui_section", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); @@ -249,12 +251,12 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) /* Export data options. */ box = uiLayoutBox(layout); col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "selected", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "selected", 0, nullptr, ICON_NONE); sub = uiLayoutColumn(col, false); uiLayoutSetEnabled(sub, RNA_boolean_get(imfptr, "selected")); - uiItemR(sub, imfptr, "include_children", 0, NULL, ICON_NONE); - uiItemR(sub, imfptr, "include_armatures", 0, NULL, ICON_NONE); - uiItemR(sub, imfptr, "include_shapekeys", 0, NULL, ICON_NONE); + uiItemR(sub, imfptr, "include_children", 0, nullptr, ICON_NONE); + uiItemR(sub, imfptr, "include_armatures", 0, nullptr, ICON_NONE); + uiItemR(sub, imfptr, "include_shapekeys", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); row = uiLayoutRow(box, false); @@ -269,7 +271,7 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemL(box, IFACE_("Texture Options"), ICON_TEXTURE_DATA); col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "use_texture_copies", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "use_texture_copies", 0, nullptr, ICON_NONE); row = uiLayoutRowWithHeading(col, true, IFACE_("UV")); uiItemR(row, imfptr, "active_uv_only", 0, IFACE_("Only Selected Map"), ICON_NONE); } @@ -279,7 +281,7 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "triangulate", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "triangulate", 0, nullptr, ICON_NONE); row = uiLayoutRowWithHeading(col, true, IFACE_("Apply Modifiers")); uiItemR(row, imfptr, "apply_modifiers", 0, "", ICON_NONE); @@ -288,10 +290,10 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(sub, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE); if (RNA_boolean_get(imfptr, "include_animations")) { - uiItemR(col, imfptr, "export_animation_transformation_type_selection", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "export_animation_transformation_type_selection", 0, nullptr, ICON_NONE); } else { - uiItemR(col, imfptr, "export_object_transformation_type_selection", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "export_object_transformation_type_selection", 0, nullptr, ICON_NONE); } } else if (ui_section == BC_UI_SECTION_ARMATURE) { @@ -300,25 +302,25 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemL(box, IFACE_("Armature Options"), ICON_ARMATURE_DATA); col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "open_sim", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "deform_bones_only", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "open_sim", 0, nullptr, ICON_NONE); } else if (ui_section == BC_UI_SECTION_ANIMATION) { /* Animation options. */ box = uiLayoutBox(layout); - uiItemR(box, imfptr, "include_animations", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "include_animations", 0, nullptr, ICON_NONE); col = uiLayoutColumn(box, false); row = uiLayoutRow(col, false); uiLayoutSetActive(row, include_animations); - uiItemR(row, imfptr, "export_animation_type_selection", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, imfptr, "export_animation_type_selection", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetActive(row, include_animations && animation_type == BC_ANIMATION_EXPORT_SAMPLES); if (RNA_boolean_get(imfptr, "include_animations")) { - uiItemR(box, imfptr, "export_animation_transformation_type_selection", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "export_animation_transformation_type_selection", 0, nullptr, ICON_NONE); } else { - uiItemR(box, imfptr, "export_object_transformation_type_selection", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "export_object_transformation_type_selection", 0, nullptr, ICON_NONE); } row = uiLayoutColumn(col, false); @@ -326,17 +328,17 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) include_animations && (animation_transformation_type == BC_TRANSFORMATION_TYPE_DECOMPOSED || animation_type == BC_ANIMATION_EXPORT_KEYS)); - uiItemR(row, imfptr, "keep_smooth_curves", 0, NULL, ICON_NONE); + uiItemR(row, imfptr, "keep_smooth_curves", 0, nullptr, ICON_NONE); sub = uiLayoutColumn(col, false); uiLayoutSetActive(sub, sampling && include_animations); - uiItemR(sub, imfptr, "sampling_rate", 0, NULL, ICON_NONE); - uiItemR(sub, imfptr, "keep_keyframes", 0, NULL, ICON_NONE); + uiItemR(sub, imfptr, "sampling_rate", 0, nullptr, ICON_NONE); + uiItemR(sub, imfptr, "keep_keyframes", 0, nullptr, ICON_NONE); sub = uiLayoutColumn(col, false); uiLayoutSetActive(sub, include_animations); - uiItemR(sub, imfptr, "keep_flat_curves", 0, NULL, ICON_NONE); - uiItemR(sub, imfptr, "include_all_actions", 0, NULL, ICON_NONE); + uiItemR(sub, imfptr, "keep_flat_curves", 0, nullptr, ICON_NONE); + uiItemR(sub, imfptr, "include_all_actions", 0, nullptr, ICON_NONE); } else if (ui_section == BC_UI_SECTION_COLLADA) { /* Collada options: */ @@ -345,20 +347,20 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemL(row, IFACE_("Collada Options"), ICON_MODIFIER); col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "use_object_instantiation", 1, NULL, ICON_NONE); - uiItemR(col, imfptr, "use_blender_profile", 1, NULL, ICON_NONE); - uiItemR(col, imfptr, "sort_by_name", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "keep_bind_info", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "limit_precision", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "use_object_instantiation", 1, nullptr, ICON_NONE); + uiItemR(col, imfptr, "use_blender_profile", 1, nullptr, ICON_NONE); + uiItemR(col, imfptr, "sort_by_name", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "keep_bind_info", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "limit_precision", 0, nullptr, ICON_NONE); } } -static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_collada_export_draw(bContext * /*C*/, wmOperator *op) { uiCollada_exportSettings(op->layout, op->ptr); } -static bool wm_collada_export_check(bContext *UNUSED(C), wmOperator *op) +static bool wm_collada_export_check(bContext * /*C*/, wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); @@ -377,7 +379,7 @@ void WM_OT_collada_export(wmOperatorType *ot) static const EnumPropertyItem prop_bc_export_mesh_type[] = { {BC_MESH_TYPE_VIEW, "view", 0, "Viewport", "Apply modifier's viewport settings"}, {BC_MESH_TYPE_RENDER, "render", 0, "Render", "Apply modifier's render settings"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem prop_bc_export_global_forward[] = { @@ -387,7 +389,7 @@ void WM_OT_collada_export(wmOperatorType *ot) {BC_GLOBAL_FORWARD_MINUS_X, "-X", 0, "-X", "Global Forward is negative X Axis"}, {BC_GLOBAL_FORWARD_MINUS_Y, "-Y", 0, "-Y", "Global Forward is negative Y Axis"}, {BC_GLOBAL_FORWARD_MINUS_Z, "-Z", 0, "-Z", "Global Forward is negative Z Axis"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem prop_bc_export_global_up[] = { @@ -397,7 +399,7 @@ void WM_OT_collada_export(wmOperatorType *ot) {BC_GLOBAL_UP_MINUS_X, "-X", 0, "-X", "Global UP is negative X Axis"}, {BC_GLOBAL_UP_MINUS_Y, "-Y", 0, "-Y", "Global UP is negative Y Axis"}, {BC_GLOBAL_UP_MINUS_Z, "-Z", 0, "-Z", "Global UP is negative Z Axis"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem prop_bc_export_transformation_type[] = { @@ -411,7 +413,7 @@ void WM_OT_collada_export(wmOperatorType *ot) 0, "Decomposed", "Use , and representation for exported transformations"}, - {0, NULL, 0, NULL, NULL}}; + {0, nullptr, 0, nullptr, nullptr}}; static const EnumPropertyItem prop_bc_export_animation_type[] = { {BC_ANIMATION_EXPORT_SAMPLES, @@ -424,7 +426,7 @@ void WM_OT_collada_export(wmOperatorType *ot) 0, "Curves", "Export Curves (note: guided by curve keys)"}, - {0, NULL, 0, NULL, NULL}}; + {0, nullptr, 0, nullptr, nullptr}}; static const EnumPropertyItem prop_bc_export_ui_section[] = { {BC_UI_SECTION_MAIN, "main", 0, "Main", "Data export section"}, @@ -432,7 +434,7 @@ void WM_OT_collada_export(wmOperatorType *ot) {BC_UI_SECTION_ARMATURE, "armature", 0, "Arm", "Armature export section"}, {BC_UI_SECTION_ANIMATION, "animation", 0, "Anim", "Animation export section"}, {BC_UI_SECTION_COLLADA, "collada", 0, "Extra", "Collada export section"}, - {0, NULL, 0, NULL, NULL}}; + {0, nullptr, 0, nullptr, nullptr}}; ot->name = "Export COLLADA"; ot->description = "Save a Collada file"; @@ -688,7 +690,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) int keep_bind_info; int custom_normals; - ImportSettings import_settings; + ImportSettings import_settings{}; if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) { BKE_report(op->reports, RPT_ERROR, "No filepath given"); @@ -737,24 +739,24 @@ static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr) box = uiLayoutBox(layout); uiItemL(box, IFACE_("Import Data Options"), ICON_MESH_DATA); - uiItemR(box, imfptr, "import_units", 0, NULL, ICON_NONE); - uiItemR(box, imfptr, "custom_normals", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "import_units", 0, nullptr, ICON_NONE); + uiItemR(box, imfptr, "custom_normals", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); uiItemL(box, IFACE_("Armature Options"), ICON_ARMATURE_DATA); col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "fix_orientation", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "find_chains", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "auto_connect", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "min_chain_length", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "fix_orientation", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "find_chains", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "auto_connect", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "min_chain_length", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); - uiItemR(box, imfptr, "keep_bind_info", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "keep_bind_info", 0, nullptr, ICON_NONE); } -static void wm_collada_import_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_collada_import_draw(bContext * /*C*/, wmOperator *op) { uiCollada_importSettings(op->layout, op->ptr); } diff --git a/source/blender/editors/io/io_collada.h b/source/blender/editors/io/io_collada.hh similarity index 100% rename from source/blender/editors/io/io_collada.h rename to source/blender/editors/io/io_collada.hh diff --git a/source/blender/editors/io/io_gpencil.h b/source/blender/editors/io/io_gpencil.hh similarity index 100% rename from source/blender/editors/io/io_gpencil.h rename to source/blender/editors/io/io_gpencil.hh diff --git a/source/blender/editors/io/io_gpencil_export.c b/source/blender/editors/io/io_gpencil_export.cc similarity index 77% rename from source/blender/editors/io/io_gpencil_export.c rename to source/blender/editors/io/io_gpencil_export.cc index 5deb7413414..14b9e770e1d 100644 --- a/source/blender/editors/io/io_gpencil_export.c +++ b/source/blender/editors/io/io_gpencil_export.cc @@ -35,7 +35,7 @@ # include "DEG_depsgraph.h" # include "DEG_depsgraph_query.h" -# include "io_gpencil.h" +# include "io_gpencil.hh" # include "gpencil_io.h" @@ -48,7 +48,7 @@ static void gpencil_export_common_props_definition(wmOperatorType *ot) {GP_EXPORT_ACTIVE, "ACTIVE", 0, "Active", "Include only the active object"}, {GP_EXPORT_SELECTED, "SELECTED", 0, "Selected", "Include selected objects"}, {GP_EXPORT_VISIBLE, "VISIBLE", 0, "Visible", "Include all visible objects"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; RNA_def_boolean(ot->srna, "use_fill", true, "Fill", "Export strokes with fill enabled"); @@ -78,7 +78,7 @@ static void gpencil_export_common_props_definition(wmOperatorType *ot) /* <-------- SVG single frame export. --------> */ # ifdef WITH_PUGIXML -static bool wm_gpencil_export_svg_common_check(bContext *UNUSED(C), wmOperator *op) +static bool wm_gpencil_export_svg_common_check(bContext * /*C*/, wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); @@ -92,7 +92,7 @@ static bool wm_gpencil_export_svg_common_check(bContext *UNUSED(C), wmOperator * return false; } -static int wm_gpencil_export_svg_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int wm_gpencil_export_svg_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { ED_fileselect_ensure_default_filepath(C, op, ".svg"); @@ -112,7 +112,7 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op) } ARegion *region = get_invoke_region(C); - if (region == NULL) { + if (region == nullptr) { BKE_report(op->reports, RPT_ERROR, "Unable to find valid 3D View area"); return OPERATOR_CANCELLED; } @@ -123,7 +123,8 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op) const bool use_fill = RNA_boolean_get(op->ptr, "use_fill"); const bool use_norm_thickness = RNA_boolean_get(op->ptr, "use_normalized_thickness"); - const eGpencilExportSelect select_mode = RNA_enum_get(op->ptr, "selected_object_type"); + const eGpencilExportSelect select_mode = eGpencilExportSelect( + RNA_enum_get(op->ptr, "selected_object_type")); const bool use_clip_camera = RNA_boolean_get(op->ptr, "use_clip_camera"); @@ -133,20 +134,21 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op) SET_FLAG_FROM_TEST(flag, use_norm_thickness, GP_EXPORT_NORM_THICKNESS); SET_FLAG_FROM_TEST(flag, use_clip_camera, GP_EXPORT_CLIP_CAMERA); - GpencilIOParams params = {.C = C, - .region = region, - .v3d = v3d, - .ob = ob, - .mode = GP_EXPORT_TO_SVG, - .frame_start = scene->r.cfra, - .frame_end = scene->r.cfra, - .frame_cur = scene->r.cfra, - .flag = flag, - .scale = 1.0f, - .select_mode = select_mode, - .frame_mode = GP_EXPORT_FRAME_ACTIVE, - .stroke_sample = RNA_float_get(op->ptr, "stroke_sample"), - .resolution = 1.0f}; + GpencilIOParams params{}; + params.C = C; + params.region = region; + params.v3d = v3d; + params.ob = ob; + params.mode = GP_EXPORT_TO_SVG; + params.frame_start = scene->r.cfra; + params.frame_end = scene->r.cfra; + params.frame_cur = scene->r.cfra; + params.flag = flag; + params.scale = 1.0f; + params.select_mode = select_mode; + params.frame_mode = GP_EXPORT_FRAME_ACTIVE; + params.stroke_sample = RNA_float_get(op->ptr, "stroke_sample"); + params.resolution = 1.0f; /* Do export. */ WM_cursor_wait(true); @@ -173,27 +175,27 @@ static void ui_gpencil_export_svg_settings(uiLayout *layout, PointerRNA *imfptr) uiItemL(row, IFACE_("Scene Options"), ICON_NONE); row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "selected_object_type", 0, NULL, ICON_NONE); + uiItemR(row, imfptr, "selected_object_type", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Export Options"), ICON_NONE); uiLayout *col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "stroke_sample", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "use_fill", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "use_normalized_thickness", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "use_clip_camera", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "stroke_sample", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "use_fill", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "use_normalized_thickness", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "use_clip_camera", 0, nullptr, ICON_NONE); } -static void wm_gpencil_export_svg_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_gpencil_export_svg_draw(bContext * /*C*/, wmOperator *op) { ui_gpencil_export_svg_settings(op->layout, op->ptr); } static bool wm_gpencil_export_svg_poll(bContext *C) { - if ((CTX_wm_window(C) == NULL) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) { + if ((CTX_wm_window(C) == nullptr) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) { return false; } @@ -232,7 +234,7 @@ void WM_OT_gpencil_export_svg(wmOperatorType *ot) /* <-------- PDF single frame export. --------> */ # ifdef WITH_HARU -static bool wm_gpencil_export_pdf_common_check(bContext *UNUSED(C), wmOperator *op) +static bool wm_gpencil_export_pdf_common_check(bContext * /*C*/, wmOperator *op) { char filepath[FILE_MAX]; @@ -247,7 +249,7 @@ static bool wm_gpencil_export_pdf_common_check(bContext *UNUSED(C), wmOperator * return false; } -static int wm_gpencil_export_pdf_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int wm_gpencil_export_pdf_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { ED_fileselect_ensure_default_filepath(C, op, ".pdf"); @@ -267,7 +269,7 @@ static int wm_gpencil_export_pdf_exec(bContext *C, wmOperator *op) } ARegion *region = get_invoke_region(C); - if (region == NULL) { + if (region == nullptr) { BKE_report(op->reports, RPT_ERROR, "Unable to find valid 3D View area"); return OPERATOR_CANCELLED; } @@ -286,20 +288,21 @@ static int wm_gpencil_export_pdf_exec(bContext *C, wmOperator *op) SET_FLAG_FROM_TEST(flag, use_fill, GP_EXPORT_FILL); SET_FLAG_FROM_TEST(flag, use_norm_thickness, GP_EXPORT_NORM_THICKNESS); - GpencilIOParams params = {.C = C, - .region = region, - .v3d = v3d, - .ob = ob, - .mode = GP_EXPORT_TO_PDF, - .frame_start = scene->r.sfra, - .frame_end = scene->r.efra, - .frame_cur = scene->r.cfra, - .flag = flag, - .scale = 1.0f, - .select_mode = select_mode, - .frame_mode = frame_mode, - .stroke_sample = RNA_float_get(op->ptr, "stroke_sample"), - .resolution = 1.0f}; + GpencilIOParams params{}; + params.C = C; + params.region = region; + params.v3d = v3d; + params.ob = ob; + params.mode = GP_EXPORT_TO_PDF; + params.frame_start = scene->r.sfra; + params.frame_end = scene->r.efra; + params.frame_cur = scene->r.cfra; + params.flag = flag; + params.scale = 1.0f; + params.select_mode = select_mode; + params.frame_mode = frame_mode; + params.stroke_sample = RNA_float_get(op->ptr, "stroke_sample"); + params.resolution = 1.0f; /* Do export. */ WM_cursor_wait(true); @@ -326,7 +329,7 @@ static void ui_gpencil_export_pdf_settings(uiLayout *layout, PointerRNA *imfptr) uiItemL(row, IFACE_("Scene Options"), ICON_NONE); row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "selected_object_type", 0, NULL, ICON_NONE); + uiItemR(row, imfptr, "selected_object_type", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); row = uiLayoutRow(box, false); @@ -339,19 +342,19 @@ static void ui_gpencil_export_pdf_settings(uiLayout *layout, PointerRNA *imfptr) uiLayoutSetPropSep(box, true); sub = uiLayoutColumn(col, true); - uiItemR(sub, imfptr, "stroke_sample", 0, NULL, ICON_NONE); - uiItemR(sub, imfptr, "use_fill", 0, NULL, ICON_NONE); - uiItemR(sub, imfptr, "use_normalized_thickness", 0, NULL, ICON_NONE); + uiItemR(sub, imfptr, "stroke_sample", 0, nullptr, ICON_NONE); + uiItemR(sub, imfptr, "use_fill", 0, nullptr, ICON_NONE); + uiItemR(sub, imfptr, "use_normalized_thickness", 0, nullptr, ICON_NONE); } -static void wm_gpencil_export_pdf_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_gpencil_export_pdf_draw(bContext * /*C*/, wmOperator *op) { ui_gpencil_export_pdf_settings(op->layout, op->ptr); } static bool wm_gpencil_export_pdf_poll(bContext *C) { - if ((CTX_wm_window(C) == NULL) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) { + if ((CTX_wm_window(C) == nullptr) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) { return false; } @@ -382,7 +385,7 @@ void WM_OT_gpencil_export_pdf(wmOperatorType *ot) {GP_EXPORT_FRAME_ACTIVE, "ACTIVE", 0, "Active", "Include only active frame"}, {GP_EXPORT_FRAME_SELECTED, "SELECTED", 0, "Selected", "Include selected frames"}, {GP_EXPORT_FRAME_SCENE, "SCENE", 0, "Scene", "Include all scene frames"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; gpencil_export_common_props_definition(ot); diff --git a/source/blender/editors/io/io_gpencil_import.c b/source/blender/editors/io/io_gpencil_import.cc similarity index 84% rename from source/blender/editors/io/io_gpencil_import.c rename to source/blender/editors/io/io_gpencil_import.cc index 2fbe167432c..76f824f9746 100644 --- a/source/blender/editors/io/io_gpencil_import.c +++ b/source/blender/editors/io/io_gpencil_import.cc @@ -35,12 +35,12 @@ # include "ED_gpencil_legacy.h" -# include "io_gpencil.h" +# include "io_gpencil.hh" # include "gpencil_io.h" /* <-------- SVG single frame import. --------> */ -static bool wm_gpencil_import_svg_common_check(bContext *UNUSED(C), wmOperator *op) +static bool wm_gpencil_import_svg_common_check(bContext * /*C*/, wmOperator *op) { char filepath[FILE_MAX]; @@ -55,7 +55,7 @@ static bool wm_gpencil_import_svg_common_check(bContext *UNUSED(C), wmOperator * return false; } -static int wm_gpencil_import_svg_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int wm_gpencil_import_svg_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { WM_event_add_fileselect(C, op); @@ -74,7 +74,7 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator *op) } ARegion *region = get_invoke_region(C); - if (region == NULL) { + if (region == nullptr) { BKE_report(op->reports, RPT_ERROR, "Unable to find valid 3D View area"); return OPERATOR_CANCELLED; } @@ -86,33 +86,32 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator *op) const int resolution = RNA_int_get(op->ptr, "resolution"); const float scale = RNA_float_get(op->ptr, "scale"); - GpencilIOParams params = { - .C = C, - .region = region, - .v3d = v3d, - .ob = NULL, - .mode = GP_IMPORT_FROM_SVG, - .frame_start = scene->r.cfra, - .frame_end = scene->r.cfra, - .frame_cur = scene->r.cfra, - .flag = flag, - .scale = scale, - .select_mode = 0, - .frame_mode = 0, - .stroke_sample = 0.0f, - .resolution = resolution, - }; + GpencilIOParams params {}; + params.C = C; + params.region = region; + params.v3d = v3d; + params.ob = nullptr; + params.mode = GP_IMPORT_FROM_SVG; + params.frame_start = scene->r.cfra; + params.frame_end = scene->r.cfra; + params.frame_cur = scene->r.cfra; + params.flag = flag; + params.scale = scale; + params.select_mode = 0; + params.frame_mode = 0; + params.stroke_sample = 0.0f; + params.resolution = resolution; /* Loop all selected files to import them. All SVG imported shared the same import * parameters, but they are created in separated grease pencil objects. */ PropertyRNA *prop; if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { - char *directory = RNA_string_get_alloc(op->ptr, "directory", NULL, 0, NULL); + char *directory = RNA_string_get_alloc(op->ptr, "directory", nullptr, 0, nullptr); if ((prop = RNA_struct_find_property(op->ptr, "files"))) { char file_path[FILE_MAX]; RNA_PROP_BEGIN (op->ptr, itemptr, prop) { - char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0, NULL); + char *filename = RNA_string_get_alloc(&itemptr, "name", nullptr, 0, nullptr); BLI_path_join(file_path, sizeof(file_path), directory, filename); MEM_freeN(filename); @@ -138,18 +137,18 @@ static void ui_gpencil_import_svg_settings(uiLayout *layout, PointerRNA *imfptr) uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); uiLayout *col = uiLayoutColumn(layout, false); - uiItemR(col, imfptr, "resolution", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "scale", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "resolution", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "scale", 0, nullptr, ICON_NONE); } -static void wm_gpencil_import_svg_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_gpencil_import_svg_draw(bContext * /*C*/, wmOperator *op) { ui_gpencil_import_svg_settings(op->layout, op->ptr); } static bool wm_gpencil_import_svg_poll(bContext *C) { - if ((CTX_wm_window(C) == NULL) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) { + if ((CTX_wm_window(C) == nullptr) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) { return false; } diff --git a/source/blender/editors/io/io_gpencil_utils.c b/source/blender/editors/io/io_gpencil_utils.cc similarity index 69% rename from source/blender/editors/io/io_gpencil_utils.c rename to source/blender/editors/io/io_gpencil_utils.cc index 7f76fa7dcf4..b2cbb875a8d 100644 --- a/source/blender/editors/io/io_gpencil_utils.c +++ b/source/blender/editors/io/io_gpencil_utils.cc @@ -15,17 +15,17 @@ # include "WM_api.h" -# include "io_gpencil.h" +# include "io_gpencil.hh" ARegion *get_invoke_region(bContext *C) { bScreen *screen = CTX_wm_screen(C); - if (screen == NULL) { - return NULL; + if (screen == nullptr) { + return nullptr; } ScrArea *area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0); - if (area == NULL) { - return NULL; + if (area == nullptr) { + return nullptr; } ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); @@ -36,18 +36,18 @@ ARegion *get_invoke_region(bContext *C) View3D *get_invoke_view3d(bContext *C) { bScreen *screen = CTX_wm_screen(C); - if (screen == NULL) { - return NULL; + if (screen == nullptr) { + return nullptr; } ScrArea *area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0); - if (area == NULL) { - return NULL; + if (area == nullptr) { + return nullptr; } - if (area) { - return area->spacedata.first; + if (area != nullptr) { + return static_cast(area->spacedata.first); } - return NULL; + return nullptr; } #endif /* WITH_IO_GPENCIL */ diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.cc similarity index 93% rename from source/blender/editors/io/io_obj.c rename to source/blender/editors/io/io_obj.cc index 9b22a83ac8f..5b7b0f5c1b7 100644 --- a/source/blender/editors/io/io_obj.c +++ b/source/blender/editors/io/io_obj.cc @@ -39,7 +39,8 @@ # include "IO_orientation.h" # include "IO_path_util_types.h" # include "IO_wavefront_obj.h" -# include "io_obj.h" + +# include "io_obj.hh" static const EnumPropertyItem io_obj_export_evaluation_mode[] = { {DAG_EVAL_RENDER, "DAG_EVAL_RENDER", 0, "Render", "Export objects as they appear in render"}, @@ -48,7 +49,7 @@ static const EnumPropertyItem io_obj_export_evaluation_mode[] = { 0, "Viewport", "Export objects as they appear in the viewport"}, - {0, NULL, 0, NULL, NULL}}; + {0, nullptr, 0, nullptr, nullptr}}; static const EnumPropertyItem io_obj_path_mode[] = { {PATH_REFERENCE_AUTO, "AUTO", 0, "Auto", "Use relative paths with subdirectories only"}, @@ -57,9 +58,9 @@ static const EnumPropertyItem io_obj_path_mode[] = { {PATH_REFERENCE_MATCH, "MATCH", 0, "Match", "Match absolute/relative setting with input path"}, {PATH_REFERENCE_STRIP, "STRIP", 0, "Strip", "Write filename only"}, {PATH_REFERENCE_COPY, "COPY", 0, "Copy", "Copy the file to the destination path"}, - {0, NULL, 0, NULL, NULL}}; + {0, nullptr, 0, nullptr, nullptr}}; -static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { ED_fileselect_ensure_default_filepath(C, op, ".obj"); @@ -73,7 +74,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No filepath given"); return OPERATOR_CANCELLED; } - struct OBJExportParams export_params; + OBJExportParams export_params{}; export_params.file_base_for_tests[0] = '\0'; RNA_string_get(op->ptr, "filepath", export_params.filepath); export_params.blen_filepath = CTX_data_main(C)->filepath; @@ -81,18 +82,18 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op) export_params.start_frame = RNA_int_get(op->ptr, "start_frame"); export_params.end_frame = RNA_int_get(op->ptr, "end_frame"); - export_params.forward_axis = RNA_enum_get(op->ptr, "forward_axis"); - export_params.up_axis = RNA_enum_get(op->ptr, "up_axis"); + export_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis")); + export_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis")); export_params.global_scale = RNA_float_get(op->ptr, "global_scale"); export_params.apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); - export_params.export_eval_mode = RNA_enum_get(op->ptr, "export_eval_mode"); + export_params.export_eval_mode = eEvaluationMode(RNA_enum_get(op->ptr, "export_eval_mode")); export_params.export_selected_objects = RNA_boolean_get(op->ptr, "export_selected_objects"); export_params.export_uv = RNA_boolean_get(op->ptr, "export_uv"); export_params.export_normals = RNA_boolean_get(op->ptr, "export_normals"); export_params.export_colors = RNA_boolean_get(op->ptr, "export_colors"); export_params.export_materials = RNA_boolean_get(op->ptr, "export_materials"); - export_params.path_mode = RNA_enum_get(op->ptr, "path_mode"); + export_params.path_mode = ePathReferenceMode(RNA_enum_get(op->ptr, "path_mode")); export_params.export_triangulated_mesh = RNA_boolean_get(op->ptr, "export_triangulated_mesh"); export_params.export_curves_as_nurbs = RNA_boolean_get(op->ptr, "export_curves_as_nurbs"); export_params.export_pbr_extensions = RNA_boolean_get(op->ptr, "export_pbr_extensions"); @@ -124,7 +125,7 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr) col = uiLayoutColumn(box, false); sub = uiLayoutColumnWithHeading(col, false, IFACE_("Limit to")); uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), ICON_NONE); - uiItemR(sub, imfptr, "global_scale", 0, NULL, ICON_NONE); + uiItemR(sub, imfptr, "global_scale", 0, nullptr, ICON_NONE); uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Forward Axis"), ICON_NONE); uiItemR(sub, imfptr, "up_axis", 0, IFACE_("Up Axis"), ICON_NONE); @@ -177,10 +178,10 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr) uiItemR(sub, imfptr, "end_frame", 0, IFACE_("End"), ICON_NONE); } -static void wm_obj_export_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_obj_export_draw(bContext * /*C*/, wmOperator *op) { PointerRNA ptr; - RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + RNA_pointer_create(nullptr, op->type->srna, op->properties, &ptr); ui_obj_export_settings(op->layout, &ptr); } @@ -372,7 +373,7 @@ void WM_OT_obj_export(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN); } -static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; @@ -380,12 +381,12 @@ static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS static int wm_obj_import_exec(bContext *C, wmOperator *op) { - struct OBJImportParams import_params; + OBJImportParams import_params{}; RNA_string_get(op->ptr, "filepath", import_params.filepath); import_params.global_scale = RNA_float_get(op->ptr, "global_scale"); import_params.clamp_size = RNA_float_get(op->ptr, "clamp_size"); - import_params.forward_axis = RNA_enum_get(op->ptr, "forward_axis"); - import_params.up_axis = RNA_enum_get(op->ptr, "up_axis"); + import_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis")); + import_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis")); import_params.use_split_objects = RNA_boolean_get(op->ptr, "use_split_objects"); import_params.use_split_groups = RNA_boolean_get(op->ptr, "use_split_groups"); import_params.import_vertex_groups = RNA_boolean_get(op->ptr, "import_vertex_groups"); @@ -438,8 +439,8 @@ static void ui_obj_import_settings(uiLayout *layout, PointerRNA *imfptr) uiItemL(box, IFACE_("Transform"), ICON_OBJECT_DATA); uiLayout *col = uiLayoutColumn(box, false); uiLayout *sub = uiLayoutColumn(col, false); - uiItemR(sub, imfptr, "global_scale", 0, NULL, ICON_NONE); - uiItemR(sub, imfptr, "clamp_size", 0, NULL, ICON_NONE); + uiItemR(sub, imfptr, "global_scale", 0, nullptr, ICON_NONE); + uiItemR(sub, imfptr, "clamp_size", 0, nullptr, ICON_NONE); sub = uiLayoutColumn(col, false); uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Forward Axis"), ICON_NONE); @@ -448,10 +449,10 @@ static void ui_obj_import_settings(uiLayout *layout, PointerRNA *imfptr) box = uiLayoutBox(layout); uiItemL(box, IFACE_("Options"), ICON_EXPORT); col = uiLayoutColumn(box, false); - uiItemR(col, imfptr, "use_split_objects", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "use_split_groups", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "import_vertex_groups", 0, NULL, ICON_NONE); - uiItemR(col, imfptr, "validate_meshes", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "use_split_objects", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "use_split_groups", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "import_vertex_groups", 0, nullptr, ICON_NONE); + uiItemR(col, imfptr, "validate_meshes", 0, nullptr, ICON_NONE); } static void wm_obj_import_draw(bContext *C, wmOperator *op) @@ -484,6 +485,7 @@ void WM_OT_obj_import(wmOperatorType *ot) WM_FILESEL_DIRECTORY | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_DEFAULT); + RNA_def_float( ot->srna, "global_scale", diff --git a/source/blender/editors/io/io_obj.h b/source/blender/editors/io/io_obj.hh similarity index 100% rename from source/blender/editors/io/io_obj.h rename to source/blender/editors/io/io_obj.hh diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.cc similarity index 88% rename from source/blender/editors/io/io_ops.c rename to source/blender/editors/io/io_ops.cc index 1cbea162ea2..d6679b46357 100644 --- a/source/blender/editors/io/io_ops.c +++ b/source/blender/editors/io/io_ops.cc @@ -11,22 +11,22 @@ #include "WM_api.h" #ifdef WITH_COLLADA -# include "io_collada.h" +# include "io_collada.hh" #endif #ifdef WITH_ALEMBIC -# include "io_alembic.h" +# include "io_alembic.hh" #endif #ifdef WITH_USD -# include "io_usd.h" +# include "io_usd.hh" #endif -#include "io_cache.h" -#include "io_gpencil.h" -#include "io_obj.h" -#include "io_ply_ops.h" -#include "io_stl_ops.h" +#include "io_cache.hh" +#include "io_gpencil.hh" +#include "io_obj.hh" +#include "io_ply_ops.hh" +#include "io_stl_ops.hh" void ED_operatortypes_io(void) { @@ -60,7 +60,6 @@ void ED_operatortypes_io(void) WM_operatortype_append(CACHEFILE_OT_layer_add); WM_operatortype_append(CACHEFILE_OT_layer_remove); WM_operatortype_append(CACHEFILE_OT_layer_move); - #ifdef WITH_IO_WAVEFRONT_OBJ WM_operatortype_append(WM_OT_obj_export); WM_operatortype_append(WM_OT_obj_import); diff --git a/source/blender/editors/io/io_ops.h b/source/blender/editors/io/io_ops.h index 1c04a4313b4..5f2c0a9f86f 100644 --- a/source/blender/editors/io/io_ops.h +++ b/source/blender/editors/io/io_ops.h @@ -8,4 +8,12 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + void ED_operatortypes_io(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/editors/io/io_ply_ops.c b/source/blender/editors/io/io_ply_ops.cc similarity index 92% rename from source/blender/editors/io/io_ply_ops.c rename to source/blender/editors/io/io_ply_ops.cc index 890636815c0..dd24a0af083 100644 --- a/source/blender/editors/io/io_ply_ops.c +++ b/source/blender/editors/io/io_ply_ops.cc @@ -36,7 +36,7 @@ # include "IO_path_util_types.h" # include "IO_ply.h" -# include "io_ply_ops.h" +# include "io_ply_ops.hh" static const EnumPropertyItem ply_vertex_colors_mode[] = { {PLY_VERTEX_COLOR_NONE, "NONE", 0, "None", "Do not import/export color attributes"}, @@ -50,9 +50,9 @@ static const EnumPropertyItem ply_vertex_colors_mode[] = { 0, "Linear", "Vertex colors in the file are in linear color space"}, - {0, NULL, 0, NULL, NULL}}; + {0, nullptr, 0, nullptr, nullptr}}; -static int wm_ply_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int wm_ply_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { ED_fileselect_ensure_default_filepath(C, op, ".ply"); @@ -66,20 +66,20 @@ static int wm_ply_export_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No filepath given"); return OPERATOR_CANCELLED; } - struct PLYExportParams export_params = {"\0"}; + PLYExportParams export_params = {"\0"}; export_params.file_base_for_tests[0] = '\0'; RNA_string_get(op->ptr, "filepath", export_params.filepath); export_params.blen_filepath = CTX_data_main(C)->filepath; - export_params.forward_axis = RNA_enum_get(op->ptr, "forward_axis"); - export_params.up_axis = RNA_enum_get(op->ptr, "up_axis"); + export_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis")); + export_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis")); export_params.global_scale = RNA_float_get(op->ptr, "global_scale"); export_params.apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); export_params.export_selected_objects = RNA_boolean_get(op->ptr, "export_selected_objects"); export_params.export_uv = RNA_boolean_get(op->ptr, "export_uv"); export_params.export_normals = RNA_boolean_get(op->ptr, "export_normals"); - export_params.vertex_colors = RNA_enum_get(op->ptr, "export_colors"); + export_params.vertex_colors = ePLYVertexColorMode(RNA_enum_get(op->ptr, "export_colors")); export_params.export_triangulated_mesh = RNA_boolean_get(op->ptr, "export_triangulated_mesh"); export_params.ascii_format = RNA_boolean_get(op->ptr, "ascii_format"); @@ -102,7 +102,7 @@ static void ui_ply_export_settings(uiLayout *layout, PointerRNA *imfptr) uiItemR(sub, imfptr, "ascii_format", 0, IFACE_("ASCII"), ICON_NONE); sub = uiLayoutColumnWithHeading(col, false, IFACE_("Limit to")); uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), ICON_NONE); - uiItemR(sub, imfptr, "global_scale", 0, NULL, ICON_NONE); + uiItemR(sub, imfptr, "global_scale", 0, nullptr, ICON_NONE); uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Forward Axis"), ICON_NONE); uiItemR(sub, imfptr, "up_axis", 0, IFACE_("Up Axis"), ICON_NONE); @@ -122,17 +122,17 @@ static void ui_ply_export_settings(uiLayout *layout, PointerRNA *imfptr) uiItemR(sub, imfptr, "export_triangulated_mesh", 0, IFACE_("Triangulated Mesh"), ICON_NONE); } -static void wm_ply_export_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_ply_export_draw(bContext * /*C*/, wmOperator *op) { PointerRNA ptr; - RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + RNA_pointer_create(nullptr, op->type->srna, op->properties, &ptr); ui_ply_export_settings(op->layout, &ptr); } /** * Return true if any property in the UI is changed. */ -static bool wm_ply_export_check(bContext *UNUSED(C), wmOperator *op) +static bool wm_ply_export_check(bContext * /*C*/, wmOperator *op) { char filepath[FILE_MAX]; bool changed = false; @@ -232,13 +232,13 @@ static int wm_ply_import_invoke(bContext *C, wmOperator *op, const wmEvent *even static int wm_ply_import_execute(bContext *C, wmOperator *op) { - struct PLYImportParams params; - params.forward_axis = RNA_enum_get(op->ptr, "forward_axis"); - params.up_axis = RNA_enum_get(op->ptr, "up_axis"); + PLYImportParams params{}; + params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis")); + params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis")); params.use_scene_unit = RNA_boolean_get(op->ptr, "use_scene_unit"); params.global_scale = RNA_float_get(op->ptr, "global_scale"); params.merge_verts = RNA_boolean_get(op->ptr, "merge_verts"); - params.vertex_colors = RNA_enum_get(op->ptr, "import_colors"); + params.vertex_colors = ePLYVertexColorMode(RNA_enum_get(op->ptr, "import_colors")); int files_len = RNA_collection_length(op->ptr, "files"); diff --git a/source/blender/editors/io/io_ply_ops.h b/source/blender/editors/io/io_ply_ops.hh similarity index 100% rename from source/blender/editors/io/io_ply_ops.h rename to source/blender/editors/io/io_ply_ops.hh diff --git a/source/blender/editors/io/io_stl_ops.c b/source/blender/editors/io/io_stl_ops.cc similarity index 94% rename from source/blender/editors/io/io_stl_ops.c rename to source/blender/editors/io/io_stl_ops.cc index 22a4bdfd3aa..c99ef8daaed 100644 --- a/source/blender/editors/io/io_stl_ops.c +++ b/source/blender/editors/io/io_stl_ops.cc @@ -22,7 +22,7 @@ # include "RNA_define.h" # include "IO_stl.h" -# include "io_stl_ops.h" +# include "io_stl_ops.hh" static int wm_stl_import_invoke(bContext *C, wmOperator *op, const wmEvent *event) { @@ -31,9 +31,9 @@ static int wm_stl_import_invoke(bContext *C, wmOperator *op, const wmEvent *even static int wm_stl_import_execute(bContext *C, wmOperator *op) { - struct STLImportParams params; - params.forward_axis = RNA_enum_get(op->ptr, "forward_axis"); - params.up_axis = RNA_enum_get(op->ptr, "up_axis"); + STLImportParams params{}; + params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis")); + params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis")); params.use_facet_normal = RNA_boolean_get(op->ptr, "use_facet_normal"); params.use_scene_unit = RNA_boolean_get(op->ptr, "use_scene_unit"); params.global_scale = RNA_float_get(op->ptr, "global_scale"); @@ -73,7 +73,7 @@ static int wm_stl_import_execute(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static bool wm_stl_import_check(bContext *UNUSED(C), wmOperator *op) +static bool wm_stl_import_check(bContext * /*C*/, wmOperator *op) { const int num_axes = 3; /* Both forward and up axes cannot be the same (or same except opposite sign). */ diff --git a/source/blender/editors/io/io_stl_ops.h b/source/blender/editors/io/io_stl_ops.hh similarity index 100% rename from source/blender/editors/io/io_stl_ops.h rename to source/blender/editors/io/io_stl_ops.hh diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.cc similarity index 76% rename from source/blender/editors/io/io_usd.c rename to source/blender/editors/io/io_usd.cc index cb7875efc27..bcd3e838798 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.cc @@ -9,7 +9,8 @@ #ifdef WITH_USD # include "DNA_modifier_types.h" # include "DNA_space_types.h" -# include + +# include # include "BKE_context.h" # include "BKE_main.h" @@ -40,10 +41,10 @@ # include "DEG_depsgraph.h" -# include "io_usd.h" +# include "io_usd.hh" # include "usd.h" -# include +# include const EnumPropertyItem rna_enum_usd_export_evaluation_mode_items[] = { {DAG_EVAL_RENDER, @@ -56,7 +57,7 @@ const EnumPropertyItem rna_enum_usd_export_evaluation_mode_items[] = { 0, "Viewport", "Use Viewport settings for object visibility, modifier settings, etc"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_usd_mtl_name_collision_mode_items[] = { @@ -70,14 +71,14 @@ const EnumPropertyItem rna_enum_usd_mtl_name_collision_mode_items[] = { 0, "Reference Existing", "If a material with the same name already exists, reference that instead of importing"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_usd_tex_import_mode_items[] = { {USD_TEX_IMPORT_NONE, "IMPORT_NONE", 0, "None", "Don't import textures"}, {USD_TEX_IMPORT_PACK, "IMPORT_PACK", 0, "Packed", "Import textures as packed data"}, {USD_TEX_IMPORT_COPY, "IMPORT_COPY", 0, "Copy", "Copy files to textures directory"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_usd_tex_name_collision_mode_items[] = { @@ -87,21 +88,21 @@ const EnumPropertyItem rna_enum_usd_tex_name_collision_mode_items[] = { "Use Existing", "If a file with the same name already exists, use that instead of copying"}, {USD_TEX_NAME_COLLISION_OVERWRITE, "OVERWRITE", 0, "Overwrite", "Overwrite existing files"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* Stored in the wmOperator's customdata field to indicate it should run as a background job. * This is set when the operator is invoked, and not set when it is only executed. */ enum { AS_BACKGROUND_JOB = 1 }; -typedef struct eUSDOperatorOptions { +struct eUSDOperatorOptions { bool as_background_job; -} eUSDOperatorOptions; +}; /* Ensure that the prim_path is not set to * the absolute root path '/'. */ static void process_prim_path(char *prim_path) { - if (prim_path == NULL || prim_path[0] == '\0') { + if (prim_path == nullptr || prim_path[0] == '\0') { return; } @@ -112,9 +113,9 @@ static void process_prim_path(char *prim_path) } } -static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - eUSDOperatorOptions *options = MEM_callocN(sizeof(eUSDOperatorOptions), "eUSDOperatorOptions"); + eUSDOperatorOptions *options = MEM_cnew("eUSDOperatorOptions"); options->as_background_job = true; op->customdata = options; @@ -135,8 +136,8 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op) char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - eUSDOperatorOptions *options = (eUSDOperatorOptions *)op->customdata; - const bool as_background_job = (options != NULL && options->as_background_job); + eUSDOperatorOptions *options = static_cast(op->customdata); + const bool as_background_job = (options != nullptr && options->as_background_job); MEM_SAFE_FREE(op->customdata); const bool selected_objects_only = RNA_boolean_get(op->ptr, "selected_objects_only"); @@ -158,7 +159,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "root_prim_path", root_prim_path); process_prim_path(root_prim_path); - struct USDExportParams params = { + USDExportParams params = { export_animation, export_hair, export_uvmaps, @@ -167,7 +168,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op) selected_objects_only, visible_objects_only, use_instancing, - evaluation_mode, + eEvaluationMode(evaluation_mode), generate_preview_surface, export_textures, overwrite_textures, @@ -181,75 +182,75 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op) return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -static void wm_usd_export_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_usd_export_draw(bContext * /*C*/, wmOperator *op) { uiLayout *layout = op->layout; uiLayout *col; - struct PointerRNA *ptr = op->ptr; + PointerRNA *ptr = op->ptr; uiLayoutSetPropSep(layout, true); uiLayout *box = uiLayoutBox(layout); col = uiLayoutColumn(box, true); - uiItemR(col, ptr, "selected_objects_only", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "visible_objects_only", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "selected_objects_only", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "visible_objects_only", 0, nullptr, ICON_NONE); col = uiLayoutColumn(box, true); - uiItemR(col, ptr, "export_animation", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "export_hair", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "export_uvmaps", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "export_normals", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "export_materials", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "root_prim_path", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "export_animation", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "export_hair", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "export_uvmaps", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "export_normals", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "export_materials", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "root_prim_path", 0, nullptr, ICON_NONE); col = uiLayoutColumn(box, true); - uiItemR(col, ptr, "evaluation_mode", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "evaluation_mode", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); col = uiLayoutColumnWithHeading(box, true, IFACE_("Materials")); - uiItemR(col, ptr, "generate_preview_surface", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "generate_preview_surface", 0, nullptr, ICON_NONE); const bool export_mtl = RNA_boolean_get(ptr, "export_materials"); uiLayoutSetActive(col, export_mtl); uiLayout *row = uiLayoutRow(col, true); - uiItemR(row, ptr, "export_textures", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "export_textures", 0, nullptr, ICON_NONE); const bool preview = RNA_boolean_get(ptr, "generate_preview_surface"); uiLayoutSetActive(row, export_mtl && preview); row = uiLayoutRow(col, true); - uiItemR(row, ptr, "overwrite_textures", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "overwrite_textures", 0, nullptr, ICON_NONE); const bool export_tex = RNA_boolean_get(ptr, "export_textures"); uiLayoutSetActive(row, export_mtl && preview && export_tex); box = uiLayoutBox(layout); col = uiLayoutColumnWithHeading(box, true, IFACE_("File References")); - uiItemR(col, ptr, "relative_paths", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "relative_paths", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); uiItemL(box, IFACE_("Experimental"), ICON_NONE); - uiItemR(box, ptr, "use_instancing", 0, NULL, ICON_NONE); + uiItemR(box, ptr, "use_instancing", 0, nullptr, ICON_NONE); } static void free_operator_customdata(wmOperator *op) { if (op->customdata) { MEM_freeN(op->customdata); - op->customdata = NULL; + op->customdata = nullptr; } } -static void wm_usd_export_cancel(bContext *UNUSED(C), wmOperator *op) +static void wm_usd_export_cancel(bContext * /*C*/, wmOperator *op) { free_operator_customdata(op); } -static bool wm_usd_export_check(bContext *UNUSED(C), wmOperator *op) +static bool wm_usd_export_check(bContext * /*C*/, wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - if (!BLI_path_extension_check_n(filepath, ".usd", ".usda", ".usdc", ".usdz", NULL)) { + if (!BLI_path_extension_check_n(filepath, ".usd", ".usda", ".usdc", ".usdz", nullptr)) { BLI_path_extension_ensure(filepath, FILE_MAX, ".usdc"); RNA_string_set(op->ptr, "filepath", filepath); return true; @@ -258,7 +259,7 @@ static bool wm_usd_export_check(bContext *UNUSED(C), wmOperator *op) return false; } -void WM_OT_usd_export(struct wmOperatorType *ot) +void WM_OT_usd_export(wmOperatorType *ot) { ot->name = "Export USD"; ot->description = "Export current scene in a USD archive"; @@ -363,7 +364,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot) RNA_def_string(ot->srna, "root_prim_path", - NULL, + nullptr, FILE_MAX, "Root Prim", "If set, add a transform primitive with the given path to the stage " @@ -374,7 +375,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot) static int wm_usd_import_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - eUSDOperatorOptions *options = MEM_callocN(sizeof(eUSDOperatorOptions), "eUSDOperatorOptions"); + eUSDOperatorOptions *options = MEM_cnew("eUSDOperatorOptions"); options->as_background_job = true; op->customdata = options; @@ -391,8 +392,8 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op) char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - eUSDOperatorOptions *options = (eUSDOperatorOptions *)op->customdata; - const bool as_background_job = (options != NULL && options->as_background_job); + eUSDOperatorOptions *options = static_cast(op->customdata); + const bool as_background_job = (options != nullptr && options->as_background_job); MEM_SAFE_FREE(op->customdata); const float scale = RNA_float_get(op->ptr, "scale"); @@ -426,7 +427,7 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op) const bool create_collection = RNA_boolean_get(op->ptr, "create_collection"); - char *prim_path_mask = RNA_string_get_alloc(op->ptr, "prim_path_mask", NULL, 0, NULL); + char *prim_path_mask = RNA_string_get_alloc(op->ptr, "prim_path_mask", nullptr, 0, nullptr); const bool import_guide = RNA_boolean_get(op->ptr, "import_guide"); const bool import_proxy = RNA_boolean_get(op->ptr, "import_proxy"); @@ -439,8 +440,8 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op) const float light_intensity_scale = RNA_float_get(op->ptr, "light_intensity_scale"); - const eUSDMtlNameCollisionMode mtl_name_collision_mode = RNA_enum_get(op->ptr, - "mtl_name_collision_mode"); + const eUSDMtlNameCollisionMode mtl_name_collision_mode = eUSDMtlNameCollisionMode( + RNA_enum_get(op->ptr, "mtl_name_collision_mode")); /* TODO(makowalski): Add support for sequences. */ const bool is_sequence = false; @@ -456,44 +457,46 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op) const bool validate_meshes = false; const bool use_instancing = false; - const eUSDTexImportMode import_textures_mode = RNA_enum_get(op->ptr, "import_textures_mode"); + const eUSDTexImportMode import_textures_mode = eUSDTexImportMode( + RNA_enum_get(op->ptr, "import_textures_mode")); char import_textures_dir[FILE_MAXDIR]; RNA_string_get(op->ptr, "import_textures_dir", import_textures_dir); - const eUSDTexNameCollisionMode tex_name_collision_mode = RNA_enum_get(op->ptr, - "tex_name_collision_mode"); + const eUSDTexNameCollisionMode tex_name_collision_mode = eUSDTexNameCollisionMode( + RNA_enum_get(op->ptr, "tex_name_collision_mode")); - struct USDImportParams params = {.scale = scale, - .is_sequence = is_sequence, - .set_frame_range = set_frame_range, - .sequence_len = sequence_len, - .offset = offset, - .validate_meshes = validate_meshes, - .mesh_read_flag = mesh_read_flag, - .import_cameras = import_cameras, - .import_curves = import_curves, - .import_lights = import_lights, - .import_materials = import_materials, - .import_meshes = import_meshes, - .import_volumes = import_volumes, - .import_shapes = import_shapes, - .prim_path_mask = prim_path_mask, - .import_subdiv = import_subdiv, - .import_instance_proxies = import_instance_proxies, - .create_collection = create_collection, - .import_guide = import_guide, - .import_proxy = import_proxy, - .import_render = import_render, - .import_visible_only = import_visible_only, - .use_instancing = use_instancing, - .import_usd_preview = import_usd_preview, - .set_material_blend = set_material_blend, - .light_intensity_scale = light_intensity_scale, - .mtl_name_collision_mode = mtl_name_collision_mode, - .import_textures_mode = import_textures_mode, - .tex_name_collision_mode = tex_name_collision_mode, - .import_all_materials = import_all_materials}; + USDImportParams params{}; + params.scale = scale; + params.is_sequence = is_sequence; + params.set_frame_range = set_frame_range; + params.sequence_len = sequence_len; + params.offset = offset; + params.validate_meshes = validate_meshes; + params.mesh_read_flag = mesh_read_flag; + params.import_cameras = import_cameras; + params.import_curves = import_curves; + params.import_lights = import_lights; + params.import_materials = import_materials; + params.import_meshes = import_meshes; + params.import_volumes = import_volumes; + params.import_shapes = import_shapes; + params.prim_path_mask = prim_path_mask; + params.import_subdiv = import_subdiv; + params.import_instance_proxies = import_instance_proxies; + params.create_collection = create_collection; + params.import_guide = import_guide; + params.import_proxy = import_proxy; + params.import_render = import_render; + params.import_visible_only = import_visible_only; + params.use_instancing = use_instancing; + params.import_usd_preview = import_usd_preview; + params.set_material_blend = set_material_blend; + params.light_intensity_scale = light_intensity_scale; + params.mtl_name_collision_mode = mtl_name_collision_mode; + params.import_textures_mode = import_textures_mode; + params.tex_name_collision_mode = tex_name_collision_mode; + params.import_all_materials = import_all_materials; STRNCPY(params.import_textures_dir, import_textures_dir); @@ -502,73 +505,73 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op) return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -static void wm_usd_import_cancel(bContext *UNUSED(C), wmOperator *op) +static void wm_usd_import_cancel(bContext * /*C*/, wmOperator *op) { free_operator_customdata(op); } -static void wm_usd_import_draw(bContext *UNUSED(C), wmOperator *op) +static void wm_usd_import_draw(bContext * /*C*/, wmOperator *op) { uiLayout *layout = op->layout; - struct PointerRNA *ptr = op->ptr; + PointerRNA *ptr = op->ptr; uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); uiLayout *box = uiLayoutBox(layout); uiLayout *col = uiLayoutColumnWithHeading(box, true, IFACE_("Data Types")); - uiItemR(col, ptr, "import_cameras", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_curves", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_lights", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_materials", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_meshes", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_volumes", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_shapes", 0, NULL, ICON_NONE); - uiItemR(box, ptr, "prim_path_mask", 0, NULL, ICON_NONE); - uiItemR(box, ptr, "scale", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_cameras", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_curves", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_lights", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_materials", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_meshes", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_volumes", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_shapes", 0, nullptr, ICON_NONE); + uiItemR(box, ptr, "prim_path_mask", 0, nullptr, ICON_NONE); + uiItemR(box, ptr, "scale", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); col = uiLayoutColumnWithHeading(box, true, IFACE_("Mesh Data")); - uiItemR(col, ptr, "read_mesh_uvs", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "read_mesh_colors", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "read_mesh_uvs", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "read_mesh_colors", 0, nullptr, ICON_NONE); col = uiLayoutColumnWithHeading(box, true, IFACE_("Include")); uiItemR(col, ptr, "import_subdiv", 0, IFACE_("Subdivision"), ICON_NONE); - uiItemR(col, ptr, "import_instance_proxies", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_visible_only", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_guide", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_proxy", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_render", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_instance_proxies", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_visible_only", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_guide", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_proxy", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_render", 0, nullptr, ICON_NONE); col = uiLayoutColumnWithHeading(box, true, IFACE_("Options")); - uiItemR(col, ptr, "set_frame_range", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "relative_path", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "create_collection", 0, NULL, ICON_NONE); - uiItemR(box, ptr, "light_intensity_scale", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "set_frame_range", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "relative_path", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "create_collection", 0, nullptr, ICON_NONE); + uiItemR(box, ptr, "light_intensity_scale", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); col = uiLayoutColumnWithHeading(box, true, IFACE_("Materials")); - uiItemR(col, ptr, "import_all_materials", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "import_usd_preview", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_all_materials", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "import_usd_preview", 0, nullptr, ICON_NONE); uiLayoutSetEnabled(col, RNA_boolean_get(ptr, "import_materials")); uiLayout *row = uiLayoutRow(col, true); - uiItemR(row, ptr, "set_material_blend", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "set_material_blend", 0, nullptr, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(ptr, "import_usd_preview")); - uiItemR(col, ptr, "mtl_name_collision_mode", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "mtl_name_collision_mode", 0, nullptr, ICON_NONE); box = uiLayoutBox(layout); col = uiLayoutColumn(box, true); - uiItemR(col, ptr, "import_textures_mode", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_textures_mode", 0, nullptr, ICON_NONE); bool copy_textures = RNA_enum_get(op->ptr, "import_textures_mode") == USD_TEX_IMPORT_COPY; row = uiLayoutRow(col, true); - uiItemR(row, ptr, "import_textures_dir", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "import_textures_dir", 0, nullptr, ICON_NONE); uiLayoutSetEnabled(row, copy_textures); row = uiLayoutRow(col, true); - uiItemR(row, ptr, "tex_name_collision_mode", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "tex_name_collision_mode", 0, nullptr, ICON_NONE); uiLayoutSetEnabled(row, copy_textures); uiLayoutSetEnabled(col, RNA_boolean_get(ptr, "import_materials")); } -void WM_OT_usd_import(struct wmOperatorType *ot) +void WM_OT_usd_import(wmOperatorType *ot) { ot->name = "Import USD"; ot->description = "Import USD stage into current scene"; @@ -652,7 +655,7 @@ void WM_OT_usd_import(struct wmOperatorType *ot) RNA_def_string(ot->srna, "prim_path_mask", - NULL, + nullptr, 0, "Path Mask", "Import only the primitive at the given path and its descendents. " diff --git a/source/blender/editors/io/io_usd.h b/source/blender/editors/io/io_usd.hh similarity index 99% rename from source/blender/editors/io/io_usd.h rename to source/blender/editors/io/io_usd.hh index 8d8169789b6..1d8db33ce53 100644 --- a/source/blender/editors/io/io_usd.h +++ b/source/blender/editors/io/io_usd.hh @@ -11,5 +11,4 @@ struct wmOperatorType; void WM_OT_usd_export(struct wmOperatorType *ot); - void WM_OT_usd_import(struct wmOperatorType *ot); diff --git a/source/blender/io/common/IO_orientation.h b/source/blender/io/common/IO_orientation.h index eeae532bf9b..16e27b0fca3 100644 --- a/source/blender/io/common/IO_orientation.h +++ b/source/blender/io/common/IO_orientation.h @@ -9,6 +9,10 @@ struct Main; struct Scene; +#ifdef __cplusplus +extern "C" { +#endif + typedef enum { IO_AXIS_X = 0, IO_AXIS_Y = 1, @@ -22,3 +26,7 @@ extern const EnumPropertyItem io_transform_axis[]; void io_ui_forward_axis_update(struct Main *main, struct Scene *scene, struct PointerRNA *ptr); void io_ui_up_axis_update(struct Main *main, struct Scene *scene, struct PointerRNA *ptr); + +#ifdef __cplusplus +} +#endif