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.
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
Reference in New Issue
Block a user