26#include "RNA_prototypes.hh"
35#include "testing/testing.h"
76 U.flag &= ~USER_DEVELOPER_UI;
77 U.experimental.use_animation_baklava = 0;
86 U.flag &= ~USER_DEVELOPER_UI;
87 U.experimental.use_animation_baklava = 0;
95 memset(bone, 0,
sizeof(
Bone));
131 strip->
start = -10.0;
155 U.experimental.use_animation_baklava = 1;
167 object->empty_drawsize = 42.0;
171 {{
"empty_display_size"}},
177 ASSERT_NE(
nullptr, object->adt);
178 ASSERT_NE(
nullptr, object->adt->action);
179 Action &action =
object->adt->action->wrap();
183 ASSERT_EQ(1, action.
slots().size());
185 EXPECT_STREQ(object->id.name, slot->
name);
186 EXPECT_STREQ(object->adt->slot_name, slot->
name);
191 ASSERT_EQ(1, action.
layers().size());
193 EXPECT_TRUE(strlen(action.
layer(0)->
name) > 0);
196 ASSERT_EQ(Strip::Type::Keyframe, strip->
type());
201 ASSERT_NE(
nullptr, channel_bag);
204 EXPECT_EQ(1, channel_bag->fcurves().size());
205 const FCurve *fcurve = channel_bag->fcurve_find({
"empty_display_size", 0});
206 ASSERT_NE(
nullptr, fcurve);
207 ASSERT_NE(
nullptr, fcurve->
bezt);
214 object->empty_drawsize = 86.0;
218 {{
"empty_display_size"}},
229 object->empty_drawsize = 7.0;
233 {{
"empty_display_size"}},
250 U.experimental.use_animation_baklava = 1;
255 &armature_object_rna_pointer,
264 ASSERT_TRUE(armature_object->adt !=
nullptr);
265 ASSERT_TRUE(armature_object->adt->action !=
nullptr);
270 &armature_rna_pointer,
278 ASSERT_TRUE(armature->adt !=
nullptr);
279 ASSERT_TRUE(armature->adt->action !=
nullptr);
282 ASSERT_EQ(armature->adt->action, armature_object->adt->action);
284 Action &action = armature->adt->action->wrap();
288 ASSERT_TRUE(slot->idtype ==
ID_AR || slot->idtype ==
ID_OB);
291 U.experimental.use_animation_baklava = 0;
292 U.flag &= ~USER_DEVELOPER_UI;
298 U.experimental.use_animation_baklava = 1;
304 &material_rna_pointer,
313 ASSERT_TRUE(material->adt !=
nullptr);
314 ASSERT_TRUE(material->adt->action !=
nullptr);
326 ASSERT_TRUE(cube->adt !=
nullptr);
327 ASSERT_TRUE(cube->adt->action !=
nullptr);
330 ASSERT_NE(cube->adt->action, material->adt->action);
333 &cube_mesh_rna_pointer,
335 {{
"remesh_voxel_size"}},
342 ASSERT_TRUE(cube_mesh->adt !=
nullptr);
343 ASSERT_TRUE(cube_mesh->adt->action !=
nullptr);
346 ASSERT_EQ(cube_mesh->adt->action, cube->adt->action);
348 ASSERT_NE(cube_mesh->adt->action, material->adt->action);
350 Action &action = cube->adt->action->wrap();
355 ASSERT_EQ(material->adt->action->wrap().slot_array_num, 1);
358 ASSERT_TRUE(slot->idtype ==
ID_ME || slot->idtype ==
ID_OB);
359 ASSERT_NE(slot->idtype,
ID_MA);
362 U.experimental.use_animation_baklava = 0;
363 U.flag &= ~USER_DEVELOPER_UI;
369 U.experimental.use_animation_baklava = 1;
390 ASSERT_TRUE(cube->adt !=
nullptr);
391 ASSERT_TRUE(cube->adt->action !=
nullptr);
394 &cube_mesh_rna_pointer,
396 {{
"remesh_voxel_size"}},
403 ASSERT_TRUE(cube_mesh->adt !=
nullptr);
404 ASSERT_TRUE(cube_mesh->adt->action !=
nullptr);
407 ASSERT_NE(cube->adt->action, cube_mesh->adt->action);
410 &another_object_rna_pointer,
419 ASSERT_TRUE(another_object->
adt !=
nullptr);
420 ASSERT_TRUE(another_object->
adt->
action !=
nullptr);
424 ASSERT_NE(cube->adt->action, another_object->
adt->
action);
426 U.experimental.use_animation_baklava = 0;
427 U.flag &= ~USER_DEVELOPER_UI;
435 U.experimental.use_animation_baklava = 1;
442 {{
"rotation_euler", std::nullopt, 0}},
449 ASSERT_NE(
nullptr, object->adt);
450 ASSERT_NE(
nullptr, object->adt->action);
451 Action &action =
object->adt->action->wrap();
452 ASSERT_EQ(1, action.
slots().size());
453 ASSERT_EQ(1, action.
layers().size());
460 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"rotation_euler", 0}));
468 U.experimental.use_animation_baklava = 1;
475 {{
"rotation_euler"}},
482 ASSERT_NE(
nullptr, object->adt);
483 ASSERT_NE(
nullptr, object->adt->action);
484 Action &action =
object->adt->action->wrap();
485 ASSERT_EQ(1, action.
slots().size());
486 ASSERT_EQ(1, action.
layers().size());
493 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"rotation_euler", 0}));
494 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"rotation_euler", 1}));
495 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"rotation_euler", 2}));
503 U.experimental.use_animation_baklava = 1;
508 &armature_object->id, &RNA_PoseBone, pchan);
511 &pose_bone_rna_pointer,
513 {{
"rotation_euler", std::nullopt, 0}},
520 ASSERT_NE(
nullptr, armature_object->adt);
521 ASSERT_NE(
nullptr, armature_object->adt->action);
522 Action &action = armature_object->adt->action->wrap();
523 ASSERT_EQ(1, action.
slots().size());
524 ASSERT_EQ(1, action.
layers().size());
531 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"pose.bones[\"Bone\"].rotation_euler", 0}));
539 U.experimental.use_animation_baklava = 1;
545 &armature_object_rna_pointer,
547 {{
"pose.bones[\"Bone\"].rotation_euler", std::nullopt, 0}},
554 ASSERT_NE(
nullptr, armature_object->adt);
555 ASSERT_NE(
nullptr, armature_object->adt->action);
556 Action &action = armature_object->adt->action->wrap();
557 ASSERT_EQ(1, action.
slots().size());
558 ASSERT_EQ(1, action.
layers().size());
565 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"pose.bones[\"Bone\"].rotation_euler", 0}));
573 U.experimental.use_animation_baklava = 1;
581 {
"empty_display_size"},
583 {
"rotation_euler", std::nullopt, 0},
584 {
"rotation_euler", std::nullopt, 2},
592 ASSERT_NE(
nullptr, object->adt);
593 ASSERT_NE(
nullptr, object->adt->action);
594 Action &action =
object->adt->action->wrap();
595 ASSERT_EQ(1, action.
slots().size());
596 ASSERT_EQ(1, action.
layers().size());
603 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"empty_display_size", 0}));
604 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"location", 0}));
605 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"location", 1}));
606 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"location", 2}));
607 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"rotation_euler", 0}));
608 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"rotation_euler", 2}));
616 U.experimental.use_animation_baklava = 1;
624 {{
"empty_display_size"}},
630 ASSERT_NE(
nullptr, object->adt);
631 ASSERT_NE(
nullptr, object->adt->action);
632 Action &action =
object->adt->action->wrap();
635 ASSERT_EQ(1, action.
slots().size());
637 ASSERT_NE(
nullptr, slot_1);
638 EXPECT_STREQ(object->id.name, slot_1->
name);
639 EXPECT_STREQ(object->adt->slot_name, slot_1->
name);
643 ASSERT_EQ(1, action.
layers().size());
650 ASSERT_NE(
nullptr, channel_bag_1);
659 &armature_object_rna_pointer,
661 {{
"empty_display_size"}},
668 ASSERT_EQ(2, action.
slots().size());
670 ASSERT_NE(
nullptr, slot_2);
671 EXPECT_STREQ(armature_object->id.name, slot_2->
name);
672 EXPECT_STREQ(armature_object->adt->slot_name, slot_2->
name);
676 ASSERT_NE(
nullptr, channel_bag_2);
689 {{
"empty_display_size"}},
696 bAction *action =
object->adt->action;
697 EXPECT_TRUE(action->wrap().is_action_legacy());
698 EXPECT_FALSE(action->wrap().is_action_layered());
703 U.experimental.use_animation_baklava = 1;
718 EXPECT_TRUE(action->wrap().is_action_legacy());
719 EXPECT_FALSE(action->wrap().is_action_layered());
728 U.experimental.use_animation_baklava = 1;
736 {{
"rotation_euler"}},
747 ASSERT_NE(
nullptr, object->adt);
750 ASSERT_EQ(
nullptr, object->adt->action);
758 {
"rotation_euler", std::nullopt, 0},
759 {
"rotation_euler", std::nullopt, 2},
768 Action &action =
object->adt->action->wrap();
769 ASSERT_EQ(1, action.slots().size());
770 ASSERT_EQ(1, action.layers().size());
771 ASSERT_EQ(1, action.layer(0)->strips().size());
772 EXPECT_EQ(object->adt->slot_handle, action.slot(0)->handle);
784 {{
"rotation_euler"}},
792 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"rotation_euler", 0}));
793 EXPECT_NE(
nullptr, channel_bag->
fcurve_find({
"rotation_euler", 2}));
801 U.experimental.use_animation_baklava = 1;
806 object->rot[0] = 42.0;
807 object->rot[1] = 42.0;
808 object->rot[2] = 42.0;
812 {{
"rotation_euler"}},
825 {
"rotation_euler", std::nullopt, 0},
826 {
"rotation_euler", std::nullopt, 2},
833 ASSERT_NE(
nullptr, object->adt);
834 ASSERT_NE(
nullptr, object->adt->action);
835 Action &action =
object->adt->action->wrap();
836 ASSERT_EQ(1, action.
slots().size());
837 ASSERT_EQ(1, action.
layers().size());
843 ASSERT_EQ(2, channel_bag->
fcurves().size());
855 object->rot[0] = 86.0;
856 object->rot[1] = 86.0;
857 object->rot[2] = 86.0;
861 {{
"rotation_euler"}},
880 {{
"rotation_euler"}},
900 U.experimental.use_animation_baklava = 1;
908 {{
"rotation_euler"}},
914 ASSERT_NE(
nullptr, object->adt);
915 ASSERT_NE(
nullptr, object->adt->action);
916 Action &action =
object->adt->action->wrap();
917 ASSERT_EQ(1, action.
slots().size());
918 ASSERT_EQ(1, action.
layers().size());
924 ASSERT_EQ(3, channel_bag->
fcurves().size());
937 {{
"rotation_euler"}},
950 object->rot[0] = 123.0;
951 object->rot[2] = 123.0;
955 {{
"rotation_euler"}},
979 object->empty_drawsize = 42.0;
983 {{
"empty_display_size"}},
989 ASSERT_NE(
nullptr, object->adt);
990 ASSERT_NE(
nullptr, object->adt->action);
993 ASSERT_NE(
nullptr, fcurve);
994 ASSERT_NE(
nullptr, fcurve->
bezt);
1001 object->empty_drawsize = 86.0;
1003 &object_rna_pointer,
1005 {{
"empty_display_size"}},
1016 object->empty_drawsize = 7.0;
1018 &object_rna_pointer,
1020 {{
"empty_display_size"}},
1042 &object_rna_pointer,
1044 {{
"rotation_mode"}},
1057 &object_rna_pointer,
1059 {{
"rotation_mode"}},
1079 &object_rna_pointer,
1081 {{
"location", std::nullopt, 0}, {
"visible_shadow"}},
1090 ASSERT_NE(
nullptr, fcurve_location_x->
grp);
1095 &object->adt->action->curves,
"visible_shadow", 0);
1096 ASSERT_EQ(
nullptr, fcurve_visible_shadow->
grp);
1101 &object_rna_pointer,
1103 {{
"location", std::nullopt, 1}, {
"hide_render"}},
1112 ASSERT_NE(
nullptr, fcurve_location_y->
grp);
1115 ASSERT_NE(
nullptr, fcurve_hide_render->
grp);
1125 &object_rna_pointer,
1127 {{
"rotation_euler", std::nullopt, 0}},
1134 ASSERT_NE(
nullptr, object->adt);
1135 ASSERT_NE(
nullptr, object->adt->action);
1137 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 0));
1146 &object_rna_pointer,
1148 {{
"rotation_euler"}},
1155 ASSERT_NE(
nullptr, object->adt);
1156 ASSERT_NE(
nullptr, object->adt->action);
1158 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 0));
1159 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 1));
1160 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 2));
1169 &armature_object->id, &RNA_PoseBone, pchan);
1172 &pose_bone_rna_pointer,
1174 {{
"rotation_euler", std::nullopt, 0}},
1181 ASSERT_NE(
nullptr, armature_object->adt);
1182 ASSERT_NE(
nullptr, armature_object->adt->action);
1186 &armature_object->adt->action->curves,
"pose.bones[\"Bone\"].rotation_euler", 0));
1196 &armature_object_rna_pointer,
1198 {{
"pose.bones[\"Bone\"].rotation_euler", std::nullopt, 0}},
1205 ASSERT_NE(
nullptr, armature_object->adt);
1206 ASSERT_NE(
nullptr, armature_object->adt->action);
1210 &armature_object->adt->action->curves,
"pose.bones[\"Bone\"].rotation_euler", 0));
1221 &object_rna_pointer,
1224 {
"empty_display_size"},
1226 {
"rotation_euler", std::nullopt, 0},
1227 {
"rotation_euler", std::nullopt, 2},
1235 ASSERT_NE(
nullptr, object->adt);
1236 ASSERT_NE(
nullptr, object->adt->action);
1238 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"empty_display_size", 0));
1239 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"location", 0));
1240 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"location", 1));
1241 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"location", 2));
1242 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 0));
1243 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 2));
1253 &object_rna_pointer,
1255 {{
"rotation_euler"}},
1266 ASSERT_NE(
nullptr, object->adt);
1269 ASSERT_EQ(
nullptr, object->adt->action);
1274 &object_rna_pointer,
1277 {
"rotation_euler", std::nullopt, 0},
1278 {
"rotation_euler", std::nullopt, 2},
1288 &object_rna_pointer,
1290 {{
"rotation_euler"}},
1298 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 0));
1299 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 2));
1308 object->rot[0] = 42.0;
1309 object->rot[1] = 42.0;
1310 object->rot[2] = 42.0;
1312 &object_rna_pointer,
1314 {{
"rotation_euler"}},
1324 &object_rna_pointer,
1327 {
"rotation_euler", std::nullopt, 0},
1328 {
"rotation_euler", std::nullopt, 2},
1335 ASSERT_NE(
nullptr, object->adt);
1336 ASSERT_NE(
nullptr, object->adt->action);
1340 ASSERT_NE(
nullptr, fcurve_x);
1341 ASSERT_NE(
nullptr, fcurve_z);
1342 ASSERT_NE(
nullptr, fcurve_x->
bezt);
1343 ASSERT_NE(
nullptr, fcurve_z->
bezt);
1353 object->rot[0] = 86.0;
1354 object->rot[1] = 86.0;
1355 object->rot[2] = 86.0;
1357 &object_rna_pointer,
1359 {{
"rotation_euler"}},
1376 &object_rna_pointer,
1378 {{
"rotation_euler"}},
1400 &object_rna_pointer,
1402 {{
"rotation_euler"}},
1409 ASSERT_NE(
nullptr, object->adt);
1410 ASSERT_NE(
nullptr, object->adt->action);
1415 ASSERT_NE(
nullptr, fcurve_x);
1416 ASSERT_NE(
nullptr, fcurve_y);
1417 ASSERT_NE(
nullptr, fcurve_z);
1423 &object_rna_pointer,
1425 {{
"rotation_euler"}},
1439 object->rot[0] = 123.0;
1440 object->rot[2] = 123.0;
1442 &object_rna_pointer,
1444 {{
"rotation_euler"}},
1464 &object_with_nla_rna_pointer,
1466 {{
"location", std::nullopt, 0}},
1475 ASSERT_NE(
nullptr, fcurve);
1476 ASSERT_NE(
nullptr, fcurve->
bezt);
1496 &object_with_nla_rna_pointer,
1498 {{
"rotation_quaternion", std::nullopt, 0}},
1519 &object_with_nla_rna_pointer,
1521 {{
"rotation_quaternion", std::nullopt, 0}},
1531 bmain, nla_action,
nullptr, &id_rna_ptr, {
"rotation_quaternion", 0});
1538 &object_with_nla_rna_pointer,
1540 {{
"rotation_quaternion", std::nullopt, 0}},
1559 &object_with_nla_rna_pointer,
1561 {{
"rotation_quaternion", std::nullopt, 0}},
1571 bmain, nla_action,
nullptr, &id_rna_ptr, {
"rotation_quaternion", 0});
1579 &object_with_nla_rna_pointer,
1581 {{
"rotation_quaternion", std::nullopt, 0}},
1594 &object_with_nla_rna_pointer,
1596 {{
"rotation_quaternion", std::nullopt, 0}},
Functions and classes to work with Actions.
Functions to insert, delete or modify keyframes.
Blender kernel action and pose functionality.
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
AnimData * BKE_animdata_ensure_id(ID *id)
void BKE_pose_ensure(Main *bmain, Object *ob, bArmature *arm, bool do_id_user)
bArmature * BKE_armature_add(Main *bmain, const char *name)
FCurve * BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index)
void * BKE_id_new(Main *bmain, short type, const char *name)
Main * BKE_main_new(void)
void BKE_main_free(Main *bmain)
General operations, lookup, etc. for materials.
void BKE_object_material_assign(struct Main *bmain, struct Object *ob, struct Material *ma, short act, int assign_type)
struct Material * BKE_material_add(struct Main *bmain, const char *name)
Mesh * BKE_mesh_add(Main *bmain, const char *name)
void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *mesh)
NlaTrack * BKE_nlatrack_new_head(ListBase *nla_tracks, bool is_liboverride)
bool BKE_nla_tweakmode_enter(OwnedAnimData owned_adt)
NlaStrip * BKE_nlastack_add_strip(OwnedAnimData owned_adt, bAction *act, bool is_liboverride)
General operations, lookup, etc. for blender objects.
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define STRNCPY(dst, src)
#define ID_REFCOUNTING_USERS(id)
Object is a sort of wrapper for general info.
const Layer * layer(int64_t index) const
const Slot * slot(int64_t index) const
blender::Span< const Layer * > layers() const
bool is_action_layered() const
blender::Span< const Slot * > slots() const
Slot * slot_for_handle(slot_handle_t handle)
const FCurve * fcurve_find(FCurveDescriptor fcurve_descriptor) const
blender::Span< const FCurve * > fcurves() const
int get_count(const SingleKeyingResult result) const
blender::Span< const Strip * > strips() const
const Strip * strip(int64_t index) const
const ChannelBag * channelbag(int64_t index) const
const ChannelBag * channelbag_for_slot(const Slot &slot) const
blender::Span< const ChannelBag * > channelbags() const
const T & data(const Action &owning_action) const
PointerRNA material_rna_pointer
PointerRNA object_rna_pointer
static void TearDownTestSuite()
static void SetUpTestSuite()
PointerRNA object_with_nla_rna_pointer
PointerRNA armature_object_rna_pointer
PointerRNA cube_rna_pointer
PointerRNA cube_mesh_rna_pointer
void *(* MEM_mallocN)(size_t len, const char *str)
TEST_F(ActionIteratorsTest, iterate_all_fcurves_of_slot)
FCurve * action_fcurve_ensure(Main *bmain, bAction *act, const char group[], PointerRNA *ptr, FCurveDescriptor fcurve_descriptor)
CombinedKeyingResult insert_keyframes(Main *bmain, PointerRNA *struct_pointer, std::optional< StringRefNull > channel_group, const blender::Span< RNAPath > rna_paths, std::optional< float > scene_frame, const AnimationEvalContext &anim_eval_context, eBezTriple_KeyframeType key_type, eInsertKeyFlags insert_key_flags)
Main key-frame insertion API.
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
bool assign_action(bAction *action, ID &animated_id)
ActionSlotAssignmentResult assign_action_slot(Slot *slot_to_assign, ID &animated_id)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
PointerRNA RNA_id_pointer_create(ID *id)