WIP: use generic copy-on-write system to avoid unnecessary data copies #104470

Closed
Jacques Lucke wants to merge 50 commits from JacquesLucke/blender:temp-copy-on-write-customdata into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
42 changed files with 799 additions and 750 deletions
Showing only changes of commit ef1f42865e - Show all commits

View File

@ -93,6 +93,7 @@ typedef enum eUndoPushReturn {
UNDO_PUSH_RET_SUCCESS = (1 << 0),
UNDO_PUSH_RET_OVERRIDE_CHANGED = (1 << 1),
} eUndoPushReturn;
ENUM_OPERATORS(eUndoPushReturn, UNDO_PUSH_RET_OVERRIDE_CHANGED)
typedef void (*UndoTypeForEachIDRefFn)(void *user_data, struct UndoRefID *id_ref);
@ -137,7 +138,7 @@ typedef struct UndoType {
/**
* The size of the undo struct 'inherited' from #UndoStep for that specific type. Used for
* generic allocation in BKE's `undo_system.c`. */
* generic allocation in BKE's `undo_system.cc`. */
size_t step_size;
} UndoType;

View File

@ -114,7 +114,9 @@ int BKE_volume_grid_channels(const struct VolumeGrid *grid);
* Transformation from index space to object space.
*/
void BKE_volume_grid_transform_matrix(const struct VolumeGrid *grid, float mat[4][4]);
void BKE_volume_grid_transform_matrix_set(struct VolumeGrid *volume_grid, const float mat[4][4]);
void BKE_volume_grid_transform_matrix_set(const struct Volume *volume,
struct VolumeGrid *volume_grid,
const float mat[4][4]);
/* Volume Editing
*

View File

@ -78,9 +78,9 @@ set(SRC
intern/autoexec.c
intern/blender.c
intern/blender_copybuffer.c
intern/blender_undo.c
intern/blender_undo.cc
intern/blender_user_menu.c
intern/blendfile.c
intern/blendfile.cc
intern/blendfile_link_append.c
intern/boids.c
intern/bpath.c
@ -296,7 +296,7 @@ set(SRC
intern/tracking_stabilize.c
intern/tracking_util.c
intern/type_conversions.cc
intern/undo_system.c
intern/undo_system.cc
intern/unit.c
intern/vfont.c
intern/vfontdata_freetype.c

View File

@ -63,10 +63,10 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
G.fileflags |= G_FILE_NO_UI;
if (UNDO_DISK) {
const struct BlendFileReadParams params = {0};
BlendFileReadReport bf_reports = {.reports = NULL};
const BlendFileReadParams params{};
BlendFileReadReport bf_reports{};
struct BlendFileData *bfd = BKE_blendfile_read(mfu->filepath, &params, &bf_reports);
if (bfd != NULL) {
if (bfd != nullptr) {
BKE_blendfile_read_setup(C, bfd, &params, &bf_reports);
success = true;
}
@ -77,10 +77,11 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
if (!use_old_bmain_data) {
params.skip_flags |= BLO_READ_SKIP_UNDO_OLD_MAIN;
}
BlendFileReadReport blend_file_read_report{};
struct BlendFileData *bfd = BKE_blendfile_read_from_memfile(
bmain, &mfu->memfile, &params, NULL);
if (bfd != NULL) {
BKE_blendfile_read_setup(C, bfd, &params, &(BlendFileReadReport){NULL});
bmain, &mfu->memfile, &params, nullptr);
if (bfd != nullptr) {
BKE_blendfile_read_setup(C, bfd, &params, &blend_file_read_report);
success = true;
}
}
@ -100,7 +101,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
{
MemFileUndoData *mfu = MEM_callocN(sizeof(MemFileUndoData), __func__);
MemFileUndoData *mfu = MEM_cnew<MemFileUndoData>(__func__);
/* Include recovery information since undo-data is written out as #BLENDER_QUIT_FILE. */
const int fileflags = G.fileflags | G_FILE_RECOVER_WRITE;
@ -118,13 +119,14 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_session(), numstr);
const BlendFileWriteParams blend_file_write_params{};
/* success = */ /* UNUSED */ BLO_write_file(
bmain, filepath, fileflags, &(const struct BlendFileWriteParams){0}, NULL);
bmain, filepath, fileflags, &blend_file_write_params, nullptr);
BLI_strncpy(mfu->filepath, filepath, sizeof(mfu->filepath));
}
else {
MemFile *prevfile = (mfu_prev) ? &(mfu_prev->memfile) : NULL;
MemFile *prevfile = (mfu_prev) ? &(mfu_prev->memfile) : nullptr;
if (prevfile) {
BLO_memfile_clear_future(prevfile);
}

View File

@ -83,7 +83,7 @@ static bool blendfile_or_libraries_versions_atleast(Main *bmain,
return true;
}
static bool foreach_path_clean_cb(BPathForeachPathData *UNUSED(bpath_data),
static bool foreach_path_clean_cb(BPathForeachPathData * /*bpath_data*/,
char *path_dst,
const char *path_src)
{
@ -95,12 +95,13 @@ static bool foreach_path_clean_cb(BPathForeachPathData *UNUSED(bpath_data),
/* make sure path names are correct for OS */
static void clean_paths(Main *bmain)
{
BKE_bpath_foreach_path_main(&(BPathForeachPathData){
.bmain = bmain,
.callback_function = foreach_path_clean_cb,
.flag = BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE,
.user_data = NULL,
});
BPathForeachPathData foreach_path_data{};
foreach_path_data.bmain = bmain;
foreach_path_data.callback_function = foreach_path_clean_cb;
foreach_path_data.flag = BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE;
foreach_path_data.user_data = nullptr;
BKE_bpath_foreach_path_main(&foreach_path_data);
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
BLI_path_slash_native(scene->r.pic);
@ -110,7 +111,7 @@ static void clean_paths(Main *bmain)
static bool wm_scene_is_visible(wmWindowManager *wm, Scene *scene)
{
wmWindow *win;
for (win = wm->windows.first; win; win = win->next) {
for (win = static_cast<wmWindow *>(wm->windows.first); win; win = win->next) {
if (win->scene == scene) {
return true;
}
@ -123,7 +124,7 @@ static void setup_app_userdef(BlendFileData *bfd)
if (bfd->user) {
/* only here free userdef themes... */
BKE_blender_userdef_data_set_and_free(bfd->user);
bfd->user = NULL;
bfd->user = nullptr;
/* Security issue: any blend file could include a USER block.
*
@ -151,7 +152,7 @@ static void setup_app_data(bContext *C,
BlendFileReadReport *reports)
{
Main *bmain = G_MAIN;
Scene *curscene = NULL;
Scene *curscene = nullptr;
const bool recover = (G.fileflags & G_FILE_RECOVER_READ) != 0;
const bool is_startup = params->is_startup;
enum {
@ -161,12 +162,12 @@ static void setup_app_data(bContext *C,
} mode;
if (params->undo_direction != STEP_INVALID) {
BLI_assert(bfd->curscene != NULL);
BLI_assert(bfd->curscene != nullptr);
mode = LOAD_UNDO;
}
/* may happen with library files - UNDO file should never have NULL curscene (but may have a
* NULL curscreen)... */
else if (ELEM(NULL, bfd->curscreen, bfd->curscene)) {
/* may happen with library files - UNDO file should never have nullptr curscene (but may have a
* nullptr curscreen)... */
else if (ELEM(nullptr, bfd->curscreen, bfd->curscene)) {
BKE_report(reports->reports, RPT_WARNING, "Library file, loading empty scene");
mode = LOAD_UI_OFF;
}
@ -205,7 +206,7 @@ static void setup_app_data(bContext *C,
* see: T43424
*/
wmWindow *win;
bScreen *curscreen = NULL;
bScreen *curscreen = nullptr;
ViewLayer *cur_view_layer;
bool track_undo_scene;
@ -213,10 +214,10 @@ static void setup_app_data(bContext *C,
SWAP(ListBase, bmain->wm, bfd->main->wm);
SWAP(ListBase, bmain->workspaces, bfd->main->workspaces);
SWAP(ListBase, bmain->screens, bfd->main->screens);
if (bmain->name_map != NULL) {
if (bmain->name_map != nullptr) {
BKE_main_namemap_destroy(&bmain->name_map);
}
if (bfd->main->name_map != NULL) {
if (bfd->main->name_map != nullptr) {
BKE_main_namemap_destroy(&bfd->main->name_map);
}
@ -250,14 +251,14 @@ static void setup_app_data(bContext *C,
track_undo_scene = (mode == LOAD_UNDO && curscreen && curscene && bfd->main->wm.first);
if (curscene == NULL) {
curscene = bfd->main->scenes.first;
if (curscene == nullptr) {
curscene = static_cast<Scene *>(bfd->main->scenes.first);
}
/* empty file, we add a scene to make Blender work */
if (curscene == NULL) {
if (curscene == nullptr) {
curscene = BKE_scene_add(bfd->main, "Empty");
}
if (cur_view_layer == NULL) {
if (cur_view_layer == nullptr) {
/* fallback to scene layer */
cur_view_layer = BKE_view_layer_default_view(curscene);
}
@ -267,7 +268,7 @@ static void setup_app_data(bContext *C,
* replace it with 'curscene' if its needed */
}
/* and we enforce curscene to be in current screen */
else if (win) { /* The window may be NULL in background-mode. */
else if (win) { /* The window may be nullptr in background-mode. */
win->scene = curscene;
}
@ -278,7 +279,7 @@ static void setup_app_data(bContext *C,
}
if (track_undo_scene) {
wmWindowManager *wm = bfd->main->wm.first;
wmWindowManager *wm = static_cast<wmWindowManager *>(bfd->main->wm.first);
if (wm_scene_is_visible(wm, bfd->curscene) == false) {
curscene = bfd->curscene;
win->scene = curscene;
@ -296,7 +297,7 @@ static void setup_app_data(bContext *C,
BKE_blender_globals_main_replace(bfd->main);
bmain = G_MAIN;
bfd->main = NULL;
bfd->main = nullptr;
CTX_data_main_set(C, bmain);
@ -306,12 +307,12 @@ static void setup_app_data(bContext *C,
CTX_data_scene_set(C, curscene);
}
else {
CTX_wm_manager_set(C, bmain->wm.first);
CTX_wm_manager_set(C, static_cast<wmWindowManager *>(bmain->wm.first));
CTX_wm_screen_set(C, bfd->curscreen);
CTX_data_scene_set(C, bfd->curscene);
CTX_wm_area_set(C, NULL);
CTX_wm_region_set(C, NULL);
CTX_wm_menu_set(C, NULL);
CTX_wm_area_set(C, nullptr);
CTX_wm_region_set(C, nullptr);
CTX_wm_menu_set(C, nullptr);
curscene = bfd->curscene;
}
@ -320,7 +321,7 @@ static void setup_app_data(bContext *C,
G.fileflags = (G.fileflags & fileflags_keep) | (bfd->fileflags & ~fileflags_keep);
/* this can happen when active scene was lib-linked, and doesn't exist anymore */
if (CTX_data_scene(C) == NULL) {
if (CTX_data_scene(C) == nullptr) {
wmWindow *win = CTX_wm_window(C);
/* in case we don't even have a local scene, add one */
@ -328,7 +329,7 @@ static void setup_app_data(bContext *C,
BKE_scene_add(bmain, "Empty");
}
CTX_data_scene_set(C, bmain->scenes.first);
CTX_data_scene_set(C, static_cast<Scene *>(bmain->scenes.first));
win->scene = CTX_data_scene(C);
curscene = CTX_data_scene(C);
}
@ -384,7 +385,7 @@ static void setup_app_data(bContext *C,
/* baseflags, groups, make depsgraph, etc */
/* first handle case if other windows have different scenes visible */
if (mode == LOAD_UI) {
wmWindowManager *wm = bmain->wm.first;
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
if (wm) {
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
@ -435,7 +436,7 @@ static void setup_app_data(bContext *C,
reports->duration.lib_overrides_resync;
/* We need to rebuild some of the deleted override rules (for UI feedback purpose). */
BKE_lib_override_library_main_operations_create(bmain, true, NULL);
BKE_lib_override_library_main_operations_create(bmain, true, nullptr);
}
}
@ -487,7 +488,7 @@ void BKE_blendfile_read_setup(bContext *C,
const struct BlendFileReadParams *params,
BlendFileReadReport *reports)
{
BKE_blendfile_read_setup_ex(C, bfd, params, reports, false, NULL);
BKE_blendfile_read_setup_ex(C, bfd, params, reports, false, nullptr);
}
struct BlendFileData *BKE_blendfile_read(const char *filepath,
@ -499,7 +500,7 @@ struct BlendFileData *BKE_blendfile_read(const char *filepath,
printf("Read blend: %s\n", filepath);
}
BlendFileData *bfd = BLO_read_from_file(filepath, params->skip_flags, reports);
BlendFileData *bfd = BLO_read_from_file(filepath, eBLOReadSkip(params->skip_flags), reports);
if (bfd) {
handle_subversion_warning(bfd->main, reports);
}
@ -514,7 +515,8 @@ struct BlendFileData *BKE_blendfile_read_from_memory(const void *filebuf,
const struct BlendFileReadParams *params,
ReportList *reports)
{
BlendFileData *bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports);
BlendFileData *bfd = BLO_read_from_memory(
filebuf, filelength, eBLOReadSkip(params->skip_flags), reports);
if (bfd) {
/* Pass. */
}
@ -595,11 +597,13 @@ void BKE_blendfile_read_make_empty(bContext *C)
UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports)
{
BlendFileData *bfd;
UserDef *userdef = NULL;
UserDef *userdef = nullptr;
bfd = BLO_read_from_file(filepath,
BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF,
&(struct BlendFileReadReport){.reports = reports});
BlendFileReadReport blend_file_read_reports{};
blend_file_read_reports.reports = reports;
bfd = BLO_read_from_file(
filepath, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, &blend_file_read_reports);
if (bfd) {
if (bfd->user) {
userdef = bfd->user;
@ -616,7 +620,7 @@ UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
ReportList *reports)
{
BlendFileData *bfd;
UserDef *userdef = NULL;
UserDef *userdef = nullptr;
bfd = BLO_read_from_memory(
filebuf, filelength, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, reports);
@ -636,8 +640,8 @@ UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
UserDef *BKE_blendfile_userdef_from_defaults(void)
{
UserDef *userdef = MEM_mallocN(sizeof(*userdef), __func__);
memcpy(userdef, &U_default, sizeof(*userdef));
UserDef *userdef = MEM_cnew<UserDef>(__func__);
*userdef = blender::dna::shallow_copy(U_default);
/* Add-ons. */
{
@ -663,7 +667,7 @@ UserDef *BKE_blendfile_userdef_from_defaults(void)
/* Theme. */
{
bTheme *btheme = MEM_mallocN(sizeof(*btheme), __func__);
bTheme *btheme = static_cast<bTheme *>(MEM_mallocN(sizeof(*btheme), __func__));
memcpy(btheme, &U_theme_default, sizeof(*btheme));
BLI_addtail(&userdef->themes, btheme);
@ -696,16 +700,13 @@ UserDef *BKE_blendfile_userdef_from_defaults(void)
bool BKE_blendfile_userdef_write(const char *filepath, ReportList *reports)
{
Main *mainb = MEM_callocN(sizeof(Main), "empty main");
Main *mainb = MEM_cnew<Main>("empty main");
bool ok = false;
if (BLO_write_file(mainb,
filepath,
0,
&(const struct BlendFileWriteParams){
.use_userdef = true,
},
reports)) {
BlendFileWriteParams params{};
params.use_userdef = true;
if (BLO_write_file(mainb, filepath, 0, &params, reports)) {
ok = true;
}
@ -721,9 +722,9 @@ bool BKE_blendfile_userdef_write_app_template(const char *filepath, ReportList *
* falling back to the defaults.
* If the preferences exists but file reading fails - the file can be assumed corrupt
* so overwriting the file is OK. */
UserDef *userdef_default = BLI_exists(filepath) ? BKE_blendfile_userdef_read(filepath, NULL) :
NULL;
if (userdef_default == NULL) {
UserDef *userdef_default = BLI_exists(filepath) ? BKE_blendfile_userdef_read(filepath, nullptr) :
nullptr;
if (userdef_default == nullptr) {
userdef_default = BKE_blendfile_userdef_from_defaults();
}
@ -742,7 +743,7 @@ bool BKE_blendfile_userdef_write_all(ReportList *reports)
bool ok = true;
const bool use_template_userpref = BKE_appdir_app_template_has_userpref(U.app_template);
if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL))) {
if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, nullptr))) {
bool ok_write;
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE);
@ -806,18 +807,19 @@ WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepat
ReportList *reports)
{
BlendFileData *bfd;
WorkspaceConfigFileData *workspace_config = NULL;
WorkspaceConfigFileData *workspace_config = nullptr;
if (filepath) {
bfd = BLO_read_from_file(
filepath, BLO_READ_SKIP_USERDEF, &(struct BlendFileReadReport){.reports = reports});
BlendFileReadReport blend_file_read_reports{};
blend_file_read_reports.reports = reports;
bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_USERDEF, &blend_file_read_reports);
}
else {
bfd = BLO_read_from_memory(filebuf, filelength, BLO_READ_SKIP_USERDEF, reports);
}
if (bfd) {
workspace_config = MEM_callocN(sizeof(*workspace_config), __func__);
workspace_config = MEM_cnew<WorkspaceConfigFileData>(__func__);
workspace_config->main = bfd->main;
/* Only 2.80+ files have actual workspaces, don't try to use screens
@ -839,7 +841,8 @@ bool BKE_blendfile_workspace_config_write(Main *bmain, const char *filepath, Rep
BKE_blendfile_write_partial_begin(bmain);
for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
for (WorkSpace *workspace = static_cast<WorkSpace *>(bmain->workspaces.first); workspace;
workspace = static_cast<WorkSpace *>(workspace->id.next)) {
BKE_blendfile_write_partial_tag_ID(&workspace->id, true);
}
@ -880,10 +883,10 @@ void BKE_blendfile_write_partial_tag_ID(ID *id, bool set)
}
}
static void blendfile_write_partial_cb(void *UNUSED(handle), Main *UNUSED(bmain), void *vid)
static void blendfile_write_partial_cb(void * /*handle*/, Main * /*bmain*/, void *vid)
{
if (vid) {
ID *id = vid;
ID *id = static_cast<ID *>(vid);
/* only tag for need-expand if not done, prevents eternal loops */
if ((id->tag & LIB_TAG_DOIT) == 0) {
id->tag |= LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT;
@ -901,11 +904,11 @@ bool BKE_blendfile_write_partial(Main *bmain_src,
const int remap_mode,
ReportList *reports)
{
Main *bmain_dst = MEM_callocN(sizeof(Main), "copybuffer");
Main *bmain_dst = MEM_cnew<Main>("copybuffer");
ListBase *lbarray_dst[INDEX_ID_MAX], *lbarray_src[INDEX_ID_MAX];
int a, retval;
void *path_list_backup = NULL;
void *path_list_backup = nullptr;
const eBPathForeachFlag path_list_flag = (BKE_BPATH_FOREACH_PATH_SKIP_LINKED |
BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE);
@ -914,7 +917,7 @@ bool BKE_blendfile_write_partial(Main *bmain_src,
STRNCPY(bmain_dst->filepath, bmain_src->filepath);
BLO_main_expander(blendfile_write_partial_cb);
BLO_expand_main(NULL, bmain_src);
BLO_expand_main(nullptr, bmain_src);
/* move over all tagged blocks */
set_listbasepointers(bmain_src, lbarray_src);
@ -923,8 +926,8 @@ bool BKE_blendfile_write_partial(Main *bmain_src,
ID *id, *nextid;
ListBase *lb_dst = lbarray_dst[a], *lb_src = lbarray_src[a];
for (id = lb_src->first; id; id = nextid) {
nextid = id->next;
for (id = static_cast<ID *>(lb_src->first); id; id = nextid) {
nextid = static_cast<ID *>(id->next);
if (id->tag & LIB_TAG_DOIT) {
BLI_remlink(lb_src, id);
BLI_addtail(lb_dst, id);
@ -946,13 +949,9 @@ bool BKE_blendfile_write_partial(Main *bmain_src,
}
/* save the buffer */
retval = BLO_write_file(bmain_dst,
filepath,
write_flags,
&(const struct BlendFileWriteParams){
.remap_mode = remap_mode,
},
reports);
BlendFileWriteParams blend_file_write_params{};
blend_file_write_params.remap_mode = eBLO_WritePathRemap(remap_mode);
retval = BLO_write_file(bmain_dst, filepath, write_flags, &blend_file_write_params, reports);
if (path_list_backup) {
BKE_bpath_list_restore(bmain_dst, path_list_flag, path_list_backup);
@ -966,9 +965,9 @@ bool BKE_blendfile_write_partial(Main *bmain_src,
ID *id;
ListBase *lb_dst = lbarray_dst[a], *lb_src = lbarray_src[a];
while ((id = BLI_pophead(lb_src))) {
while ((id = static_cast<ID *>(BLI_pophead(lb_src)))) {
BLI_addtail(lb_dst, id);
id_sort_by_name(lb_dst, id, NULL);
id_sort_by_name(lb_dst, id, nullptr);
}
}

View File

@ -52,14 +52,14 @@ static CLG_LogRef LOG = {"bke.undosys"};
/** \name Undo Types
* \{ */
const UndoType *BKE_UNDOSYS_TYPE_IMAGE = NULL;
const UndoType *BKE_UNDOSYS_TYPE_MEMFILE = NULL;
const UndoType *BKE_UNDOSYS_TYPE_PAINTCURVE = NULL;
const UndoType *BKE_UNDOSYS_TYPE_PARTICLE = NULL;
const UndoType *BKE_UNDOSYS_TYPE_SCULPT = NULL;
const UndoType *BKE_UNDOSYS_TYPE_TEXT = NULL;
const UndoType *BKE_UNDOSYS_TYPE_IMAGE = nullptr;
const UndoType *BKE_UNDOSYS_TYPE_MEMFILE = nullptr;
const UndoType *BKE_UNDOSYS_TYPE_PAINTCURVE = nullptr;
const UndoType *BKE_UNDOSYS_TYPE_PARTICLE = nullptr;
const UndoType *BKE_UNDOSYS_TYPE_SCULPT = nullptr;
const UndoType *BKE_UNDOSYS_TYPE_TEXT = nullptr;
static ListBase g_undo_types = {NULL, NULL};
static ListBase g_undo_types = {nullptr, nullptr};
static const UndoType *BKE_undosys_type_from_context(bContext *C)
{
@ -69,7 +69,7 @@ static const UndoType *BKE_undosys_type_from_context(bContext *C)
return ut;
}
}
return NULL;
return nullptr;
}
/** \} */
@ -115,13 +115,13 @@ static bool g_undo_callback_running = false;
*
* \{ */
static void undosys_id_ref_store(void *UNUSED(user_data), UndoRefID *id_ref)
static void undosys_id_ref_store(void * /*user_data*/, UndoRefID *id_ref)
{
BLI_assert(id_ref->name[0] == '\0');
if (id_ref->ptr) {
BLI_strncpy(id_ref->name, id_ref->ptr->name, sizeof(id_ref->name));
/* Not needed, just prevents stale data access. */
id_ref->ptr = NULL;
id_ref->ptr = nullptr;
}
}
@ -129,7 +129,7 @@ static void undosys_id_ref_resolve(void *user_data, UndoRefID *id_ref)
{
/* NOTE: we could optimize this,
* for now it's not too bad since it only runs when we access undo! */
Main *bmain = user_data;
Main *bmain = static_cast<Main *>(user_data);
ListBase *lb = which_libbase(bmain, GS(id_ref->name));
LISTBASE_FOREACH (ID *, id, lb) {
if (STREQ(id_ref->name, id->name) && !ID_IS_LINKED(id)) {
@ -146,7 +146,7 @@ static bool undosys_step_encode(bContext *C, Main *bmain, UndoStack *ustack, Und
bool ok = us->type->step_encode(C, bmain, us);
UNDO_NESTED_CHECK_END;
if (ok) {
if (us->type->step_foreach_ID_ref != NULL) {
if (us->type->step_foreach_ID_ref != nullptr) {
/* Don't use from context yet because sometimes context is fake and
* not all members are filled in. */
us->type->step_foreach_ID_ref(us, undosys_id_ref_store, bmain);
@ -221,7 +221,7 @@ static void undosys_step_free_and_unlink(UndoStack *ustack, UndoStep *us)
#ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER
if (ustack->step_active_memfile == us) {
ustack->step_active_memfile = NULL;
ustack->step_active_memfile = nullptr;
}
#endif
}
@ -235,7 +235,7 @@ static void undosys_step_free_and_unlink(UndoStack *ustack, UndoStep *us)
#ifndef NDEBUG
static void undosys_stack_validate(UndoStack *ustack, bool expect_non_empty)
{
if (ustack->step_active != NULL) {
if (ustack->step_active != nullptr) {
BLI_assert(!BLI_listbase_is_empty(&ustack->steps));
BLI_assert(BLI_findindex(&ustack->steps, ustack->step_active) != -1);
}
@ -244,14 +244,14 @@ static void undosys_stack_validate(UndoStack *ustack, bool expect_non_empty)
}
}
#else
static void undosys_stack_validate(UndoStack *UNUSED(ustack), bool UNUSED(expect_non_empty))
static void undosys_stack_validate(UndoStack * /*ustack*/, bool /*expect_non_empty*/)
{
}
#endif
UndoStack *BKE_undosys_stack_create(void)
{
UndoStack *ustack = MEM_callocN(sizeof(UndoStack), __func__);
UndoStack *ustack = MEM_cnew<UndoStack>(__func__);
return ustack;
}
@ -265,12 +265,12 @@ void BKE_undosys_stack_clear(UndoStack *ustack)
{
UNDO_NESTED_ASSERT(false);
CLOG_INFO(&LOG, 1, "steps=%d", BLI_listbase_count(&ustack->steps));
for (UndoStep *us = ustack->steps.last, *us_prev; us; us = us_prev) {
for (UndoStep *us = static_cast<UndoStep *>(ustack->steps.last), *us_prev; us; us = us_prev) {
us_prev = us->prev;
undosys_step_free_and_unlink(ustack, us);
}
BLI_listbase_clear(&ustack->steps);
ustack->step_active = NULL;
ustack->step_active = nullptr;
}
void BKE_undosys_stack_clear_active(UndoStack *ustack)
@ -280,10 +280,10 @@ void BKE_undosys_stack_clear_active(UndoStack *ustack)
if (us) {
ustack->step_active = us->prev;
bool is_not_empty = ustack->step_active != NULL;
bool is_not_empty = ustack->step_active != nullptr;
while (ustack->steps.last != ustack->step_active) {
UndoStep *us_iter = ustack->steps.last;
UndoStep *us_iter = static_cast<UndoStep *>(ustack->steps.last);
undosys_step_free_and_unlink(ustack, us_iter);
undosys_stack_validate(ustack, is_not_empty);
}
@ -297,7 +297,7 @@ static void undosys_stack_clear_all_last(UndoStack *ustack, UndoStep *us)
bool is_not_empty = true;
UndoStep *us_iter;
do {
us_iter = ustack->steps.last;
us_iter = static_cast<UndoStep *>(ustack->steps.last);
BLI_assert(us_iter != ustack->step_active);
undosys_step_free_and_unlink(ustack, us_iter);
undosys_stack_validate(ustack, is_not_empty);
@ -315,7 +315,7 @@ static void undosys_stack_clear_all_first(UndoStack *ustack, UndoStep *us, UndoS
bool is_not_empty = true;
UndoStep *us_iter;
do {
us_iter = ustack->steps.first;
us_iter = static_cast<UndoStep *>(ustack->steps.first);
if (us_iter == us_exclude) {
us_iter = us_iter->next;
}
@ -329,7 +329,7 @@ static void undosys_stack_clear_all_first(UndoStack *ustack, UndoStep *us, UndoS
static bool undosys_stack_push_main(UndoStack *ustack, const char *name, struct Main *bmain)
{
UNDO_NESTED_ASSERT(false);
BLI_assert(ustack->step_init == NULL);
BLI_assert(ustack->step_init == nullptr);
CLOG_INFO(&LOG, 1, "'%s'", name);
bContext *C_temp = CTX_create();
CTX_data_main_set(C_temp, bmain);
@ -348,7 +348,7 @@ void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain)
void BKE_undosys_stack_init_from_context(UndoStack *ustack, bContext *C)
{
const UndoType *ut = BKE_undosys_type_from_context(C);
if (!ELEM(ut, NULL, BKE_UNDOSYS_TYPE_MEMFILE)) {
if (!ELEM(ut, nullptr, BKE_UNDOSYS_TYPE_MEMFILE)) {
BKE_undosys_step_push_with_type(ustack, C, IFACE_("Original Mode"), ut);
}
}
@ -356,7 +356,8 @@ void BKE_undosys_stack_init_from_context(UndoStack *ustack, bContext *C)
bool BKE_undosys_stack_has_undo(const UndoStack *ustack, const char *name)
{
if (name) {
const UndoStep *us = BLI_rfindstring(&ustack->steps, name, offsetof(UndoStep, name));
const UndoStep *us = static_cast<UndoStep *>(
BLI_rfindstring(&ustack->steps, name, offsetof(UndoStep, name)));
return us && us->prev;
}
@ -391,11 +392,11 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size
CLOG_INFO(&LOG, 1, "steps=%d, memory_limit=%zu", steps, memory_limit);
UndoStep *us;
UndoStep *us_exclude = NULL;
UndoStep *us_exclude = nullptr;
/* keep at least two (original + other) */
size_t data_size_all = 0;
size_t us_count = 0;
for (us = ustack->steps.last; us && us->prev; us = us->prev) {
for (us = static_cast<UndoStep *>(ustack->steps.last); us && us->prev; us = us->prev) {
if (memory_limit) {
data_size_all += us->data_size;
if (data_size_all > memory_limit) {
@ -447,7 +448,7 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack,
{
UNDO_NESTED_ASSERT(false);
/* We could detect and clean this up (but it should never happen!). */
BLI_assert(ustack->step_init == NULL);
BLI_assert(ustack->step_init == nullptr);
if (ut->step_encode_init) {
undosys_stack_validate(ustack, false);
@ -455,8 +456,8 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack,
undosys_stack_clear_all_last(ustack, ustack->step_active->next);
}
UndoStep *us = MEM_callocN(ut->step_size, __func__);
if (name != NULL) {
UndoStep *us = static_cast<UndoStep *>(MEM_callocN(ut->step_size, __func__));
if (name != nullptr) {
BLI_strncpy(us->name, name, sizeof(us->name));
}
us->type = ut;
@ -467,17 +468,17 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack,
return us;
}
return NULL;
return nullptr;
}
UndoStep *BKE_undosys_step_push_init(UndoStack *ustack, bContext *C, const char *name)
{
UNDO_NESTED_ASSERT(false);
/* We could detect and clean this up (but it should never happen!). */
BLI_assert(ustack->step_init == NULL);
BLI_assert(ustack->step_init == nullptr);
const UndoType *ut = BKE_undosys_type_from_context(C);
if (ut == NULL) {
return NULL;
if (ut == nullptr) {
return nullptr;
}
return BKE_undosys_step_push_init_with_type(ustack, C, name, ut);
}
@ -487,11 +488,11 @@ eUndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack,
const char *name,
const UndoType *ut)
{
BLI_assert((ut->flags & UNDOTYPE_FLAG_NEED_CONTEXT_FOR_ENCODE) == 0 || C != NULL);
BLI_assert((ut->flags & UNDOTYPE_FLAG_NEED_CONTEXT_FOR_ENCODE) == 0 || C != nullptr);
UNDO_NESTED_ASSERT(false);
undosys_stack_validate(ustack, false);
bool is_not_empty = ustack->step_active != NULL;
bool is_not_empty = ustack->step_active != nullptr;
eUndoPushReturn retval = UNDO_PUSH_RET_FAILURE;
/* Might not be final place for this to be called - probably only want to call it from some
@ -502,9 +503,9 @@ eUndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack,
retval |= UNDO_PUSH_RET_OVERRIDE_CHANGED;
}
/* Remove all undo-steps after (also when 'ustack->step_active == NULL'). */
/* Remove all undo-steps after (also when 'ustack->step_active == nullptr'). */
while (ustack->steps.last != ustack->step_active) {
UndoStep *us_iter = ustack->steps.last;
UndoStep *us_iter = static_cast<UndoStep *>(ustack->steps.last);
undosys_step_free_and_unlink(ustack, us_iter);
undosys_stack_validate(ustack, is_not_empty);
}
@ -514,17 +515,17 @@ eUndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack,
}
#ifdef WITH_GLOBAL_UNDO_ENSURE_UPDATED
if (ut->step_foreach_ID_ref != NULL) {
if (ut->step_foreach_ID_ref != nullptr) {
if (G_MAIN->is_memfile_undo_written == false) {
const char *name_internal = "MemFile Internal (pre)";
/* Don't let 'step_init' cause issues when adding memfile undo step. */
void *step_init = ustack->step_init;
ustack->step_init = NULL;
ustack->step_init = nullptr;
const bool ok = undosys_stack_push_main(ustack, name_internal, G_MAIN);
/* Restore 'step_init'. */
ustack->step_init = step_init;
ustack->step_init = static_cast<UndoStep *>(step_init);
if (ok) {
UndoStep *us = ustack->steps.last;
UndoStep *us = static_cast<UndoStep *>(ustack->steps.last);
BLI_assert(STREQ(us->name, name_internal));
us->skip = true;
# ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER
@ -537,8 +538,10 @@ eUndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack,
bool use_memfile_step = false;
{
UndoStep *us = ustack->step_init ? ustack->step_init : MEM_callocN(ut->step_size, __func__);
ustack->step_init = NULL;
UndoStep *us = ustack->step_init ?
ustack->step_init :
static_cast<UndoStep *>(MEM_callocN(ut->step_size, __func__));
ustack->step_init = nullptr;
if (us->name[0] == '\0') {
BLI_strncpy(us->name, name, sizeof(us->name));
}
@ -566,7 +569,7 @@ eUndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack,
const char *name_internal = us_prev->name;
const bool ok = undosys_stack_push_main(ustack, name_internal, G_MAIN);
if (ok) {
UndoStep *us = ustack->steps.last;
UndoStep *us = static_cast<UndoStep *>(ustack->steps.last);
BLI_assert(STREQ(us->name, name_internal));
us_prev->skip = true;
#ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER
@ -591,8 +594,8 @@ eUndoPushReturn BKE_undosys_step_push(UndoStack *ustack, bContext *C, const char
UNDO_NESTED_ASSERT(false);
const UndoType *ut = ustack->step_init ? ustack->step_init->type :
BKE_undosys_type_from_context(C);
if (ut == NULL) {
return false;
if (ut == nullptr) {
return UNDO_PUSH_RET_FAILURE;
}
return BKE_undosys_step_push_with_type(ustack, C, name, ut);
}
@ -627,40 +630,40 @@ UndoStep *BKE_undosys_step_find_by_name_with_type(UndoStack *ustack,
const char *name,
const UndoType *ut)
{
for (UndoStep *us = ustack->steps.last; us; us = us->prev) {
for (UndoStep *us = static_cast<UndoStep *>(ustack->steps.last); us; us = us->prev) {
if (us->type == ut) {
if (STREQ(name, us->name)) {
return us;
}
}
}
return NULL;
return nullptr;
}
UndoStep *BKE_undosys_step_find_by_name(UndoStack *ustack, const char *name)
{
return BLI_rfindstring(&ustack->steps, name, offsetof(UndoStep, name));
return static_cast<UndoStep *>(BLI_rfindstring(&ustack->steps, name, offsetof(UndoStep, name)));
}
UndoStep *BKE_undosys_step_find_by_type(UndoStack *ustack, const UndoType *ut)
{
for (UndoStep *us = ustack->steps.last; us; us = us->prev) {
for (UndoStep *us = static_cast<UndoStep *>(ustack->steps.last); us; us = us->prev) {
if (us->type == ut) {
return us;
}
}
return NULL;
return nullptr;
}
eUndoStepDir BKE_undosys_step_calc_direction(const UndoStack *ustack,
const UndoStep *us_target,
const UndoStep *us_reference)
{
if (us_reference == NULL) {
if (us_reference == nullptr) {
us_reference = ustack->step_active;
}
BLI_assert(us_reference != NULL);
BLI_assert(us_reference != nullptr);
/* Note that we use heuristics to make this lookup as fast as possible in most common cases,
* assuming that:
@ -676,12 +679,12 @@ eUndoStepDir BKE_undosys_step_calc_direction(const UndoStack *ustack,
}
/* Search forward, and then backward. */
for (UndoStep *us_iter = us_reference->next; us_iter != NULL; us_iter = us_iter->next) {
for (UndoStep *us_iter = us_reference->next; us_iter != nullptr; us_iter = us_iter->next) {
if (us_iter == us_target) {
return STEP_REDO;
}
}
for (UndoStep *us_iter = us_reference->prev; us_iter != NULL; us_iter = us_iter->prev) {
for (UndoStep *us_iter = us_reference->prev; us_iter != nullptr; us_iter = us_iter->prev) {
if (us_iter == us_target) {
return STEP_UNDO;
}
@ -718,16 +721,16 @@ bool BKE_undosys_step_load_data_ex(UndoStack *ustack,
const bool use_skip)
{
UNDO_NESTED_ASSERT(false);
if (us_target == NULL) {
CLOG_ERROR(&LOG, "called with a NULL target step");
if (us_target == nullptr) {
CLOG_ERROR(&LOG, "called with a nullptr target step");
return false;
}
undosys_stack_validate(ustack, true);
if (us_reference == NULL) {
if (us_reference == nullptr) {
us_reference = ustack->step_active;
}
if (us_reference == NULL) {
if (us_reference == nullptr) {
CLOG_ERROR(&LOG, "could not find a valid initial active target step as reference");
return false;
}
@ -742,10 +745,10 @@ bool BKE_undosys_step_load_data_ex(UndoStack *ustack,
* the one passed as parameter. */
UndoStep *us_target_active = us_target;
if (use_skip) {
while (us_target_active != NULL && us_target_active->skip) {
while (us_target_active != nullptr && us_target_active->skip) {
us_target_active = (undo_dir == -1) ? us_target_active->prev : us_target_active->next;
}
if (us_target_active == NULL) {
if (us_target_active == nullptr) {
CLOG_INFO(&LOG,
2,
"undo/redo did not find a step after stepping over skip-steps "
@ -765,9 +768,9 @@ bool BKE_undosys_step_load_data_ex(UndoStack *ustack,
/* Undo/Redo steps until we reach given target step (or beyond if it has to be skipped),
* from given reference step. */
bool is_processing_extra_skipped_steps = false;
for (UndoStep *us_iter = undosys_step_iter_first(us_reference, undo_dir); us_iter != NULL;
for (UndoStep *us_iter = undosys_step_iter_first(us_reference, undo_dir); us_iter != nullptr;
us_iter = (undo_dir == -1) ? us_iter->prev : us_iter->next) {
BLI_assert(us_iter != NULL);
BLI_assert(us_iter != nullptr);
const bool is_final = (us_iter == us_target_active);
@ -802,12 +805,12 @@ bool BKE_undosys_step_load_data_ex(UndoStack *ustack,
bool BKE_undosys_step_load_data(UndoStack *ustack, bContext *C, UndoStep *us_target)
{
/* Note that here we do not skip 'skipped' steps by default. */
return BKE_undosys_step_load_data_ex(ustack, C, us_target, NULL, false);
return BKE_undosys_step_load_data_ex(ustack, C, us_target, nullptr, false);
}
void BKE_undosys_step_load_from_index(UndoStack *ustack, bContext *C, const int index)
{
UndoStep *us_target = BLI_findlink(&ustack->steps, index);
UndoStep *us_target = static_cast<UndoStep *>(BLI_findlink(&ustack->steps, index));
BLI_assert(us_target->skip == false);
if (us_target == ustack->step_active) {
return;
@ -823,7 +826,7 @@ bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack,
/* In case there is no active step, we consider we just load given step, so reference must be
* itself (due to weird 'load current active step in undo case' thing, see comments in
* #BKE_undosys_step_load_data_ex). */
UndoStep *us_reference = ustack->step_active != NULL ? ustack->step_active : us_target;
UndoStep *us_reference = ustack->step_active != nullptr ? ustack->step_active : us_target;
BLI_assert(BKE_undosys_step_calc_direction(ustack, us_target, us_reference) == -1);
@ -837,7 +840,7 @@ bool BKE_undosys_step_undo_with_data(UndoStack *ustack, bContext *C, UndoStep *u
bool BKE_undosys_step_undo(UndoStack *ustack, bContext *C)
{
if (ustack->step_active != NULL) {
if (ustack->step_active != nullptr) {
return BKE_undosys_step_undo_with_data(ustack, C, ustack->step_active->prev);
}
return false;
@ -850,7 +853,7 @@ bool BKE_undosys_step_redo_with_data_ex(UndoStack *ustack,
{
/* In case there is no active step, we consider we just load given step, so reference must be
* the previous one. */
UndoStep *us_reference = ustack->step_active != NULL ? ustack->step_active : us_target->prev;
UndoStep *us_reference = ustack->step_active != nullptr ? ustack->step_active : us_target->prev;
BLI_assert(BKE_undosys_step_calc_direction(ustack, us_target, us_reference) == 1);
@ -864,7 +867,7 @@ bool BKE_undosys_step_redo_with_data(UndoStack *ustack, bContext *C, UndoStep *u
bool BKE_undosys_step_redo(UndoStack *ustack, bContext *C)
{
if (ustack->step_active != NULL) {
if (ustack->step_active != nullptr) {
return BKE_undosys_step_redo_with_data(ustack, C, ustack->step_active->next);
}
return false;
@ -872,9 +875,7 @@ bool BKE_undosys_step_redo(UndoStack *ustack, bContext *C)
UndoType *BKE_undosys_type_append(void (*undosys_fn)(UndoType *))
{
UndoType *ut;
ut = MEM_callocN(sizeof(UndoType), __func__);
UndoType *ut = MEM_cnew<UndoType>(__func__);
undosys_fn(ut);
@ -886,7 +887,7 @@ UndoType *BKE_undosys_type_append(void (*undosys_fn)(UndoType *))
void BKE_undosys_type_free_all(void)
{
UndoType *ut;
while ((ut = BLI_pophead(&g_undo_types))) {
while ((ut = static_cast<UndoType *>(BLI_pophead(&g_undo_types)))) {
MEM_freeN(ut);
}
}
@ -924,7 +925,7 @@ void BKE_undosys_stack_group_end(UndoStack *ustack)
BLI_assert(ustack->group_level >= 0);
if (ustack->group_level == 0) {
if (LIKELY(ustack->step_active != NULL)) {
if (LIKELY(ustack->step_active != nullptr)) {
ustack->step_active->skip = false;
}
}
@ -944,7 +945,7 @@ static void UNUSED_FUNCTION(BKE_undosys_foreach_ID_ref(UndoStack *ustack,
{
LISTBASE_FOREACH (UndoStep *, us, &ustack->steps) {
const UndoType *ut = us->type;
if (ut->step_foreach_ID_ref != NULL) {
if (ut->step_foreach_ID_ref != nullptr) {
ut->step_foreach_ID_ref(us, foreach_ID_ref_fn, user_data);
}
}

View File

@ -1474,7 +1474,9 @@ void BKE_volume_grid_transform_matrix(const VolumeGrid *volume_grid, float mat[4
#endif
}
void BKE_volume_grid_transform_matrix_set(struct VolumeGrid *volume_grid, const float mat[4][4])
void BKE_volume_grid_transform_matrix_set(const Volume *volume,
VolumeGrid *volume_grid,
const float mat[4][4])
{
#ifdef WITH_OPENVDB
openvdb::math::Mat4f mat_openvdb;
@ -1483,7 +1485,7 @@ void BKE_volume_grid_transform_matrix_set(struct VolumeGrid *volume_grid, const
mat_openvdb(col, row) = mat[col][row];
}
}
openvdb::GridBase::Ptr grid = volume_grid->grid();
openvdb::GridBase::Ptr grid = BKE_volume_grid_openvdb_for_write(volume, volume_grid, false);
grid->setTransform(std::make_shared<openvdb::math::Transform>(
std::make_shared<openvdb::math::AffineMap>(mat_openvdb)));
#else

View File

@ -122,6 +122,7 @@ typedef enum eBLOReadSkip {
/** Do not attempt to re-use IDs from old bmain for unchanged ones in case of undo. */
BLO_READ_SKIP_UNDO_OLD_MAIN = (1 << 2),
} eBLOReadSkip;
ENUM_OPERATORS(eBLOReadSkip, BLO_READ_SKIP_UNDO_OLD_MAIN)
#define BLO_READ_SKIP_ALL (BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA)
/**

View File

@ -81,7 +81,7 @@ void BlendfileLoadingBaseTest::TearDownTestCase()
G.main->wm.first = nullptr;
}
/* Copied from WM_exit_ex() in wm_init_exit.c, and cherry-picked those lines that match the
/* Copied from WM_exit_ex() in wm_init_exit.cc, and cherry-picked those lines that match the
* allocation/initialization done in SetUpTestCase(). */
BKE_blender_free();
RNA_exit();

View File

@ -31,7 +31,7 @@ set(SRC
armature_select.c
armature_skinning.c
armature_utils.c
editarmature_undo.c
editarmature_undo.cc
meshlaplacian.cc
pose_edit.c
pose_group.c

View File

@ -60,7 +60,7 @@ static void undoarm_to_editarm(UndoArmature *uarm, bArmature *arm)
arm->act_edbone = ebone->temp.ebone;
}
else {
arm->act_edbone = NULL;
arm->act_edbone = nullptr;
}
ED_armature_ebone_listbase_temp_clear(arm->edbo);
@ -102,12 +102,12 @@ static Object *editarm_object_from_context(bContext *C)
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
if (obedit && obedit->type == OB_ARMATURE) {
bArmature *arm = obedit->data;
if (arm->edbo != NULL) {
bArmature *arm = static_cast<bArmature *>(obedit->data);
if (arm->edbo != nullptr) {
return obedit;
}
}
return NULL;
return nullptr;
}
/** \} */
@ -132,7 +132,7 @@ typedef struct ArmatureUndoStep {
static bool armature_undosys_poll(bContext *C)
{
return editarm_object_from_context(C) != NULL;
return editarm_object_from_context(C) != nullptr;
}
static bool armature_undosys_step_encode(struct bContext *C, struct Main *bmain, UndoStep *us_p)
@ -146,7 +146,8 @@ static bool armature_undosys_step_encode(struct bContext *C, struct Main *bmain,
uint objects_len = 0;
Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len);
us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
us->elems = static_cast<ArmatureUndoStep_Elem *>(
MEM_callocN(sizeof(*us->elems) * objects_len, __func__));
us->elems_len = objects_len;
for (uint i = 0; i < objects_len; i++) {
@ -154,7 +155,7 @@ static bool armature_undosys_step_encode(struct bContext *C, struct Main *bmain,
ArmatureUndoStep_Elem *elem = &us->elems[i];
elem->obedit_ref.ptr = ob;
bArmature *arm = elem->obedit_ref.ptr->data;
bArmature *arm = static_cast<bArmature *>(elem->obedit_ref.ptr->data);
undoarm_from_editarm(&elem->data, arm);
arm->needs_flush_to_id = 1;
us->step.data_size += elem->data.undo_size;
@ -169,8 +170,8 @@ static bool armature_undosys_step_encode(struct bContext *C, struct Main *bmain,
static void armature_undosys_step_decode(struct bContext *C,
struct Main *bmain,
UndoStep *us_p,
const eUndoStepDir UNUSED(dir),
bool UNUSED(is_final))
const eUndoStepDir /*dir*/,
bool /*is_final*/)
{
ArmatureUndoStep *us = (ArmatureUndoStep *)us_p;
@ -182,8 +183,8 @@ static void armature_undosys_step_decode(struct bContext *C,
for (uint i = 0; i < us->elems_len; i++) {
ArmatureUndoStep_Elem *elem = &us->elems[i];
Object *obedit = elem->obedit_ref.ptr;
bArmature *arm = obedit->data;
if (arm->edbo == NULL) {
bArmature *arm = static_cast<bArmature *>(obedit->data);
if (arm->edbo == nullptr) {
/* Should never fail, may not crash but can give odd behavior. */
CLOG_ERROR(&LOG,
"name='%s', failed to enter edit-mode for object '%s', undo state invalid",
@ -205,7 +206,7 @@ static void armature_undosys_step_decode(struct bContext *C,
bmain->is_memfile_undo_flush_needed = true;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, nullptr);
}
static void armature_undosys_step_free(UndoStep *us_p)

View File

@ -28,7 +28,7 @@ set(SRC
editcurve_pen.c
editcurve_query.c
editcurve_select.c
editcurve_undo.c
editcurve_undo.cc
editfont.c
editfont_undo.c

View File

@ -15,6 +15,10 @@ struct Object;
struct ViewContext;
struct wmOperatorType;
#ifdef __cplusplus
extern "C" {
#endif
/* editfont.c */
enum {
@ -129,7 +133,7 @@ void CURVE_OT_cyclic_toggle(struct wmOperatorType *ot);
void CURVE_OT_match_texture_space(struct wmOperatorType *ot);
/* exported for editcurve_undo.c */
/* exported for editcurve_undo.cc */
struct GHash *ED_curve_keyindex_hash_duplicate(struct GHash *keyindex);
void ED_curve_keyindex_update_nurb(struct EditNurb *editnurb, struct Nurb *nu, struct Nurb *newnu);
@ -227,3 +231,7 @@ void CURVE_OT_draw(struct wmOperatorType *ot);
void CURVE_OT_pen(struct wmOperatorType *ot);
struct wmKeyMap *curve_pen_modal_keymap(struct wmKeyConfig *keyconf);
#ifdef __cplusplus
}
#endif

View File

@ -84,7 +84,7 @@ static void undocurve_to_editcurve(Main *bmain, UndoCurve *ucu, Curve *cu, short
}
/* Copy. */
for (nu = undobase->first; nu; nu = nu->next) {
for (nu = static_cast<Nurb *>(undobase->first); nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
if (editnurb->keyindex) {
@ -126,7 +126,7 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
}
/* Copy. */
for (nu = nubase->first; nu; nu = nu->next) {
for (nu = static_cast<Nurb *>(nubase->first); nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
if (ucu->undoIndex) {
@ -165,12 +165,12 @@ static Object *editcurve_object_from_context(bContext *C)
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
if (obedit && ELEM(obedit->type, OB_CURVES_LEGACY, OB_SURF)) {
Curve *cu = obedit->data;
if (BKE_curve_editNurbs_get(cu) != NULL) {
Curve *cu = static_cast<Curve *>(obedit->data);
if (BKE_curve_editNurbs_get(cu) != nullptr) {
return obedit;
}
}
return NULL;
return nullptr;
}
/** \} */
@ -195,7 +195,7 @@ typedef struct CurveUndoStep {
static bool curve_undosys_poll(bContext *C)
{
Object *obedit = editcurve_object_from_context(C);
return (obedit != NULL);
return (obedit != nullptr);
}
static bool curve_undosys_step_encode(struct bContext *C, struct Main *bmain, UndoStep *us_p)
@ -209,16 +209,17 @@ static bool curve_undosys_step_encode(struct bContext *C, struct Main *bmain, Un
uint objects_len = 0;
Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len);
us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
us->elems = static_cast<CurveUndoStep_Elem *>(
MEM_callocN(sizeof(*us->elems) * objects_len, __func__));
us->elems_len = objects_len;
for (uint i = 0; i < objects_len; i++) {
Object *ob = objects[i];
Curve *cu = ob->data;
Curve *cu = static_cast<Curve *>(ob->data);
CurveUndoStep_Elem *elem = &us->elems[i];
elem->obedit_ref.ptr = ob;
undocurve_from_editcurve(&elem->data, ob->data, ob->shapenr);
undocurve_from_editcurve(&elem->data, static_cast<Curve *>(ob->data), ob->shapenr);
cu->editnurb->needs_flush_to_id = 1;
us->step.data_size += elem->data.undo_size;
}
@ -232,8 +233,8 @@ static bool curve_undosys_step_encode(struct bContext *C, struct Main *bmain, Un
static void curve_undosys_step_decode(struct bContext *C,
struct Main *bmain,
UndoStep *us_p,
const eUndoStepDir UNUSED(dir),
bool UNUSED(is_final))
const eUndoStepDir /*dir*/,
bool /*is_final*/)
{
CurveUndoStep *us = (CurveUndoStep *)us_p;
@ -245,8 +246,8 @@ static void curve_undosys_step_decode(struct bContext *C,
for (uint i = 0; i < us->elems_len; i++) {
CurveUndoStep_Elem *elem = &us->elems[i];
Object *obedit = elem->obedit_ref.ptr;
Curve *cu = obedit->data;
if (cu->editnurb == NULL) {
Curve *cu = static_cast<Curve *>(obedit->data);
if (cu->editnurb == nullptr) {
/* Should never fail, may not crash but can give odd behavior. */
CLOG_ERROR(&LOG,
"name='%s', failed to enter edit-mode for object '%s', undo state invalid",
@ -254,7 +255,8 @@ static void curve_undosys_step_decode(struct bContext *C,
obedit->id.name);
continue;
}
undocurve_to_editcurve(bmain, &elem->data, obedit->data, &obedit->shapenr);
undocurve_to_editcurve(
bmain, &elem->data, static_cast<Curve *>(obedit->data), &obedit->shapenr);
cu->editnurb->needs_flush_to_id = 1;
DEG_id_tag_update(&cu->id, ID_RECALC_GEOMETRY);
}
@ -268,7 +270,7 @@ static void curve_undosys_step_decode(struct bContext *C,
bmain->is_memfile_undo_flush_needed = true;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, nullptr);
}
static void curve_undosys_step_free(UndoStep *us_p)

View File

@ -46,7 +46,7 @@ set(SRC
gpencil_primitive.c
gpencil_sculpt_paint.c
gpencil_select.c
gpencil_undo.c
gpencil_undo.cc
gpencil_utils.c
gpencil_uv.c
gpencil_vertex_ops.c

View File

@ -38,8 +38,8 @@ typedef struct bGPundonode {
struct bGPdata *gpd;
} bGPundonode;
static ListBase undo_nodes = {NULL, NULL};
static bGPundonode *cur_node = NULL;
static ListBase undo_nodes = {nullptr, nullptr};
static bGPundonode *cur_node = nullptr;
int ED_gpencil_session_active(void)
{
@ -48,9 +48,9 @@ int ED_gpencil_session_active(void)
int ED_undo_gpencil_step(bContext *C, const int step)
{
bGPdata **gpd_ptr = NULL, *new_gpd = NULL;
bGPdata **gpd_ptr = nullptr, *new_gpd = nullptr;
gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
gpd_ptr = ED_gpencil_data_get_pointers(C, nullptr);
const eUndoStepDir undo_step = (eUndoStepDir)step;
if (undo_step == STEP_UNDO) {
@ -89,7 +89,7 @@ int ED_undo_gpencil_step(bContext *C, const int step)
new_gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
}
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@ -104,7 +104,7 @@ static void gpencil_undo_free_node(bGPundonode *undo_node)
/* HACK: animdata wasn't duplicated, so it shouldn't be freed here,
* or else the real copy will segfault when accessed
*/
undo_node->gpd->adt = NULL;
undo_node->gpd->adt = nullptr;
BKE_gpencil_free_data(undo_node->gpd, false);
MEM_freeN(undo_node->gpd);
@ -138,7 +138,7 @@ void gpencil_undo_push(bGPdata *gpd)
/* remove anything older than n-steps before cur_node */
int steps = 0;
undo_node = (cur_node) ? cur_node : undo_nodes.last;
undo_node = (cur_node) ? cur_node : static_cast<bGPundonode *>(undo_nodes.last);
while (undo_node) {
bGPundonode *prev_node = undo_node->prev;
@ -153,8 +153,8 @@ void gpencil_undo_push(bGPdata *gpd)
}
/* create new undo node */
undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node");
undo_node->gpd = BKE_gpencil_data_duplicate(NULL, gpd, true);
undo_node = MEM_cnew<bGPundonode>("gpencil undo node");
undo_node->gpd = BKE_gpencil_data_duplicate(nullptr, gpd, true);
cur_node = undo_node;
@ -163,7 +163,7 @@ void gpencil_undo_push(bGPdata *gpd)
void gpencil_undo_finish(void)
{
bGPundonode *undo_node = undo_nodes.first;
bGPundonode *undo_node = static_cast<bGPundonode *>(undo_nodes.first);
while (undo_node) {
gpencil_undo_free_node(undo_node);
@ -172,5 +172,5 @@ void gpencil_undo_finish(void)
BLI_freelistN(&undo_nodes);
cur_node = NULL;
cur_node = nullptr;
}

View File

@ -205,7 +205,7 @@ void ED_object_vgroup_calc_from_armature(struct ReportList *reports,
int mode,
bool mirror);
/* editarmature_undo.c */
/* editarmature_undo.cc */
/** Export for ED_undo_sys. */
void ED_armature_undosys_type(struct UndoType *ut);

View File

@ -81,7 +81,7 @@ bool ED_curve_select_all(struct EditNurb *editnurb);
bool ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles);
int ED_curve_select_count(const struct View3D *v3d, const struct EditNurb *editnurb);
/* editcurve_undo.c */
/* editcurve_undo.cc */
/** Export for ED_undo_sys */
void ED_curve_undosys_type(struct UndoType *ut);

View File

@ -37,7 +37,7 @@ void ED_sculpt_init_transform(struct bContext *C,
const char *undo_name);
void ED_sculpt_end_transform(struct bContext *C, struct Object *ob);
/* sculpt_undo.c */
/* sculpt_undo.cc */
/** Export for ED_undo_sys. */
void ED_sculpt_undosys_type(struct UndoType *ut);

View File

@ -33,7 +33,7 @@ bool ED_text_region_location_from_cursor(struct SpaceText *st,
const int cursor_co[2],
int r_pixel_co[2]);
/* text_undo.c */
/* text_undo.cc */
/** Export for ED_undo_sys. */
void ED_text_undosys_type(struct UndoType *ut);

View File

@ -82,7 +82,7 @@ set(SRC
sculpt_pose.c
sculpt_smooth.c
sculpt_transform.c
sculpt_undo.c
sculpt_undo.cc
sculpt_uv.c
curves_sculpt_intern.h

View File

@ -300,7 +300,7 @@ struct PartialUpdateData {
*/
static void update_cb_partial(PBVHNode *node, void *userdata)
{
struct PartialUpdateData *data = userdata;
PartialUpdateData *data = static_cast<PartialUpdateData *>(userdata);
if (BKE_pbvh_type(data->pbvh) == PBVH_GRIDS) {
int *node_grid_indices;
int totgrid;
@ -637,10 +637,11 @@ static bool sculpt_undo_restore_face_sets(bContext *C,
return modified;
}
static void sculpt_undo_bmesh_restore_generic_task_cb(
void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
static void sculpt_undo_bmesh_restore_generic_task_cb(void *__restrict userdata,
const int n,
const TaskParallelTLS *__restrict /*tls*/)
{
PBVHNode **nodes = userdata;
PBVHNode **nodes = static_cast<PBVHNode **>(userdata);
BKE_pbvh_node_mark_redraw(nodes[n]);
}
@ -680,15 +681,15 @@ static void sculpt_undo_bmesh_restore_generic(SculptUndoNode *unode, Object *ob,
static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
{
SculptSession *ss = ob->sculpt;
Mesh *me = ob->data;
Mesh *me = static_cast<Mesh *>(ob->data);
SCULPT_pbvh_clear(ob);
/* Create empty BMesh and enable logging. */
ss->bm = BM_mesh_create(&bm_mesh_allocsize_default,
&((struct BMeshCreateParams){
.use_toolflags = false,
}));
BMeshCreateParams bmesh_create_params{};
bmesh_create_params.use_toolflags = false;
ss->bm = BM_mesh_create(&bm_mesh_allocsize_default, &bmesh_create_params);
BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK);
me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
@ -738,7 +739,7 @@ static void sculpt_undo_bmesh_restore_end(bContext *C,
static void sculpt_undo_geometry_store_data(SculptUndoNodeGeometry *geometry, Object *object)
{
Mesh *mesh = object->data;
Mesh *mesh = static_cast<Mesh *>(object->data);
BLI_assert(!geometry->is_initialized);
geometry->is_initialized = true;
@ -756,7 +757,7 @@ static void sculpt_undo_geometry_store_data(SculptUndoNodeGeometry *geometry, Ob
static void sculpt_undo_geometry_restore_data(SculptUndoNodeGeometry *geometry, Object *object)
{
Mesh *mesh = object->data;
Mesh *mesh = static_cast<Mesh *>(object->data);
BLI_assert(geometry->is_initialized);
@ -861,7 +862,8 @@ static void sculpt_undo_refine_subdiv(Depsgraph *depsgraph,
float(*deformed_verts)[3] = BKE_multires_create_deformed_base_mesh_vert_coords(
depsgraph, object, ss->multires.modifier, NULL);
BKE_subdiv_eval_refine_from_mesh(subdiv, object->data, deformed_verts);
BKE_subdiv_eval_refine_from_mesh(
subdiv, static_cast<const Mesh *>(object->data), deformed_verts);
MEM_freeN(deformed_verts);
}
@ -882,7 +884,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
bool need_refine_subdiv = false;
bool clear_automask_cache = false;
for (unode = lb->first; unode; unode = unode->next) {
for (unode = static_cast<SculptUndoNode *>(lb->first); unode; unode = unode->next) {
if (!ELEM(unode->type, SCULPT_UNDO_COLOR, SCULPT_UNDO_MASK)) {
clear_automask_cache = true;
}
@ -915,7 +917,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask, false);
}
if (sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) {
if (sculpt_undo_bmesh_restore(C, static_cast<SculptUndoNode *>(lb->first), ob, ss)) {
return;
}
}
@ -930,7 +932,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
char *undo_modified_grids = NULL;
bool use_multires_undo = false;
for (unode = lb->first; unode; unode = unode->next) {
for (unode = static_cast<SculptUndoNode *>(lb->first); unode; unode = unode->next) {
if (!STREQ(unode->idname, ob->id.name)) {
continue;
@ -960,7 +962,8 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
break;
case SCULPT_UNDO_HIDDEN:
if (modified_hidden_verts == NULL) {
modified_hidden_verts = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
modified_hidden_verts = static_cast<bool *>(
MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__));
}
if (sculpt_undo_restore_hidden(C, unode, modified_hidden_verts)) {
rebuild = true;
@ -969,7 +972,8 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
break;
case SCULPT_UNDO_MASK:
if (modified_mask_verts == NULL) {
modified_mask_verts = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
modified_mask_verts = static_cast<bool *>(
MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__));
}
if (sculpt_undo_restore_mask(C, unode, modified_mask_verts)) {
update = true;
@ -978,8 +982,8 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
break;
case SCULPT_UNDO_FACE_SETS:
if (modified_face_set_faces == NULL) {
modified_face_set_faces = MEM_calloc_arrayN(
BKE_pbvh_num_faces(ss->pbvh), sizeof(bool), __func__);
modified_face_set_faces = static_cast<bool *>(
MEM_calloc_arrayN(BKE_pbvh_num_faces(ss->pbvh), sizeof(bool), __func__));
}
if (sculpt_undo_restore_face_sets(C, unode, modified_face_set_faces)) {
update = true;
@ -988,7 +992,8 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
break;
case SCULPT_UNDO_COLOR:
if (modified_color_verts == NULL) {
modified_color_verts = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
modified_color_verts = static_cast<bool *>(
MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__));
}
if (sculpt_undo_restore_color(C, unode, modified_color_verts)) {
update = true;
@ -1010,7 +1015,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
}
if (use_multires_undo) {
for (unode = lb->first; unode; unode = unode->next) {
for (unode = static_cast<SculptUndoNode *>(lb->first); unode; unode = unode->next) {
if (!STREQ(unode->idname, ob->id.name)) {
continue;
}
@ -1019,7 +1024,8 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
}
if (undo_modified_grids == NULL) {
undo_modified_grids = MEM_callocN(sizeof(char) * unode->maxgrid, "undo_grids");
undo_modified_grids = static_cast<char *>(
MEM_callocN(sizeof(char) * unode->maxgrid, "undo_grids"));
}
for (int i = 0; i < unode->totgrid; i++) {
@ -1037,15 +1043,14 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
/* We update all nodes still, should be more clever, but also
* needs to work correct when exiting/entering sculpt mode and
* the nodes get recreated, though in that case it could do all. */
struct PartialUpdateData data = {
.rebuild = rebuild,
.pbvh = ss->pbvh,
.modified_grids = undo_modified_grids,
.modified_hidden_verts = modified_hidden_verts,
.modified_mask_verts = modified_mask_verts,
.modified_color_verts = modified_color_verts,
.modified_face_set_faces = modified_face_set_faces,
};
PartialUpdateData data{};
data.rebuild = rebuild;
data.pbvh = ss->pbvh;
data.modified_grids = undo_modified_grids;
data.modified_hidden_verts = modified_hidden_verts;
data.modified_mask_verts = modified_mask_verts;
data.modified_color_verts = modified_color_verts;
data.modified_face_set_faces = modified_face_set_faces;
BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb_partial, &data);
BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw);
@ -1081,7 +1086,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
ss->shapekey_active || ss->deform_modifiers_active;
if (tag_update) {
Mesh *mesh = ob->data;
Mesh *mesh = static_cast<Mesh *>(ob->data);
BKE_mesh_tag_coords_changed(mesh);
BKE_sculptsession_free_deformMats(ss);
@ -1104,7 +1109,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
static void sculpt_undo_free_list(ListBase *lb)
{
SculptUndoNode *unode = lb->first;
SculptUndoNode *unode = static_cast<SculptUndoNode *>(lb->first);
while (unode != NULL) {
SculptUndoNode *unode_next = unode->next;
if (unode->co) {
@ -1215,23 +1220,24 @@ SculptUndoNode *SCULPT_undo_get_first_node()
return NULL;
}
return usculpt->nodes.first;
return static_cast<SculptUndoNode *>(usculpt->nodes.first);
}
static size_t sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, SculptUndoNode *unode)
{
PBVHNode *node = unode->node;
PBVHNode *node = static_cast<PBVHNode *>(unode->node);
BLI_bitmap **grid_hidden = BKE_pbvh_grid_hidden(pbvh);
int *grid_indices, totgrid;
BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, NULL, NULL, NULL);
size_t alloc_size = sizeof(*unode->grid_hidden) * (size_t)totgrid;
unode->grid_hidden = MEM_callocN(alloc_size, "unode->grid_hidden");
unode->grid_hidden = static_cast<BLI_bitmap **>(MEM_callocN(alloc_size, "unode->grid_hidden"));
for (int i = 0; i < totgrid; i++) {
if (grid_hidden[grid_indices[i]]) {
unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]);
unode->grid_hidden[i] = static_cast<BLI_bitmap *>(
MEM_dupallocN(grid_hidden[grid_indices[i]]));
alloc_size += MEM_allocN_len(unode->grid_hidden[i]);
}
else {
@ -1247,7 +1253,7 @@ static size_t sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, SculptUndoNode *uno
static SculptUndoNode *sculpt_undo_alloc_node_type(Object *object, SculptUndoType type)
{
const size_t alloc_size = sizeof(SculptUndoNode);
SculptUndoNode *unode = MEM_callocN(alloc_size, "SculptUndoNode");
SculptUndoNode *unode = static_cast<SculptUndoNode *>(MEM_callocN(alloc_size, "SculptUndoNode"));
BLI_strncpy(unode->idname, object->id.name, sizeof(unode->idname));
unode->type = type;
@ -1279,13 +1285,14 @@ static void sculpt_undo_store_faces(SculptSession *ss, SculptUndoNode *unode)
unode->faces_num = 0;
PBVHFaceIter fd;
BKE_pbvh_face_iter_begin (ss->pbvh, unode->node, fd) {
BKE_pbvh_face_iter_begin (ss->pbvh, static_cast<PBVHNode *>(unode->node), fd) {
unode->faces_num++;
}
BKE_pbvh_face_iter_end(fd);
unode->faces = MEM_malloc_arrayN(sizeof(*unode->faces), unode->faces_num, __func__);
BKE_pbvh_face_iter_begin (ss->pbvh, unode->node, fd) {
unode->faces = static_cast<PBVHFaceRef *>(
MEM_malloc_arrayN(sizeof(*unode->faces), unode->faces_num, __func__));
BKE_pbvh_face_iter_begin (ss->pbvh, static_cast<PBVHNode *>(unode->node), fd) {
unode->faces[fd.i] = fd.face;
}
BKE_pbvh_face_iter_end(fd);
@ -1320,7 +1327,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
BKE_pbvh_node_num_loops(ss->pbvh, node, &totloop);
unode->loop_index = MEM_calloc_arrayN(totloop, sizeof(int), __func__);
unode->loop_index = static_cast<int *>(MEM_calloc_arrayN(totloop, sizeof(int), __func__));
unode->maxloop = 0;
unode->totloop = totloop;
@ -1337,12 +1344,12 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
switch (type) {
case SCULPT_UNDO_COORDS: {
size_t alloc_size = sizeof(*unode->co) * (size_t)allvert;
unode->co = MEM_callocN(alloc_size, "SculptUndoNode.co");
unode->co = static_cast<float(*)[3]>(MEM_callocN(alloc_size, "SculptUndoNode.co"));
usculpt->undo_size += alloc_size;
/* Needed for original data lookup. */
alloc_size = sizeof(*unode->no) * (size_t)allvert;
unode->no = MEM_callocN(alloc_size, "SculptUndoNode.no");
unode->no = static_cast<float(*)[3]>(MEM_callocN(alloc_size, "SculptUndoNode.no"));
usculpt->undo_size += alloc_size;
break;
}
@ -1359,7 +1366,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
}
case SCULPT_UNDO_MASK: {
const size_t alloc_size = sizeof(*unode->mask) * (size_t)allvert;
unode->mask = MEM_callocN(alloc_size, "SculptUndoNode.mask");
unode->mask = static_cast<float *>(MEM_callocN(alloc_size, "SculptUndoNode.mask"));
usculpt->undo_size += alloc_size;
break;
}
@ -1367,15 +1374,15 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
/* Allocate vertex colors, even for loop colors we still
* need this for original data lookup. */
const size_t alloc_size = sizeof(*unode->col) * (size_t)allvert;
unode->col = MEM_callocN(alloc_size, "SculptUndoNode.col");
unode->col = static_cast<float(*)[4]>(MEM_callocN(alloc_size, "SculptUndoNode.col"));
usculpt->undo_size += alloc_size;
/* Allocate loop colors separately too. */
if (ss->vcol_domain == ATTR_DOMAIN_CORNER) {
size_t alloc_size_loop = sizeof(float) * 4 * (size_t)unode->totloop;
unode->loop_col = MEM_calloc_arrayN(
unode->totloop, sizeof(float) * 4, "SculptUndoNode.loop_col");
unode->loop_col = static_cast<float(*)[4]>(
MEM_calloc_arrayN(unode->totloop, sizeof(float) * 4, "SculptUndoNode.loop_col"));
usculpt->undo_size += alloc_size_loop;
}
break;
@ -1401,7 +1408,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
unode->gridsize = gridsize;
const size_t alloc_size = sizeof(*unode->grids) * (size_t)totgrid;
unode->grids = MEM_callocN(alloc_size, "SculptUndoNode.grids");
unode->grids = static_cast<int *>(MEM_callocN(alloc_size, "SculptUndoNode.grids"));
usculpt->undo_size += alloc_size;
}
else {
@ -1409,13 +1416,13 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
unode->maxvert = ss->totvert;
const size_t alloc_size = sizeof(*unode->index) * (size_t)allvert;
unode->index = MEM_callocN(alloc_size, "SculptUndoNode.index");
unode->index = static_cast<int *>(MEM_callocN(alloc_size, "SculptUndoNode.index"));
usculpt->undo_size += alloc_size;
}
if (ss->deform_modifiers_active) {
const size_t alloc_size = sizeof(*unode->orig_co) * (size_t)allvert;
unode->orig_co = MEM_callocN(alloc_size, "undoSculpt orig_cos");
unode->orig_co = static_cast<float(*)[3]>(MEM_callocN(alloc_size, "undoSculpt orig_cos"));
usculpt->undo_size += alloc_size;
}
@ -1427,7 +1434,7 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
SculptSession *ss = ob->sculpt;
PBVHVertexIter vd;
BKE_pbvh_vertex_iter_begin (ss->pbvh, unode->node, vd, PBVH_ITER_ALL) {
BKE_pbvh_vertex_iter_begin (ss->pbvh, static_cast<PBVHNode *>(unode->node), vd, PBVH_ITER_ALL) {
copy_v3_v3(unode->co[vd.i], vd.co);
if (vd.no) {
copy_v3_v3(unode->no[vd.i], vd.no);
@ -1446,7 +1453,7 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
{
PBVH *pbvh = ob->sculpt->pbvh;
PBVHNode *node = unode->node;
PBVHNode *node = static_cast<PBVHNode *>(unode->node);
const bool *hide_vert = BKE_pbvh_get_vert_hide(pbvh);
if (hide_vert == NULL) {
@ -1472,7 +1479,7 @@ static void sculpt_undo_store_mask(Object *ob, SculptUndoNode *unode)
SculptSession *ss = ob->sculpt;
PBVHVertexIter vd;
BKE_pbvh_vertex_iter_begin (ss->pbvh, unode->node, vd, PBVH_ITER_ALL) {
BKE_pbvh_vertex_iter_begin (ss->pbvh, static_cast<PBVHNode *>(unode->node), vd, PBVH_ITER_ALL) {
unode->mask[vd.i] = *vd.mask;
}
BKE_pbvh_vertex_iter_end;
@ -1485,7 +1492,7 @@ static void sculpt_undo_store_color(Object *ob, SculptUndoNode *unode)
BLI_assert(BKE_pbvh_type(ss->pbvh) == PBVH_FACES);
int allvert;
BKE_pbvh_node_num_verts(ss->pbvh, unode->node, NULL, &allvert);
BKE_pbvh_node_num_verts(ss->pbvh, static_cast<PBVHNode *>(unode->node), NULL, &allvert);
/* NOTE: even with loop colors we still store (derived)
* vertex colors for original data lookup. */
@ -1521,10 +1528,11 @@ static SculptUndoNode *sculpt_undo_geometry_push(Object *object, SculptUndoType
static void sculpt_undo_store_face_sets(SculptSession *ss, SculptUndoNode *unode)
{
unode->face_sets = MEM_malloc_arrayN(sizeof(*unode->face_sets), unode->faces_num, __func__);
unode->face_sets = static_cast<int *>(
MEM_malloc_arrayN(sizeof(*unode->face_sets), unode->faces_num, __func__));
PBVHFaceIter fd;
BKE_pbvh_face_iter_begin (ss->pbvh, unode->node, fd) {
BKE_pbvh_face_iter_begin (ss->pbvh, static_cast<PBVHNode *>(unode->node), fd) {
unode->face_sets[fd.i] = fd.face_set ? *fd.face_set : SCULPT_FACE_SET_NONE;
}
BKE_pbvh_face_iter_end(fd);
@ -1536,10 +1544,10 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt
SculptSession *ss = ob->sculpt;
PBVHVertexIter vd;
SculptUndoNode *unode = usculpt->nodes.first;
SculptUndoNode *unode = static_cast<SculptUndoNode *>(usculpt->nodes.first);
if (unode == NULL) {
unode = MEM_callocN(sizeof(*unode), __func__);
unode = MEM_cnew<SculptUndoNode>(__func__);
BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname));
unode->type = type;
@ -1589,7 +1597,7 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt
BKE_pbvh_vertex_iter_end;
GSET_ITER (gs_iter, faces) {
BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
BMFace *f = static_cast<BMFace *>(BLI_gsetIterator_getKey(&gs_iter));
BM_log_face_modified(ss->bm_log, f);
}
break;
@ -1651,13 +1659,13 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
const int *loop_indices;
int allvert, allloop;
BKE_pbvh_node_num_verts(ss->pbvh, unode->node, NULL, &allvert);
BKE_pbvh_node_num_verts(ss->pbvh, static_cast<PBVHNode *>(unode->node), NULL, &allvert);
const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
memcpy(unode->index, vert_indices, sizeof(int) * allvert);
if (unode->loop_index) {
BKE_pbvh_node_num_loops(ss->pbvh, unode->node, &allloop);
BKE_pbvh_node_get_loops(ss->pbvh, unode->node, &loop_indices, NULL);
BKE_pbvh_node_num_loops(ss->pbvh, static_cast<PBVHNode *>(unode->node), &allloop);
BKE_pbvh_node_get_loops(ss->pbvh, static_cast<PBVHNode *>(unode->node), &loop_indices, NULL);
if (allloop) {
memcpy(unode->loop_index, loop_indices, sizeof(int) * allloop);
@ -1746,7 +1754,7 @@ void SCULPT_undo_push_begin_ex(Object *ob, const char *name)
/* If possible, we need to tag the object and its geometry data as 'changed in the future' in
* the previous undo step if it's a memfile one. */
ED_undosys_stack_memfile_id_changed_tag(ustack, &ob->id);
ED_undosys_stack_memfile_id_changed_tag(ustack, ob->data);
ED_undosys_stack_memfile_id_changed_tag(ustack, static_cast<ID *>(ob->data));
}
/* Special case, we never read from this. */
@ -1779,7 +1787,7 @@ void SCULPT_undo_push_end_ex(struct Object *ob, const bool use_nested_undo)
SculptUndoNode *unode;
/* We don't need normals in the undo stack. */
for (unode = usculpt->nodes.first; unode; unode = unode->next) {
for (unode = static_cast<SculptUndoNode *>(usculpt->nodes.first); unode; unode = unode->next) {
if (unode->no) {
usculpt->undo_size -= MEM_allocN_len(unode->no);
MEM_freeN(unode->no);
@ -1788,7 +1796,7 @@ void SCULPT_undo_push_end_ex(struct Object *ob, const bool use_nested_undo)
}
/* We could remove this and enforce all callers run in an operator using 'OPTYPE_UNDO'. */
wmWindowManager *wm = G_MAIN->wm.first;
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
if (wm->op_undo_depth == 0 || use_nested_undo) {
UndoStack *ustack = ED_undo_stack_get();
BKE_undosys_step_push(ustack, NULL, NULL);
@ -1836,7 +1844,8 @@ static void sculpt_undo_set_active_layer(struct bContext *C, SculptAttrRef *attr
if (!layer) {
layer = BKE_id_attribute_search(&me->id, attr->name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
if (layer) {
if (ED_geometry_attribute_convert(me, attr->name, attr->type, attr->domain, NULL)) {
if (ED_geometry_attribute_convert(
me, attr->name, eCustomDataType(attr->type), attr->domain, NULL)) {
layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
}
}
@ -1864,23 +1873,21 @@ static void sculpt_undo_set_active_layer(struct bContext *C, SculptAttrRef *attr
}
}
static void sculpt_undosys_step_encode_init(struct bContext *UNUSED(C), UndoStep *us_p)
static void sculpt_undosys_step_encode_init(struct bContext * /*C*/, UndoStep *us_p)
{
SculptUndoStep *us = (SculptUndoStep *)us_p;
/* Dummy, memory is cleared anyway. */
BLI_listbase_clear(&us->data.nodes);
}
static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C),
struct Main *bmain,
UndoStep *us_p)
static bool sculpt_undosys_step_encode(struct bContext * /*C*/, struct Main *bmain, UndoStep *us_p)
{
/* Dummy, encoding is done along the way by adding tiles
* to the current 'SculptUndoStep' added by encode_init. */
SculptUndoStep *us = (SculptUndoStep *)us_p;
us->step.data_size = us->data.undo_size;
SculptUndoNode *unode = us->data.nodes.last;
SculptUndoNode *unode = static_cast<SculptUndoNode *>(us->data.nodes.last);
if (unode && unode->type == SCULPT_UNDO_DYNTOPO_END) {
us->step.use_memfile_step = true;
}
@ -1998,7 +2005,7 @@ static void sculpt_undosys_step_decode(
* (some) evaluated data. */
BKE_scene_graph_evaluated_ensure(depsgraph, bmain);
Mesh *me = ob->data;
Mesh *me = static_cast<Mesh *>(ob->data);
/* Don't add sculpt topology undo steps when reading back undo state.
* The undo steps must enter/exit for us. */
me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY;

View File

@ -32,7 +32,7 @@ set(SRC
text_format_py.c
text_header.c
text_ops.c
text_undo.c
text_undo.cc
text_format.h
text_intern.h

View File

@ -17,6 +17,10 @@ struct TextLine;
struct bContext;
struct wmOperatorType;
#ifdef __cplusplus
extern "C" {
#endif
/* text_draw.c */
void draw_text_main(struct SpaceText *st, struct ARegion *region);
@ -176,3 +180,7 @@ void TEXT_OT_autocomplete(struct wmOperatorType *ot);
/* space_text.c */
extern const char *text_context_dir[]; /* doc access */
#ifdef __cplusplus
}
#endif

View File

@ -61,16 +61,17 @@ static void text_state_encode(TextState *state, Text *text, BArrayStore *buffer_
{
size_t buf_len = 0;
uchar *buf = (uchar *)txt_to_buf_for_undo(text, &buf_len);
state->buf_array_state = BLI_array_store_state_add(buffer_store, buf, buf_len, NULL);
state->buf_array_state = BLI_array_store_state_add(buffer_store, buf, buf_len, nullptr);
MEM_freeN(buf);
state->cursor_line = txt_get_span(text->lines.first, text->curl);
state->cursor_line = txt_get_span(static_cast<TextLine *>(text->lines.first), text->curl);
state->cursor_column = text->curc;
if (txt_has_sel(text)) {
state->cursor_line_select = (text->curl == text->sell) ?
state->cursor_line :
txt_get_span(text->lines.first, text->sell);
txt_get_span(static_cast<TextLine *>(text->lines.first),
text->sell);
state->cursor_column_select = text->selc;
}
else {
@ -83,7 +84,8 @@ static void text_state_decode(TextState *state, Text *text)
{
size_t buf_len;
{
const uchar *buf = BLI_array_store_state_data_get_alloc(state->buf_array_state, &buf_len);
const uchar *buf = static_cast<const uchar *>(
BLI_array_store_state_data_get_alloc(state->buf_array_state, &buf_len));
txt_from_buf_for_undo(text, (const char *)buf, buf_len);
MEM_freeN((void *)buf);
}
@ -115,12 +117,12 @@ typedef struct TextUndoStep {
static struct {
BArrayStore *buffer_store;
int users;
} g_text_buffers = {NULL};
} g_text_buffers = {nullptr};
static size_t text_undosys_step_encode_to_state(TextState *state, Text *text)
{
BLI_assert(BLI_array_is_zeroed(state, 1));
if (g_text_buffers.buffer_store == NULL) {
if (g_text_buffers.buffer_store == nullptr) {
g_text_buffers.buffer_store = BLI_array_store_create(1, ARRAY_CHUNK_SIZE);
}
g_text_buffers.users += 1;
@ -132,7 +134,7 @@ static size_t text_undosys_step_encode_to_state(TextState *state, Text *text)
return BLI_array_store_calc_size_compacted_get(g_text_buffers.buffer_store) - total_size_prev;
}
static bool text_undosys_poll(bContext *UNUSED(C))
static bool text_undosys_poll(bContext * /*C*/)
{
/* Only use when operators initialized. */
UndoStack *ustack = ED_undo_stack_get();
@ -165,9 +167,7 @@ static void text_undosys_step_encode_init(struct bContext *C, UndoStep *us_p)
us->text_ref.ptr = text;
}
static bool text_undosys_step_encode(struct bContext *C,
struct Main *UNUSED(bmain),
UndoStep *us_p)
static bool text_undosys_step_encode(struct bContext *C, struct Main * /*bmain*/, UndoStep *us_p)
{
TextUndoStep *us = (TextUndoStep *)us_p;
@ -183,7 +183,7 @@ static bool text_undosys_step_encode(struct bContext *C,
}
static void text_undosys_step_decode(struct bContext *C,
struct Main *UNUSED(bmain),
struct Main * /*bmain*/,
UndoStep *us_p,
const eUndoStepDir dir,
bool is_final)
@ -194,7 +194,7 @@ static void text_undosys_step_decode(struct bContext *C,
Text *text = us->text_ref.ptr;
TextState *state;
if ((us->states[0].buf_array_state != NULL) && (dir == STEP_UNDO) && !is_final) {
if ((us->states[0].buf_array_state != nullptr) && (dir == STEP_UNDO) && !is_final) {
state = &us->states[0];
}
else {
@ -224,7 +224,7 @@ static void text_undosys_step_free(UndoStep *us_p)
g_text_buffers.users -= 1;
if (g_text_buffers.users == 0) {
BLI_array_store_destroy(g_text_buffers.buffer_store);
g_text_buffers.buffer_store = NULL;
g_text_buffers.buffer_store = nullptr;
}
}
}
@ -264,12 +264,13 @@ UndoStep *ED_text_undo_push_init(bContext *C)
{
UndoStack *ustack = ED_undo_stack_get();
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = bmain->wm.first;
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
if (wm->op_undo_depth <= 1) {
UndoStep *us_p = BKE_undosys_step_push_init_with_type(ustack, C, NULL, BKE_UNDOSYS_TYPE_TEXT);
UndoStep *us_p = BKE_undosys_step_push_init_with_type(
ustack, C, nullptr, BKE_UNDOSYS_TYPE_TEXT);
return us_p;
}
return NULL;
return nullptr;
}
/** \} */

View File

@ -2,6 +2,7 @@
set(INC
../include
../../asset_system
../../blenkernel
../../blenlib
../../blenloader
@ -18,11 +19,11 @@ set(INC_SYS
)
set(SRC
ed_undo.c
memfile_undo.c
undo_system_types.c
ed_undo.cc
memfile_undo.cc
undo_system_types.cc
undo_intern.h
undo_intern.hh
)
set(LIB

View File

@ -67,7 +67,7 @@ bool ED_undo_is_state_valid(bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
/* Currently only checks matching begin/end calls. */
if (wm->undo_stack == NULL) {
if (wm->undo_stack == nullptr) {
/* No undo stack is valid, nothing to do. */
return true;
}
@ -75,7 +75,7 @@ bool ED_undo_is_state_valid(bContext *C)
/* If this fails #ED_undo_grouped_begin, #ED_undo_grouped_end calls don't match. */
return false;
}
if (wm->undo_stack->step_active != NULL) {
if (wm->undo_stack->step_active != nullptr) {
if (wm->undo_stack->step_active->skip == true) {
/* Skip is only allowed between begin/end calls,
* a state that should never happen in main event loop. */
@ -113,7 +113,7 @@ void ED_undo_push(bContext *C, const char *str)
*
* For this reason we need to handle the undo step even when undo steps is set to zero.
*/
if ((steps <= 0) && wm->undo_stack->step_init != NULL) {
if ((steps <= 0) && wm->undo_stack->step_init != nullptr) {
steps = 1;
}
if (steps <= 0) {
@ -121,9 +121,9 @@ void ED_undo_push(bContext *C, const char *str)
}
if (G.background) {
/* Python developers may have explicitly created the undo stack in background mode,
* otherwise allow it to be NULL, see: T60934.
* Otherwise it must never be NULL, even when undo is disabled. */
if (wm->undo_stack == NULL) {
* otherwise allow it to be nullptr, see: T60934.
* Otherwise it must never be nullptr, even when undo is disabled. */
if (wm->undo_stack == nullptr) {
return;
}
}
@ -131,7 +131,7 @@ void ED_undo_push(bContext *C, const char *str)
eUndoPushReturn push_retval;
/* Only apply limit if this is the last undo step. */
if (wm->undo_stack->step_active && (wm->undo_stack->step_active->next == NULL)) {
if (wm->undo_stack->step_active && (wm->undo_stack->step_active->next == nullptr)) {
BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, steps - 1, 0);
}
@ -147,7 +147,7 @@ void ED_undo_push(bContext *C, const char *str)
}
if (push_retval & UNDO_PUSH_RET_OVERRIDE_CHANGED) {
WM_main_add_notifier(NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL);
WM_main_add_notifier(NC_WM | ND_LIB_OVERRIDE_CHANGED, nullptr);
}
}
@ -170,7 +170,7 @@ static void ed_undo_step_pre(bContext *C,
WM_jobs_kill_all(wm);
if (G.debug & G_DEBUG_IO) {
if (bmain->lock != NULL) {
if (bmain->lock != nullptr) {
BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *BEFORE* undo step");
BLO_main_validate_libraries(bmain, reports);
}
@ -179,7 +179,7 @@ static void ed_undo_step_pre(bContext *C,
if (area && (area->spacetype == SPACE_VIEW3D)) {
Object *obact = CTX_data_active_object(C);
if (obact && (obact->type == OB_GPENCIL)) {
ED_gpencil_toggle_brush_cursor(C, false, NULL);
ED_gpencil_toggle_brush_cursor(C, false, nullptr);
}
}
@ -210,15 +210,15 @@ static void ed_undo_step_post(bContext *C,
ScrArea *area = CTX_wm_area(C);
/* Set special modes for grease pencil */
if (area != NULL && (area->spacetype == SPACE_VIEW3D)) {
if (area != nullptr && (area->spacetype == SPACE_VIEW3D)) {
Object *obact = CTX_data_active_object(C);
if (obact && (obact->type == OB_GPENCIL)) {
/* set cursor */
if ((obact->mode & OB_MODE_ALL_PAINT_GPENCIL)) {
ED_gpencil_toggle_brush_cursor(C, true, NULL);
ED_gpencil_toggle_brush_cursor(C, true, nullptr);
}
else {
ED_gpencil_toggle_brush_cursor(C, false, NULL);
ED_gpencil_toggle_brush_cursor(C, false, nullptr);
}
/* set workspace mode */
Base *basact = CTX_data_active_base(C);
@ -235,14 +235,14 @@ static void ed_undo_step_post(bContext *C,
}
if (G.debug & G_DEBUG_IO) {
if (bmain->lock != NULL) {
if (bmain->lock != nullptr) {
BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *AFTER* undo step");
BLO_main_validate_libraries(bmain, reports);
}
}
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
WM_event_add_notifier(C, NC_WM | ND_UNDO, nullptr);
WM_toolsystem_refresh_active(C);
WM_toolsystem_refresh_screen_all(bmain);
@ -298,7 +298,7 @@ static int ed_undo_step_direction(bContext *C, enum eUndoStepDir step, ReportLis
*/
static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *reports)
{
BLI_assert(undo_name != NULL);
BLI_assert(undo_name != nullptr);
/* FIXME: See comments in `ed_undo_step_direction`. */
if (ED_gpencil_session_active()) {
@ -307,20 +307,21 @@ static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *
wmWindowManager *wm = CTX_wm_manager(C);
UndoStep *undo_step_from_name = BKE_undosys_step_find_by_name(wm->undo_stack, undo_name);
if (undo_step_from_name == NULL) {
if (undo_step_from_name == nullptr) {
CLOG_ERROR(&LOG, "Step name='%s' not found in current undo stack", undo_name);
return OPERATOR_CANCELLED;
}
UndoStep *undo_step_target = undo_step_from_name->prev;
if (undo_step_target == NULL) {
if (undo_step_target == nullptr) {
CLOG_ERROR(&LOG, "Step name='%s' cannot be undone", undo_name);
return OPERATOR_CANCELLED;
}
const int undo_dir_i = BKE_undosys_step_calc_direction(wm->undo_stack, undo_step_target, NULL);
const int undo_dir_i = BKE_undosys_step_calc_direction(
wm->undo_stack, undo_step_target, nullptr);
BLI_assert(ELEM(undo_dir_i, -1, 1));
const enum eUndoStepDir undo_dir = (undo_dir_i == -1) ? STEP_UNDO : STEP_REDO;
@ -332,7 +333,7 @@ static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *
ed_undo_step_pre(C, wm, undo_dir, reports);
BKE_undosys_step_load_data_ex(wm->undo_stack, C, undo_step_target, NULL, true);
BKE_undosys_step_load_data_ex(wm->undo_stack, C, undo_step_target, nullptr, true);
ed_undo_step_post(C, wm, undo_dir, reports);
@ -390,11 +391,11 @@ void ED_undo_grouped_push(bContext *C, const char *str)
void ED_undo_pop(bContext *C)
{
ed_undo_step_direction(C, STEP_UNDO, NULL);
ed_undo_step_direction(C, STEP_UNDO, nullptr);
}
void ED_undo_redo(bContext *C)
{
ed_undo_step_direction(C, STEP_REDO, NULL);
ed_undo_step_direction(C, STEP_REDO, nullptr);
}
void ED_undo_push_op(bContext *C, wmOperator *op)
@ -431,10 +432,10 @@ bool ED_undo_is_memfile_compatible(const bContext *C)
* (this matches 2.7x behavior). */
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
if (view_layer != NULL) {
if (view_layer != nullptr) {
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obact = BKE_view_layer_active_object_get(view_layer);
if (obact != NULL) {
if (obact != nullptr) {
if (obact->mode & OB_MODE_EDIT) {
return false;
}
@ -447,10 +448,10 @@ bool ED_undo_is_legacy_compatible_for_property(struct bContext *C, ID *id)
{
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
if (view_layer != NULL) {
if (view_layer != nullptr) {
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obact = BKE_view_layer_active_object_get(view_layer);
if (obact != NULL) {
if (obact != nullptr) {
if (obact->mode & OB_MODE_ALL_PAINT) {
/* Don't store property changes when painting
* (only do undo pushes on brush strokes which each paint operator handles on its own). */
@ -458,7 +459,7 @@ bool ED_undo_is_legacy_compatible_for_property(struct bContext *C, ID *id)
return false;
}
if (obact->mode & OB_MODE_EDIT) {
if ((id == NULL) || (obact->data == NULL) ||
if ((id == nullptr) || (obact->data == nullptr) ||
(GS(id->name) != GS(((ID *)obact->data)->name))) {
/* No undo push on id type mismatch in edit-mode. */
CLOG_INFO(&LOG, 1, "skipping undo for edit-mode");
@ -472,7 +473,7 @@ bool ED_undo_is_legacy_compatible_for_property(struct bContext *C, ID *id)
UndoStack *ED_undo_stack_get(void)
{
wmWindowManager *wm = G_MAIN->wm.first;
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
return wm->undo_stack;
}
@ -514,7 +515,7 @@ static int ed_undo_push_exec(bContext *C, wmOperator *op)
* NOTE: since the undo stack isn't initialized on startup, background mode behavior
* won't match regular usage, this is just for scripts to do explicit undo pushes. */
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->undo_stack == NULL) {
if (wm->undo_stack == nullptr) {
wm->undo_stack = BKE_undosys_stack_create();
}
}
@ -533,7 +534,7 @@ static int ed_redo_exec(bContext *C, wmOperator *op)
return ret;
}
static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op))
static int ed_undo_redo_exec(bContext *C, wmOperator * /*op*/)
{
wmOperator *last_op = WM_operator_last_redo(C);
int ret = ED_undo_operator_repeat(C, last_op);
@ -550,7 +551,7 @@ static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op))
static bool ed_undo_is_init_poll(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->undo_stack == NULL) {
if (wm->undo_stack == nullptr) {
/* This message is intended for Python developers,
* it will be part of the exception when attempting to call undo in background mode. */
CTX_wm_operator_poll_msg_set(
@ -583,7 +584,7 @@ static bool ed_undo_poll(bContext *C)
return false;
}
UndoStack *undo_stack = CTX_wm_manager(C)->undo_stack;
return (undo_stack->step_active != NULL) && (undo_stack->step_active->prev != NULL);
return (undo_stack->step_active != nullptr) && (undo_stack->step_active->prev != nullptr);
}
void ED_OT_undo(wmOperatorType *ot)
@ -626,7 +627,7 @@ static bool ed_redo_poll(bContext *C)
return false;
}
UndoStack *undo_stack = CTX_wm_manager(C)->undo_stack;
return (undo_stack->step_active != NULL) && (undo_stack->step_active->next != NULL);
return (undo_stack->step_active != nullptr) && (undo_stack->step_active->next != nullptr);
}
void ED_OT_redo(wmOperatorType *ot)
@ -724,18 +725,18 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
CTX_wm_region_set(C, region_orig);
}
else {
CLOG_WARN(&LOG, "called with NULL 'op'");
CLOG_WARN(&LOG, "called with nullptr 'op'");
}
return ret;
}
void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void *UNUSED(arg_unused))
void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void * /*arg_unused*/)
{
ED_undo_operator_repeat(C, (wmOperator *)arg_op);
}
void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int UNUSED(arg_unused))
void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int /*arg_unused*/)
{
ED_undo_operator_repeat(C, (wmOperator *)arg_op);
}
@ -758,14 +759,14 @@ static int undo_history_exec(bContext *C, wmOperator *op)
if (ret & OPERATOR_FINISHED) {
ed_undo_refresh_for_op(C);
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
return OPERATOR_FINISHED;
}
}
return OPERATOR_CANCELLED;
}
static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "item");
if (RNA_property_is_set(op->ptr, prop)) {
@ -804,7 +805,7 @@ void ED_undo_object_set_active_or_warn(
Object *ob_prev = BKE_view_layer_active_object_get(view_layer);
if (ob_prev != ob) {
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (base != NULL) {
if (base != nullptr) {
view_layer->basact = base;
ED_object_base_active_refresh(G_MAIN, scene, view_layer);
}
@ -831,13 +832,14 @@ void ED_undo_object_editmode_restore_helper(struct bContext *C,
((ID *)bases[i]->object->data)->tag |= LIB_TAG_DOIT;
}
Object **ob_p = object_array;
for (uint i = 0; i < object_array_len; i++, ob_p = POINTER_OFFSET(ob_p, object_array_stride)) {
for (uint i = 0; i < object_array_len;
i++, ob_p = static_cast<Object **>(POINTER_OFFSET(ob_p, object_array_stride))) {
Object *obedit = *ob_p;
ED_object_editmode_enter_ex(bmain, scene, obedit, EM_NO_CONTEXT);
((ID *)obedit->data)->tag &= ~LIB_TAG_DOIT;
}
for (uint i = 0; i < bases_len; i++) {
ID *id = bases[i]->object->data;
ID *id = static_cast<ID *>(bases[i]->object->data);
if (id->tag & LIB_TAG_DOIT) {
ED_object_editmode_exit_ex(bmain, scene, bases[i]->object, EM_FREEDATA);
/* Ideally we would know the selection state it was before entering edit-mode,
@ -870,7 +872,7 @@ static int undo_editmode_objects_from_view_layer_prepare(const Scene *scene,
LISTBASE_FOREACH (Base *, base, object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
ID *id = static_cast<ID *>(ob->data);
id->tag &= ~LIB_TAG_DOIT;
}
}
@ -879,7 +881,7 @@ static int undo_editmode_objects_from_view_layer_prepare(const Scene *scene,
LISTBASE_FOREACH (Base *, base, object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
ID *id = static_cast<ID *>(ob->data);
if ((id->tag & LIB_TAG_DOIT) == 0) {
len += 1;
id->tag |= LIB_TAG_DOIT;
@ -895,21 +897,23 @@ Object **ED_undo_editmode_objects_from_view_layer(const Scene *scene,
{
BKE_view_layer_synced_ensure(scene, view_layer);
Base *baseact = BKE_view_layer_active_base_get(view_layer);
if ((baseact == NULL) || (baseact->object->mode & OB_MODE_EDIT) == 0) {
return MEM_mallocN(0, __func__);
if ((baseact == nullptr) || (baseact->object->mode & OB_MODE_EDIT) == 0) {
return static_cast<Object **>(MEM_mallocN(0, __func__));
}
const int len = undo_editmode_objects_from_view_layer_prepare(
scene, view_layer, baseact->object);
const short object_type = baseact->object->type;
int i = 0;
Object **objects = MEM_malloc_arrayN(len, sizeof(*objects), __func__);
Object **objects = static_cast<Object **>(MEM_malloc_arrayN(len, sizeof(*objects), __func__));
/* Base iteration, starting with the active-base to ensure it's the first item in the array.
* Looping over the active-base twice is OK as the tag check prevents it being handled twice. */
for (Base *base = baseact, *base_next = BKE_view_layer_object_bases_get(view_layer)->first; base;
base = base_next, base_next = base_next ? base_next->next : NULL) {
for (Base *base = baseact,
*base_next = static_cast<Base *>(BKE_view_layer_object_bases_get(view_layer)->first);
base;
base = base_next, base_next = base_next ? base_next->next : nullptr) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
ID *id = static_cast<ID *>(ob->data);
if (id->tag & LIB_TAG_DOIT) {
objects[i++] = ob;
id->tag &= ~LIB_TAG_DOIT;
@ -928,23 +932,23 @@ Base **ED_undo_editmode_bases_from_view_layer(const Scene *scene,
{
BKE_view_layer_synced_ensure(scene, view_layer);
Base *baseact = BKE_view_layer_active_base_get(view_layer);
if ((baseact == NULL) || (baseact->object->mode & OB_MODE_EDIT) == 0) {
return MEM_mallocN(0, __func__);
if ((baseact == nullptr) || (baseact->object->mode & OB_MODE_EDIT) == 0) {
return static_cast<Base **>(MEM_mallocN(0, __func__));
}
const int len = undo_editmode_objects_from_view_layer_prepare(
scene, view_layer, baseact->object);
const short object_type = baseact->object->type;
int i = 0;
Base **base_array = MEM_malloc_arrayN(len, sizeof(*base_array), __func__);
Base **base_array = static_cast<Base **>(MEM_malloc_arrayN(len, sizeof(*base_array), __func__));
/* Base iteration, starting with the active-base to ensure it's the first item in the array.
* Looping over the active-base twice is OK as the tag check prevents it being handled twice. */
for (Base *base = BKE_view_layer_active_base_get(view_layer),
*base_next = BKE_view_layer_object_bases_get(view_layer)->first;
*base_next = static_cast<Base *>(BKE_view_layer_object_bases_get(view_layer)->first);
base;
base = base_next, base_next = base_next ? base_next->next : NULL) {
base = base_next, base_next = base_next ? base_next->next : nullptr) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
ID *id = static_cast<ID *>(ob->data);
if (id->tag & LIB_TAG_DOIT) {
base_array[i++] = base;
id->tag &= ~LIB_TAG_DOIT;

View File

@ -41,7 +41,7 @@
#include "../blenloader/BLO_undofile.h"
#include "undo_intern.h"
#include "undo_intern.hh"
#include <stdio.h>
@ -64,13 +64,13 @@ static bool memfile_undosys_poll(bContext *C)
/* Allow a single memfile undo step (the first). */
UndoStack *ustack = ED_undo_stack_get();
if ((ustack->step_active != NULL) && (ED_undo_is_memfile_compatible(C) == false)) {
if ((ustack->step_active != nullptr) && (ED_undo_is_memfile_compatible(C) == false)) {
return false;
}
return true;
}
static bool memfile_undosys_step_encode(struct bContext *UNUSED(C),
static bool memfile_undosys_step_encode(struct bContext * /*C*/,
struct Main *bmain,
UndoStep *us_p)
{
@ -83,10 +83,10 @@ static bool memfile_undosys_step_encode(struct bContext *UNUSED(C),
ED_editors_flush_edits_ex(bmain, false, true);
}
/* can be NULL, use when set. */
/* can be null, use when set. */
MemFileUndoStep *us_prev = (MemFileUndoStep *)BKE_undosys_step_find_by_type(
ustack, BKE_UNDOSYS_TYPE_MEMFILE);
us->data = BKE_memfile_undo_encode(bmain, us_prev ? us_prev->data : NULL);
us->data = BKE_memfile_undo_encode(bmain, us_prev ? us_prev->data : nullptr);
us->step.data_size = us->data->undo_size;
/* Store the fact that we should not re-use old data with that undo step, and reset the Main
@ -104,14 +104,14 @@ static int memfile_undosys_step_id_reused_cb(LibraryIDLinkCallbackData *cb_data)
BLI_assert((id_self->tag & LIB_TAG_UNDO_OLD_ID_REUSED) != 0);
ID *id = *id_pointer;
if (id != NULL && !ID_IS_LINKED(id) && (id->tag & LIB_TAG_UNDO_OLD_ID_REUSED) == 0) {
if (id != nullptr && !ID_IS_LINKED(id) && (id->tag & LIB_TAG_UNDO_OLD_ID_REUSED) == 0) {
bool do_stop_iter = true;
if (GS(id_self->name) == ID_OB) {
Object *ob_self = (Object *)id_self;
if (ob_self->type == OB_ARMATURE) {
if (ob_self->data == id) {
BLI_assert(GS(id->name) == ID_AR);
if (ob_self->pose != NULL) {
if (ob_self->pose != nullptr) {
/* We have a changed/re-read armature used by an unchanged armature object: our beloved
* Bone pointers from the object's pose need their usual special treatment. */
ob_self->pose->flag |= POSE_RECALC;
@ -151,7 +151,7 @@ static void memfile_undosys_unfinished_id_previews_restart(ID *id)
}
if (!BKE_previewimg_is_finished(preview, i)) {
ED_preview_restart_queue_add(id, i);
ED_preview_restart_queue_add(id, eIconSizes(i));
}
}
}
@ -160,7 +160,7 @@ static void memfile_undosys_step_decode(struct bContext *C,
struct Main *bmain,
UndoStep *us_p,
const eUndoStepDir undo_direction,
bool UNUSED(is_final))
bool /*is_final*/)
{
BLI_assert(undo_direction != STEP_INVALID);
@ -187,7 +187,7 @@ static void memfile_undosys_step_decode(struct bContext *C,
* fine-grained update flags now.
*/
UndoStep *us_next = us_p->next;
if (us_next != NULL) {
if (us_next != nullptr) {
if (us_next->use_old_bmain_data == false) {
use_old_bmain_data = false;
}
@ -196,7 +196,7 @@ static void memfile_undosys_step_decode(struct bContext *C,
/* Extract depsgraphs from current bmain (which may be freed during undo step reading),
* and store them for re-use. */
GHash *depsgraphs = NULL;
GHash *depsgraphs = nullptr;
if (use_old_bmain_data) {
depsgraphs = BKE_scene_undo_depsgraphs_extract(bmain);
}
@ -232,11 +232,11 @@ static void memfile_undosys_step_decode(struct bContext *C,
/* We need to inform depsgraph about re-used old IDs that would be using newly read
* data-blocks, at least COW evaluated copies need to be updated... */
ID *id = NULL;
ID *id = nullptr;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (id->tag & LIB_TAG_UNDO_OLD_ID_REUSED) {
BKE_library_foreach_ID_link(
bmain, id, memfile_undosys_step_id_reused_cb, NULL, IDWALK_READONLY);
bmain, id, memfile_undosys_step_id_reused_cb, nullptr, IDWALK_READONLY);
}
/* Tag depsgraph to update data-block for changes that happened between the
@ -246,12 +246,12 @@ static void memfile_undosys_step_decode(struct bContext *C,
}
bNodeTree *nodetree = ntreeFromID(id);
if (nodetree != NULL && nodetree->id.recalc != 0) {
if (nodetree != nullptr && nodetree->id.recalc != 0) {
DEG_id_tag_update_ex(bmain, &nodetree->id, nodetree->id.recalc);
}
if (GS(id->name) == ID_SCE) {
Scene *scene = (Scene *)id;
if (scene->master_collection != NULL && scene->master_collection->id.recalc != 0) {
if (scene->master_collection != nullptr && scene->master_collection->id.recalc != 0) {
DEG_id_tag_update_ex(
bmain, &scene->master_collection->id, scene->master_collection->id.recalc);
}
@ -271,12 +271,12 @@ static void memfile_undosys_step_decode(struct bContext *C,
* loop because DEG_id_tag_update may set tags on other datablocks. */
id->recalc_after_undo_push = 0;
bNodeTree *nodetree = ntreeFromID(id);
if (nodetree != NULL) {
if (nodetree != nullptr) {
nodetree->id.recalc_after_undo_push = 0;
}
if (GS(id->name) == ID_SCE) {
Scene *scene = (Scene *)id;
if (scene->master_collection != NULL) {
if (scene->master_collection != nullptr) {
scene->master_collection->id.recalc_after_undo_push = 0;
}
}
@ -284,7 +284,7 @@ static void memfile_undosys_step_decode(struct bContext *C,
FOREACH_MAIN_ID_END;
}
else {
ID *id = NULL;
ID *id = nullptr;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
/* Restart preview generation if the undo state was generating previews. */
memfile_undosys_unfinished_id_previews_restart(id);
@ -300,9 +300,9 @@ static void memfile_undosys_step_free(UndoStep *us_p)
/* To avoid unnecessary slow down, free backwards
* (so we don't need to merge when clearing all). */
MemFileUndoStep *us = (MemFileUndoStep *)us_p;
if (us_p->next != NULL) {
if (us_p->next != nullptr) {
UndoStep *us_next_p = BKE_undosys_step_same_type_next(us_p);
if (us_next_p != NULL) {
if (us_next_p != nullptr) {
MemFileUndoStep *us_next = (MemFileUndoStep *)us_next_p;
BLO_memfile_merge(&us->data->memfile, &us_next->data->memfile);
}
@ -346,13 +346,13 @@ struct MemFile *ED_undosys_stack_memfile_get_active(UndoStack *ustack)
if (us) {
return ed_undosys_step_get_memfile(us);
}
return NULL;
return nullptr;
}
void ED_undosys_stack_memfile_id_changed_tag(UndoStack *ustack, ID *id)
{
UndoStep *us = ustack->step_active;
if (id == NULL || us == NULL || us->type != BKE_UNDOSYS_TYPE_MEMFILE) {
if (id == nullptr || us == nullptr || us->type != BKE_UNDOSYS_TYPE_MEMFILE) {
return;
}

View File

@ -10,7 +10,7 @@
struct UndoType;
/* memfile_undo.c */
/* memfile_undo.cc */
/** Export for ED_undo_sys. */
void ED_memfile_undosys_type(struct UndoType *ut);

View File

@ -19,7 +19,7 @@
#include "ED_sculpt.h"
#include "ED_text.h"
#include "ED_undo.h"
#include "undo_intern.h"
#include "undo_intern.hh"
/* Keep last */
#include "BKE_undo_system.h"

View File

@ -36,9 +36,7 @@
#include "uvedit_clipboard_graph_iso.hh"
#include "uvedit_intern.h" /* linker, extern "C" */
extern "C" {
void UV_clipboard_free(void);
}
void UV_clipboard_free();
class UV_ClipboardBuffer {
public:

View File

@ -659,6 +659,8 @@ typedef struct UserDef_Experimental {
(((userdef)->flag & USER_DEVELOPER_UI) && ((userdef)->experimental).member)
typedef struct UserDef {
DNA_DEFINE_CXX_METHODS(UserDef)
/** UserDef has separate do-version handling, and can be read from other files. */
int versionfile, subversionfile;

View File

@ -142,7 +142,7 @@ static void transform_volume(GeoNodeExecParams &params,
normalize_v3(grid_matrix.values[2]);
}
}
BKE_volume_grid_transform_matrix_set(volume_grid, grid_matrix.values);
BKE_volume_grid_transform_matrix_set(&volume, volume_grid, grid_matrix.values);
}
if (found_too_small_scale) {
params.error_message_add(NodeWarningType::Warning,

View File

@ -41,11 +41,11 @@ set(SRC
intern/wm_draw.c
intern/wm_event_query.c
intern/wm_event_system.cc
intern/wm_files.c
intern/wm_files.cc
intern/wm_files_link.c
intern/wm_gesture.c
intern/wm_gesture_ops.c
intern/wm_init_exit.c
intern/wm_init_exit.cc
intern/wm_jobs.c
intern/wm_keymap.c
intern/wm_keymap_utils.c
@ -105,6 +105,10 @@ set(LIB
bf_sequencer
)
if(WIN32)
add_definitions(-DNOMINMAX)
endif()
if(WITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}

View File

@ -274,7 +274,7 @@ void WM_window_set_dpi(const wmWindow *win);
bool WM_stereo3d_enabled(struct wmWindow *win, bool only_fullscreen_test);
/* wm_files.c */
/* wm_files.cc */
void WM_file_autoexec_init(const char *filepath);
bool WM_file_read(struct bContext *C, const char *filepath, struct ReportList *reports);

View File

@ -1270,7 +1270,7 @@ typedef struct RecentFile {
/* Logging */
struct CLG_LogRef;
/* wm_init_exit.c */
/* wm_init_exit.cc */
extern struct CLG_LogRef *WM_LOG_OPERATORS;
extern struct CLG_LogRef *WM_LOG_HANDLERS;

View File

@ -190,7 +190,7 @@ static void sound_jack_sync_callback(Main *bmain, int mode, double time)
return;
}
wmWindowManager *wm = bmain->wm.first;
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
Scene *scene = WM_window_get_active_scene(window);
@ -199,7 +199,7 @@ static void sound_jack_sync_callback(Main *bmain, int mode, double time)
}
ViewLayer *view_layer = WM_window_get_active_view_layer(window);
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer);
if (depsgraph == NULL) {
if (depsgraph == nullptr) {
continue;
}
BKE_sound_lock();
@ -250,7 +250,7 @@ void WM_init(bContext *C, int argc, const char **argv)
BLT_lang_init();
/* Must call first before doing any `.blend` file reading,
* since versioning code may create new IDs. See T57066. */
BLT_lang_set(NULL);
BLT_lang_set(nullptr);
/* Init icons before reading .blend files for preview icons, which can
* get triggered by the depsgraph. This is also done in background mode
@ -287,25 +287,23 @@ void WM_init(bContext *C, int argc, const char **argv)
* Creating a dummy window-manager early, or moving the key-maps into the preferences
* would resolve this and may be worth looking into long-term, see: D12184 for details.
*/
struct wmFileReadPost_Params *params_file_read_post = NULL;
wm_homefile_read_ex(C,
&(const struct wmHomeFileRead_Params){
.use_data = true,
.use_userdef = true,
.use_factory_settings = G.factory_startup,
.use_empty_data = false,
.filepath_startup_override = NULL,
.app_template_override = WM_init_state_app_template_get(),
},
NULL,
&params_file_read_post);
struct wmFileReadPost_Params *params_file_read_post = nullptr;
wmHomeFileRead_Params read_homefile_params{};
read_homefile_params.use_data = true;
read_homefile_params.use_userdef = true;
read_homefile_params.use_factory_settings = G.factory_startup;
read_homefile_params.use_empty_data = false;
read_homefile_params.filepath_startup_override = nullptr;
read_homefile_params.app_template_override = WM_init_state_app_template_get();
wm_homefile_read_ex(C, &read_homefile_params, nullptr, &params_file_read_post);
/* NOTE: leave `G_MAIN->filepath` set to an empty string since this
* matches behavior after loading a new file. */
BLI_assert(G_MAIN->filepath[0] == '\0');
/* Call again to set from preferences. */
BLT_lang_set(NULL);
BLT_lang_set(nullptr);
/* For file-system. Called here so can include user preference paths if needed. */
ED_file_init();
@ -367,8 +365,8 @@ void WM_init_splash(bContext *C)
wmWindow *prevwin = CTX_wm_window(C);
if (wm->windows.first) {
CTX_wm_window_set(C, wm->windows.first);
WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, NULL, NULL);
CTX_wm_window_set(C, static_cast<wmWindow *>(wm->windows.first));
WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
CTX_wm_window_set(C, prevwin);
}
}
@ -390,7 +388,8 @@ static void wait_for_console_key(void)
{
HANDLE hConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
if (!ELEM(hConsoleInput, NULL, INVALID_HANDLE_VALUE) && FlushConsoleInputBuffer(hConsoleInput)) {
if (!ELEM(hConsoleInput, nullptr, INVALID_HANDLE_VALUE) &&
FlushConsoleInputBuffer(hConsoleInput)) {
for (;;) {
INPUT_RECORD buffer;
DWORD ignored;
@ -424,25 +423,26 @@ void wm_exit_schedule_delayed(const bContext *C)
/* Use modal UI handler for now.
* Could add separate WM handlers or so, but probably not worth it. */
WM_event_add_ui_handler(C, &win->modalhandlers, wm_exit_handler, NULL, NULL, 0);
WM_event_add_ui_handler(
C, &win->modalhandlers, wm_exit_handler, nullptr, nullptr, eWM_EventHandlerFlag(0));
WM_event_add_mousemove(win); /* ensure handler actually gets called */
}
void UV_clipboard_free(void);
void UV_clipboard_free();
void WM_exit_ex(bContext *C, const bool do_python)
{
wmWindowManager *wm = C ? CTX_wm_manager(C) : NULL;
wmWindowManager *wm = C ? CTX_wm_manager(C) : nullptr;
/* first wrap up running stuff, we assume only the active WM is running */
/* modal handlers are on window level freed, others too? */
/* NOTE: same code copied in `wm_files.c`. */
/* NOTE: same code copied in `wm_files.cc`. */
if (C && wm) {
if (!G.background) {
struct MemFile *undo_memfile = wm->undo_stack ?
ED_undosys_stack_memfile_get_active(wm->undo_stack) :
NULL;
if (undo_memfile != NULL) {
nullptr;
if (undo_memfile != nullptr) {
/* save the undo state as quit.blend */
Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
@ -453,9 +453,9 @@ void WM_exit_ex(bContext *C, const bool do_python)
has_edited = ED_editors_flush_edits(bmain);
BlendFileWriteParams blend_file_write_params{};
if ((has_edited &&
BLO_write_file(
bmain, filepath, fileflags, &(const struct BlendFileWriteParams){0}, NULL)) ||
BLO_write_file(bmain, filepath, fileflags, &blend_file_write_params, nullptr)) ||
BLO_memfile_write_file(undo_memfile, filepath)) {
printf("Saved session recovery to '%s'\n", filepath);
}
@ -474,12 +474,12 @@ void WM_exit_ex(bContext *C, const bool do_python)
if (!G.background) {
if ((U.pref_flag & USER_PREF_FLAG_SAVE) && ((G.f & G_FLAG_USERPREF_NO_SAVE_ON_EXIT) == 0)) {
if (U.runtime.is_dirty) {
BKE_blendfile_userdef_write_all(NULL);
BKE_blendfile_userdef_write_all(nullptr);
}
}
/* Free the callback data used on file-open
* (will be set when a recover operation has run). */
wm_test_autorun_revert_action_set(NULL, NULL);
wm_test_autorun_revert_action_set(nullptr, nullptr);
}
}
@ -492,7 +492,8 @@ void WM_exit_ex(bContext *C, const bool do_python)
* Don't run this code when built as a Python module as this runs when Python is in the
* process of shutting down, where running a snippet like this will crash, see T82675.
* Instead use the `atexit` module, installed by #BPY_python_start */
BPY_run_string_eval(C, (const char *[]){"addon_utils", NULL}, "addon_utils.disable_all()");
const char *imports[2] = {"addon_utils", nullptr};
BPY_run_string_eval(C, imports, "addon_utils.disable_all()");
#endif
BLI_timer_free();
@ -584,7 +585,7 @@ void WM_exit_ex(bContext *C, const bool do_python)
#ifdef WITH_PYTHON
/* option not to close python so we can use 'atexit' */
if (do_python && ((C == NULL) || CTX_py_init_get(C))) {
if (do_python && ((C == nullptr) || CTX_py_init_get(C))) {
/* NOTE: (old note)
* before BKE_blender_free so Python's garbage-collection happens while library still exists.
* Needed at least for a rare crash that can happen in python-drivers.

View File

@ -8,4 +8,12 @@
#include "BLI_sys_types.h"
#ifdef __cplusplus
extern "C" {
#endif
bool WM_platform_support_perform_checks(void);
#ifdef __cplusplus
}
#endif

View File

@ -1644,7 +1644,7 @@ void wm_ghost_init(bContext *C)
GHOST_UseWindowFocus(wm_init_state.window_focus);
}
/* TODO move this to wm_init_exit.c. */
/* TODO move this to wm_init_exit.cc. */
void wm_ghost_init_background(void)
{
if (g_system) {

View File

@ -88,7 +88,7 @@ void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt);
*/
void wm_jobs_timer_end(wmWindowManager *wm, wmTimer *wt);
/* wm_files.c */
/* wm_files.cc */
/**
* Run the auto-save timer action.

View File

@ -16,7 +16,7 @@ struct wmOperatorType;
extern "C" {
#endif
/* wm_files.c */
/* wm_files.cc */
void wm_history_file_read(void);