Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-07-16 16:24:55 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-07-20 18:11:29 +0300
commit3ea4c6b9c9cb7bc6e9efa00bf86759b8a7fedc68 (patch)
tree5b54b8bdc73c438fbcfe9ea5aabdf6d2b2d82d73 /source/blender
parentf164188a6d81cb4b8f7400b12979b2948ec46734 (diff)
Pose backup: convert from C to C++
Convert `pose_backup.c` (in C) to `pose_backup.cc` (in C++). This will make future improvements easier. For now, it's the same code with just some additional explicit casts (C++ doesn't allow implicitly casting `void *`), `NULL` changed into `nullptr`, and some other simple changes. No functional changes.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/armature/CMakeLists.txt2
-rw-r--r--source/blender/editors/armature/pose_backup.cc (renamed from source/blender/editors/armature/pose_backup.c)19
2 files changed, 11 insertions, 10 deletions
diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt
index e942bcf2902..aff5803f037 100644
--- a/source/blender/editors/armature/CMakeLists.txt
+++ b/source/blender/editors/armature/CMakeLists.txt
@@ -44,7 +44,7 @@ set(SRC
armature_utils.c
editarmature_undo.c
meshlaplacian.c
- pose_backup.c
+ pose_backup.cc
pose_edit.c
pose_group.c
pose_lib.c
diff --git a/source/blender/editors/armature/pose_backup.c b/source/blender/editors/armature/pose_backup.cc
index dffcd9bdc5a..8d53bd8064b 100644
--- a/source/blender/editors/armature/pose_backup.c
+++ b/source/blender/editors/armature/pose_backup.cc
@@ -20,7 +20,7 @@
#include "ED_armature.h"
-#include <string.h>
+#include <cstring>
#include "BLI_listbase.h"
@@ -44,23 +44,23 @@ typedef struct PoseChannelBackup {
struct IDProperty *oldprops; /* Backup copy (needs freeing) of pose channel's ID properties. */
} PoseChannelBackup;
-typedef struct PoseBackup {
+struct PoseBackup {
bool is_bone_selection_relevant;
ListBase /* PoseChannelBackup* */ backups;
-} PoseBackup;
+};
static PoseBackup *pose_backup_create(const Object *ob,
const bAction *action,
const bool is_bone_selection_relevant)
{
- ListBase backups = {NULL, NULL};
- const bArmature *armature = ob->data;
+ ListBase backups = {nullptr, nullptr};
+ const bArmature *armature = static_cast<const bArmature *>(ob->data);
/* TODO(Sybren): reuse same approach as in `armature_pose.cc` in this function, as that doesn't
* have the assumption that action group names are bone names. */
LISTBASE_FOREACH (bActionGroup *, agrp, &action->groups) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
- if (pchan == NULL) {
+ if (pchan == nullptr) {
continue;
}
@@ -68,7 +68,8 @@ static PoseBackup *pose_backup_create(const Object *ob,
continue;
}
- PoseChannelBackup *chan_bak = MEM_callocN(sizeof(*chan_bak), "PoseChannelBackup");
+ PoseChannelBackup *chan_bak = static_cast<PoseChannelBackup *>(
+ MEM_callocN(sizeof(*chan_bak), "PoseChannelBackup"));
chan_bak->pchan = pchan;
memcpy(&chan_bak->olddata, chan_bak->pchan, sizeof(chan_bak->olddata));
@@ -80,7 +81,7 @@ static PoseBackup *pose_backup_create(const Object *ob,
}
/* PoseBackup is constructed late, so that the above loop can use stack variables. */
- PoseBackup *pose_backup = MEM_callocN(sizeof(*pose_backup), __func__);
+ PoseBackup *pose_backup = static_cast<PoseBackup *>(MEM_callocN(sizeof(*pose_backup), __func__));
pose_backup->is_bone_selection_relevant = is_bone_selection_relevant;
pose_backup->backups = backups;
return pose_backup;
@@ -96,7 +97,7 @@ PoseBackup *ED_pose_backup_create_selected_bones(const Object *ob, const bAction
/* See if bone selection is relevant. */
bool all_bones_selected = true;
bool no_bones_selected = true;
- const bArmature *armature = ob->data;
+ const bArmature *armature = static_cast<const bArmature *>(ob->data);
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
const bool is_selected = PBONE_SELECTED(armature, pchan->bone);
all_bones_selected &= is_selected;