Refactor: Anim, abstractions for armature layers #110533

Manually merged
Sybren A. Stüvel merged 1 commits from dr.sybren/blender:anim/armature-coll-prep into main 2023-07-27 14:57:28 +02:00
33 changed files with 271 additions and 39 deletions

View File

@ -131,6 +131,7 @@ set(SRC_DNA_DEFAULTS_INC
add_subdirectory(datatoc)
add_subdirectory(editors)
add_subdirectory(windowmanager)
add_subdirectory(animrig)
add_subdirectory(asset_system)
add_subdirectory(blenkernel)
add_subdirectory(blenlib)

View File

@ -0,0 +1,83 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup animrig
*
* \brief Functions to deal with Armature collections (i.e. the successor of bone layers).
*/
#pragma once
#include <stdbool.h>
#include "BLI_math_bits.h"
#include "BKE_armature.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct bArmature;
struct Bone;
struct bPoseChannel;
struct EditBone;
/**
* Armature/Bone Layer abstractions. These functions are intended as the sole
* accessors for `bone->layer`, `armature->layer`, etc. to get a grip on which
* queries & operations are performed.
*
* The functions are named "bonecoll" (short for "bone collection"), as that's
* the soon-to-be-introduced replacement for armature layers. This API is the
* first step towards replacement.
*/
inline bool ANIM_bonecoll_is_visible(const struct bArmature *armature, const struct Bone *bone)
{
return armature->layer & bone->layer;
}
inline bool ANIM_bone_is_visible(const struct bArmature *armature, const struct Bone *bone)
{
const bool bone_itself_visible = (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0;
return bone_itself_visible && ANIM_bonecoll_is_visible(armature, bone);
}
inline bool ANIM_bonecoll_is_visible_editbone(const struct bArmature *armature,
const struct EditBone *ebone)
{
return armature->layer & ebone->layer;
}
inline bool ANIM_bonecoll_is_visible_pchan(const struct bArmature *armature,
const struct bPoseChannel *pchan)
{
return ANIM_bonecoll_is_visible(armature, pchan->bone);
}
inline bool ANIM_bonecoll_is_visible_actbone(const struct bArmature *armature)
{
return ANIM_bonecoll_is_visible(armature, armature->act_bone);
}
void ANIM_armature_enable_layers(struct bArmature *armature, const int layers);
void ANIM_armature_disable_all_layers(struct bArmature *armature);
void ANIM_bone_set_layer_ebone(struct EditBone *ebone, int layer);
void ANIM_bone_set_ebone_layer_from_armature(struct EditBone *ebone,
const struct bArmature *armature);
void ANIM_armature_ensure_first_layer_enabled(struct bArmature *armature);
void ANIM_armature_ensure_layer_enabled_from_bone(struct bArmature *armature,
const struct Bone *bone);
void ANIM_armature_ensure_layer_enabled_from_ebone(struct bArmature *armature,
const struct EditBone *ebone);
void ANIM_armature_ensure_layer_enabled_from_pchan(struct bArmature *armature,
const struct bPoseChannel *pchan);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: 2023 Blender Foundation
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(INC
PUBLIC .
intern
../blenkernel
)
set(INC_SYS
)
set(SRC
intern/bone_collections.cc
ANIM_bone_collections.h
)
set(LIB
bf_blenkernel
bf::blenlib
bf::dna
)
blender_add_lib(bf_animrig "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_library(bf::animrig ALIAS bf_animrig)
# if(WITH_GTESTS)
# set(TEST_SRC
# )
# set(TEST_LIB
# PRIVATE bf::animrig
# )
# include(GTestTesting)
# blender_add_test_lib(bf_animrig_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
# endif()

View File

@ -0,0 +1,62 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup animrig
*/
#include "DNA_armature_types.h"
#include "BLI_math_bits.h"
#include "ANIM_bone_collections.h"
/* ********************************* */
/* Armature Layers transitional API. */
void ANIM_armature_enable_layers(bArmature *armature, const int layers)
{
armature->layer |= layers;
}
void ANIM_armature_disable_all_layers(bArmature *armature)
{
armature->layer = 0;
}
void ANIM_bone_set_layer_ebone(EditBone *ebone, const int layer)
{
ebone->layer = layer;
}
void ANIM_bone_set_ebone_layer_from_armature(EditBone *ebone, const bArmature *armature)
{
ebone->layer = armature->layer;
}
void ANIM_armature_ensure_first_layer_enabled(bArmature *armature)
{
armature->layer = 1;
}
void ANIM_armature_ensure_layer_enabled_from_bone(bArmature *armature, const Bone *bone)
{
if (ANIM_bonecoll_is_visible(armature, bone)) {
return;
}
armature->layer |= 1U << bitscan_forward_uint(bone->layer);
}
void ANIM_armature_ensure_layer_enabled_from_ebone(bArmature *armature, const EditBone *ebone)
{
if (ANIM_bonecoll_is_visible_editbone(armature, ebone)) {
return;
}
armature->layer |= 1U << bitscan_forward_uint(ebone->layer);
}
void ANIM_armature_ensure_layer_enabled_from_pchan(bArmature *armature, const bPoseChannel *pchan)
{
ANIM_armature_ensure_layer_enabled_from_bone(armature, pchan->bone);
}

View File

@ -814,6 +814,7 @@ endforeach()
blender_add_lib(bf_draw_shaders "${GLSL_C}" "" "" "")
list(APPEND LIB
PRIVATE bf::animrig
bf_draw_shaders
)

View File

@ -35,6 +35,8 @@
#include "ED_armature.h"
#include "ED_view3d.h"
#include "ANIM_bone_collections.h"
#include "UI_resources.h"
#include "draw_common.h"
@ -2560,7 +2562,7 @@ static void draw_armature_edit(const ArmatureDrawContext *ctx)
eBone;
eBone = eBone->next, index += 0x10000)
{
if ((eBone->layer & arm->layer) == 0) {
if (!ANIM_bonecoll_is_visible_editbone(arm, eBone)) {
continue;
}
if (eBone->flag & BONE_HIDDEN_A) {

View File

@ -44,6 +44,7 @@ set(SRC
set(LIB
bf_blenkernel
PRIVATE bf::animrig
PRIVATE bf::blenlib
PRIVATE bf::dna
PRIVATE bf::intern::guardedalloc

View File

@ -89,6 +89,8 @@
#include "SEQ_sequencer.h"
#include "SEQ_utils.h"
#include "ANIM_bone_collections.h"
#include "UI_resources.h" /* for TH_KEYFRAME_SCALE lookup */
/* ************************************************************ */
@ -1038,7 +1040,7 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
bArmature *arm = (bArmature *)ob->data;
/* skipping - not visible on currently visible layers */
if ((arm->layer & pchan->bone->layer) == 0) {
if (!ANIM_bonecoll_is_visible_pchan(arm, pchan)) {
return true;
}
/* skipping - is currently hidden */

View File

@ -33,6 +33,8 @@
#include "ED_anim_api.h"
#include "ED_keyframes_keylist.h"
#include "ANIM_bone_collections.h"
#include "CLG_log.h"
static CLG_LogRef LOG = {"ed.anim.motion_paths"};
@ -112,7 +114,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
if ((pchan->bone) && (arm->layer & pchan->bone->layer) && (pchan->mpath)) {
if ((pchan->bone) && ANIM_bonecoll_is_visible_pchan(arm, pchan) && (pchan->mpath)) {
/* new target for bone */
mpt = static_cast<MPathTarget *>(MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone"));
BLI_addtail(targets, mpt);

View File

@ -57,6 +57,8 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ANIM_bone_collections.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -2436,7 +2438,7 @@ static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
bArmature *arm = (bArmature *)ob->data;
/* skipping - not visible on currently visible layers */
if ((arm->layer & pchan->bone->layer) == 0) {
if (!ANIM_bonecoll_is_visible_pchan(arm, pchan)) {
continue;
}
/* skipping - is currently hidden */

View File

@ -46,6 +46,7 @@ set(SRC
)
set(LIB
PRIVATE bf::animrig
bf_blenkernel
PRIVATE bf::blenlib
PRIVATE bf::dna

View File

@ -43,6 +43,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
#include "ANIM_bone_collections.h"
#include "DEG_depsgraph.h"
#include "armature_intern.h"
@ -66,7 +68,7 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name)
bone->rad_head = 0.10f;
bone->rad_tail = 0.05f;
bone->segments = 1;
bone->layer = arm->layer;
ANIM_bone_set_ebone_layer_from_armature(bone, arm);
/* Bendy-Bone parameters */
bone->roll1 = 0.0f;

View File

@ -41,6 +41,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
#include "ANIM_bone_collections.h"
#include "DEG_depsgraph.h"
#include "armature_intern.h"
@ -1221,7 +1223,7 @@ static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p)
EditBone *ebone;
ebone = ED_armature_ebone_find_name(arm->edbo, bone_name);
return (ebone && (ebone->flag & BONE_SELECTED) && (arm->layer & ebone->layer));
return (ebone && (ebone->flag & BONE_SELECTED) && ANIM_bonecoll_is_visible_editbone(arm, ebone));
}
/* previously delete_armature */
@ -1252,7 +1254,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator * /*op*/)
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = ebone_next) {
ebone_next = curBone->next;
if (arm->layer & curBone->layer) {
if (ANIM_bonecoll_is_visible_editbone(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) {
if (curBone == arm->act_edbone) {
arm->act_edbone = nullptr;
@ -1384,13 +1386,13 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/)
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
/* break connections for unseen bones */
if (((arm->layer & ebone->layer) &&
if ((ANIM_bonecoll_is_visible_editbone(arm, ebone) &&
(ED_armature_ebone_selectflag_get(ebone) & (BONE_TIPSEL | BONE_SELECTED))) == 0)
{
ebone->temp.ebone = nullptr;
}
if (((arm->layer & ebone->layer) &&
if ((ANIM_bonecoll_is_visible_editbone(arm, ebone) &&
(ED_armature_ebone_selectflag_get(ebone) & (BONE_ROOTSEL | BONE_SELECTED))) == 0)
{
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
@ -1565,7 +1567,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op)
bool changed = false;
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (arm->layer & ebone->layer) {
if (ANIM_bonecoll_is_visible_editbone(arm, ebone)) {
if (ebone->flag & BONE_HIDDEN_A) {
if (!(ebone->flag & BONE_UNSELECTABLE)) {
SET_FLAG_FROM_TEST(ebone->flag, select, (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL));

View File

@ -37,6 +37,8 @@
#include "ED_armature.h"
#include "ED_mesh.h"
#include "ANIM_bone_collections.h"
#include "armature_intern.h"
#include "meshlaplacian.h"
@ -159,7 +161,9 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
segments = 1;
}
if (!data->is_weight_paint || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) {
if (!data->is_weight_paint ||
(ANIM_bonecoll_is_visible(arm, bone) && (bone->flag & BONE_SELECTED)))
{
if (!(defgroup = BKE_object_defgroup_find_name(ob, bone->name))) {
defgroup = BKE_object_defgroup_add_name(ob, bone->name);
}
@ -376,7 +380,7 @@ static void add_verts_to_dgroups(ReportList *reports,
/* set selected */
if (wpmode) {
if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED)) {
if (ANIM_bonecoll_is_visible(arm, bone) && (bone->flag & BONE_SELECTED)) {
selected[j] = 1;
}
}

View File

@ -28,6 +28,8 @@
#include "ED_armature.h"
#include "ED_util.h"
#include "ANIM_bone_collections.h"
#include "armature_intern.h"
/* -------------------------------------------------------------------- */
@ -297,7 +299,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
EditBone *curBone, *ebone_mirr;
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = curBone->next) {
if (arm->layer & curBone->layer) {
if (ANIM_bonecoll_is_visible_editbone(arm, curBone)) {
if (curBone->flag & flag) {
ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr) {
@ -326,7 +328,7 @@ void armature_tag_select_mirrored(bArmature *arm)
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = curBone->next) {
if (arm->layer & curBone->layer) {
if (ANIM_bonecoll_is_visible_editbone(arm, curBone)) {
if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) {

View File

@ -50,6 +50,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
#include "ANIM_bone_collections.h"
#include "UI_interface.h"
#include "armature_intern.h"
@ -995,7 +997,7 @@ static int hide_pose_bone_fn(Object *ob, Bone *bone, void *ptr)
bArmature *arm = static_cast<bArmature *>(ob->data);
const bool hide_select = bool(POINTER_AS_INT(ptr));
int count = 0;
if (arm->layer & bone->layer) {
if (ANIM_bonecoll_is_visible(arm, bone)) {
if (((bone->flag & BONE_SELECTED) != 0) == hide_select) {
bone->flag |= BONE_HIDDEN_P;
/* only needed when 'hide_select' is true, but harmless. */
@ -1065,7 +1067,7 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
bArmature *arm = static_cast<bArmature *>(ob->data);
int count = 0;
if (arm->layer & bone->layer) {
if (ANIM_bonecoll_is_visible(arm, bone)) {
if (bone->flag & BONE_HIDDEN_P) {
if (!(bone->flag & BONE_UNSELECTABLE)) {
SET_FLAG_FROM_TEST(bone->flag, select, BONE_SELECTED);

View File

@ -46,6 +46,8 @@
#include "ED_screen.h"
#include "ED_util.h"
#include "ANIM_bone_collections.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -605,7 +607,7 @@ static void set_pose_keys(Object *ob)
if (ob->pose) {
for (chan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); chan; chan = chan->next) {
Bone *bone = chan->bone;
if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) {
if ((bone) && (bone->flag & BONE_SELECTED) && ANIM_bonecoll_is_visible(arm, bone)) {
chan->flag |= POSE_KEY;
}
else {

View File

@ -57,6 +57,7 @@ set(SRC
)
set(LIB
PRIVATE bf::animrig
bf_blenkernel
PRIVATE bf::blenlib
PRIVATE bf::dna

View File

@ -46,6 +46,8 @@
#include "ED_mesh.h"
#include "ED_object.h"
#include "ANIM_bone_collections.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@ -203,7 +205,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
segments = 1;
}
if (arm->layer & bone->layer) {
if (ANIM_bonecoll_is_visible(arm, bone)) {
if (!(defgroup = BKE_object_defgroup_find_name(ob, bone->name))) {
defgroup = BKE_object_defgroup_add_name(ob, bone->name);
}

View File

@ -61,6 +61,7 @@ set(SRC
)
set(LIB
PRIVATE bf::animrig
bf_blenkernel
PRIVATE bf::blenlib
PRIVATE bf::dna

View File

@ -89,6 +89,8 @@
#include "ED_screen.h"
#include "ED_sculpt.h"
#include "ANIM_bone_collections.h"
#include "UI_interface.h"
#include "WM_api.h"
@ -2957,7 +2959,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
Object *arm_ob = BKE_object_add(bmain, scene, view_layer, OB_ARMATURE, nullptr);
BKE_object_transform_copy(arm_ob, skin_ob);
bArmature *arm = static_cast<bArmature *>(arm_ob->data);
arm->layer = 1;
ANIM_armature_ensure_first_layer_enabled(arm);
arm_ob->dtx |= OB_DRAW_IN_FRONT;
arm->drawtype = ARM_LINE;
arm->edbo = MEM_cnew<ListBase>("edbo armature");

View File

@ -61,6 +61,8 @@
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ANIM_bone_collections.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -311,10 +313,7 @@ bool ED_object_jump_to_bone(bContext *C,
if (reveal_hidden) {
/* Unhide the bone. */
ebone->flag &= ~BONE_HIDDEN_A;
if ((arm->layer & ebone->layer) == 0) {
arm->layer |= 1U << bitscan_forward_uint(ebone->layer);
}
ANIM_armature_ensure_layer_enabled_from_ebone(arm, ebone);
}
/* Select it. */
@ -338,10 +337,7 @@ bool ED_object_jump_to_bone(bContext *C,
if (reveal_hidden) {
/* Unhide the bone. */
pchan->bone->flag &= ~BONE_HIDDEN_P;
if ((arm->layer & pchan->bone->layer) == 0) {
arm->layer |= 1U << bitscan_forward_uint(pchan->bone->layer);
}
ANIM_armature_ensure_layer_enabled_from_pchan(arm, pchan);
}
/* Select it. */

View File

@ -78,6 +78,7 @@ set(SRC
)
set(LIB
PRIVATE bf::animrig
PRIVATE bf::blenlib
PRIVATE bf::dna
bf_editor_curves

View File

@ -55,6 +55,8 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ANIM_bone_collections.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -1630,7 +1632,7 @@ static void v3d_editarmature_buts(uiLayout *layout, Object *ob)
ebone = arm->act_edbone;
if (!ebone || (ebone->layer & arm->layer) == 0) {
if (!ebone || !ANIM_bonecoll_is_visible_editbone(arm, ebone)) {
uiItemL(layout, IFACE_("Nothing selected"), ICON_NONE);
return;
}

View File

@ -58,6 +58,8 @@
#include "ED_view3d_offscreen.h"
#include "ED_viewer_path.hh"
#include "ANIM_bone_collections.h"
#include "DEG_depsgraph_query.h"
#include "GPU_batch.h"
@ -1371,7 +1373,7 @@ static void draw_selected_name(
else if (ob->mode & OB_MODE_POSE) {
if (arm->act_bone) {
if (arm->act_bone->layer & arm->layer) {
if (ANIM_bonecoll_is_visible_actbone(arm)) {
info_array[i++] = msg_sep;
info_array[i++] = arm->act_bone->name;
}
@ -1386,7 +1388,7 @@ static void draw_selected_name(
if (armobj && armobj->mode & OB_MODE_POSE) {
bArmature *arm = static_cast<bArmature *>(armobj->data);
if (arm->act_bone) {
if (arm->act_bone->layer & arm->layer) {
if (ANIM_bonecoll_is_visible_actbone(arm)) {
info_array[i++] = msg_sep;
info_array[i++] = arm->act_bone->name;
}

View File

@ -41,6 +41,8 @@
#include "ED_screen.h"
#include "ED_transverts.h"
#include "ANIM_bone_collections.h"
#include "view3d_intern.h"
static bool snap_curs_to_sel_ex(bContext *C, const int pivot_point, float r_cursor[3]);
@ -125,7 +127,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator * /*op*/)
pchan_eval = pchan_eval->next)
{
if (pchan_eval->bone->flag & BONE_SELECTED) {
if (pchan_eval->bone->layer & arm_eval->layer) {
if (ANIM_bonecoll_is_visible_pchan(arm_eval, pchan_eval)) {
if ((pchan_eval->bone->flag & BONE_CONNECTED) == 0) {
float nLoc[3];
@ -843,7 +845,7 @@ static bool snap_curs_to_sel_ex(bContext *C, const int pivot_point, float r_curs
for (pchan = static_cast<bPoseChannel *>(obact_eval->pose->chanbase.first); pchan;
pchan = pchan->next)
{
if (arm->layer & pchan->bone->layer) {
if (ANIM_bonecoll_is_visible_pchan(arm, pchan)) {
if (pchan->bone->flag & BONE_SELECTED) {
copy_v3_v3(vec, pchan->pose_head);
mul_m4_v3(obact_eval->object_to_world, vec);

View File

@ -115,6 +115,7 @@ set(SRC
)
set(LIB
PRIVATE bf::animrig
bf_blenfont
bf_blenkernel
PRIVATE bf::blenlib

View File

@ -41,6 +41,8 @@
#include "ED_armature.h"
#include "ANIM_bone_collections.h"
#include "SEQ_select.h"
#include "transform.hh"
@ -551,7 +553,7 @@ static int armature_bone_transflags_update_recursive(bArmature *arm,
bone->flag &= ~BONE_TRANSFORM;
do_next = do_it;
if (do_it) {
if (bone->layer & arm->layer) {
if (ANIM_bonecoll_is_visible(arm, bone)) {
if (bone->flag & BONE_SELECTED) {
bone->flag |= BONE_TRANSFORM;
total++;
@ -1302,7 +1304,7 @@ int getTransformOrientation_ex(const Scene *scene,
zero_v3(fallback_plane);
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
if (arm->layer & ebone->layer) {
if (ANIM_bonecoll_is_visible_editbone(arm, ebone)) {
if (ebone->flag & BONE_SELECTED) {
ED_armature_ebone_to_mat3(ebone, tmat);
add_v3_v3(normal, tmat[2]);

View File

@ -16,6 +16,8 @@
#include "ED_transform_snap_object_context.h"
#include "ANIM_bone_collections.h"
#include "transform_snap_object.hh"
using blender::float4x4;
@ -56,7 +58,7 @@ eSnapMode snapArmature(SnapObjectContext *sctx,
if (arm->edbo) {
LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
if (eBone->layer & arm->layer) {
if (ANIM_bonecoll_is_visible_editbone(arm, eBone)) {
if (eBone->flag & BONE_HIDDEN_A) {
/* Skip hidden bones. */
continue;

View File

@ -107,6 +107,7 @@ set(SRC
)
set(LIB
PRIVATE bf::animrig
PRIVATE bf::blenlib
PRIVATE bf::dna
PRIVATE bf::intern::guardedalloc

View File

@ -34,6 +34,8 @@
#include "ED_armature.h"
#include "ED_curves.hh"
#include "ANIM_bone_collections.h"
#include "ED_transverts.h" /* own include */
void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
@ -327,7 +329,7 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, const Object *obedit,
MEM_callocN(totmalloc * sizeof(TransVert), __func__));
for (ebo = static_cast<EditBone *>(arm->edbo->first); ebo; ebo = ebo->next) {
if (ebo->layer & arm->layer) {
if (ANIM_bonecoll_is_visible_editbone(arm, ebo)) {
const bool tipsel = (ebo->flag & BONE_TIPSEL) != 0;
const bool rootsel = (ebo->flag & BONE_ROOTSEL) != 0;
const bool rootok = !(ebo->parent && (ebo->flag & BONE_CONNECTED) &&

View File

@ -20,6 +20,8 @@
#include "BLI_string.h"
#include "ED_armature.h"
#include "ANIM_bone_collections.h"
#include "DEG_depsgraph.h"
#include "ArmatureImporter.h"
@ -139,9 +141,10 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
BoneExtended &be = add_bone_extended(bone, node, totchild, layer_labels, extended_bones);
int layer = be.get_bone_layers();
if (layer) {
bone->layer = layer;
ANIM_bone_set_layer_ebone(bone, layer);
}
arm->layer |= layer; /* ensure that all populated bone layers are visible after import */
/* Ensure that all populated bone layers are visible after import. */
ANIM_armature_enable_layers(arm, layer);
float *tail = be.get_tail();
int use_connect = be.get_use_connect();
@ -486,7 +489,8 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
}
ED_armature_to_edit(armature);
armature->layer = 0; /* layer is set according to imported bone set in create_bone() */
/* Layers are enabled according to imported bone set in create_bone(). */
ANIM_armature_disable_all_layers(armature);
create_bone(
nullptr, node, nullptr, node->getChildNodes().getCount(), nullptr, armature, layer_labels);

View File

@ -114,6 +114,7 @@ set(LIB
${OPENCOLLADA_LIBRARIES}
${PCRE_LIBRARIES}
${XML2_LIBRARIES}
PRIVATE bf::animrig
PRIVATE bf::blenlib
PRIVATE bf::dna
PRIVATE bf::intern::guardedalloc