26#include "RNA_prototypes.hh"
32#include "testing/testing.h"
120 strip->
start = -10.0;
185 object->empty_drawsize = 42.0;
189 {{
"empty_display_size"}},
195 ASSERT_NE(
nullptr, object->adt);
196 ASSERT_NE(
nullptr, object->adt->action);
197 Action &action =
object->adt->action->wrap();
201 ASSERT_EQ(1, action.
slots().size());
203 EXPECT_STREQ(object->id.name, slot->
identifier);
204 EXPECT_STREQ(object->adt->last_slot_identifier, slot->
identifier);
209 ASSERT_EQ(1, action.
layers().size());
211 EXPECT_TRUE(strlen(action.
layer(0)->
name) > 0);
214 ASSERT_EQ(Strip::Type::Keyframe, strip->
type());
219 ASSERT_NE(
nullptr, channelbag);
222 EXPECT_EQ(1, channelbag->fcurves().size());
223 const FCurve *fcurve = channelbag->fcurve_find({
"empty_display_size", 0});
224 ASSERT_NE(
nullptr, fcurve);
225 ASSERT_NE(
nullptr, fcurve->
bezt);
232 object->empty_drawsize = 86.0;
236 {{
"empty_display_size"}},
247 object->empty_drawsize = 7.0;
251 {{
"empty_display_size"}},
269 &armature_object_rna_pointer,
278 ASSERT_TRUE(armature_object->adt !=
nullptr);
279 ASSERT_TRUE(armature_object->adt->action !=
nullptr);
284 &armature_rna_pointer,
292 ASSERT_TRUE(armature->adt !=
nullptr);
293 ASSERT_TRUE(armature->adt->action !=
nullptr);
296 ASSERT_EQ(armature->adt->action, armature_object->adt->action);
298 Action &action = armature->adt->action->wrap();
302 ASSERT_TRUE(slot->idtype ==
ID_AR || slot->idtype ==
ID_OB);
312 &material_rna_pointer,
321 ASSERT_TRUE(material->adt !=
nullptr);
322 ASSERT_TRUE(material->adt->action !=
nullptr);
334 ASSERT_TRUE(cube->adt !=
nullptr);
335 ASSERT_TRUE(cube->adt->action !=
nullptr);
338 ASSERT_NE(cube->adt->action, material->adt->action);
341 &cube_mesh_rna_pointer,
343 {{
"remesh_voxel_size"}},
350 ASSERT_TRUE(cube_mesh->adt !=
nullptr);
351 ASSERT_TRUE(cube_mesh->adt->action !=
nullptr);
354 ASSERT_EQ(cube_mesh->adt->action, cube->adt->action);
356 ASSERT_NE(cube_mesh->adt->action, material->adt->action);
358 Action &action = cube->adt->action->wrap();
363 ASSERT_EQ(material->adt->action->wrap().slot_array_num, 1);
366 ASSERT_TRUE(slot->idtype ==
ID_ME || slot->idtype ==
ID_OB);
367 ASSERT_NE(slot->idtype,
ID_MA);
392 ASSERT_TRUE(cube->adt !=
nullptr);
393 ASSERT_TRUE(cube->adt->action !=
nullptr);
396 &cube_mesh_rna_pointer,
398 {{
"remesh_voxel_size"}},
405 ASSERT_TRUE(cube_mesh->adt !=
nullptr);
406 ASSERT_TRUE(cube_mesh->adt->action !=
nullptr);
409 ASSERT_NE(cube->adt->action, cube_mesh->adt->action);
412 &another_object_rna_pointer,
421 ASSERT_TRUE(another_object->
adt !=
nullptr);
422 ASSERT_TRUE(another_object->
adt->
action !=
nullptr);
426 ASSERT_NE(cube->adt->action, another_object->
adt->
action);
437 {{
"rotation_euler", std::nullopt, 0}},
444 ASSERT_NE(
nullptr, object->adt);
445 ASSERT_NE(
nullptr, object->adt->action);
446 Action &action =
object->adt->action->wrap();
447 ASSERT_EQ(1, action.
slots().size());
448 ASSERT_EQ(1, action.
layers().size());
455 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"rotation_euler", 0}));
466 {{
"rotation_euler"}},
473 ASSERT_NE(
nullptr, object->adt);
474 ASSERT_NE(
nullptr, object->adt->action);
475 Action &action =
object->adt->action->wrap();
476 ASSERT_EQ(1, action.
slots().size());
477 ASSERT_EQ(1, action.
layers().size());
484 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"rotation_euler", 0}));
485 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"rotation_euler", 1}));
486 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"rotation_euler", 2}));
495 &armature_object->id, &RNA_PoseBone, pchan);
498 &pose_bone_rna_pointer,
500 {{
"rotation_euler", std::nullopt, 0}},
507 ASSERT_NE(
nullptr, armature_object->adt);
508 ASSERT_NE(
nullptr, armature_object->adt->action);
509 Action &action = armature_object->adt->action->wrap();
510 ASSERT_EQ(1, action.
slots().size());
511 ASSERT_EQ(1, action.
layers().size());
518 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"pose.bones[\"Bone\"].rotation_euler", 0}));
528 &armature_object_rna_pointer,
530 {{
"pose.bones[\"Bone\"].rotation_euler", std::nullopt, 0}},
537 ASSERT_NE(
nullptr, armature_object->adt);
538 ASSERT_NE(
nullptr, armature_object->adt->action);
539 Action &action = armature_object->adt->action->wrap();
540 ASSERT_EQ(1, action.
slots().size());
541 ASSERT_EQ(1, action.
layers().size());
548 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"pose.bones[\"Bone\"].rotation_euler", 0}));
560 {
"empty_display_size"},
562 {
"rotation_euler", std::nullopt, 0},
563 {
"rotation_euler", std::nullopt, 2},
571 ASSERT_NE(
nullptr, object->adt);
572 ASSERT_NE(
nullptr, object->adt->action);
573 Action &action =
object->adt->action->wrap();
574 ASSERT_EQ(1, action.
slots().size());
575 ASSERT_EQ(1, action.
layers().size());
582 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"empty_display_size", 0}));
583 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"location", 0}));
584 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"location", 1}));
585 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"location", 2}));
586 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"rotation_euler", 0}));
587 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"rotation_euler", 2}));
599 {{
"empty_display_size"}},
605 ASSERT_NE(
nullptr, object->adt);
606 ASSERT_NE(
nullptr, object->adt->action);
607 Action &action =
object->adt->action->wrap();
610 ASSERT_EQ(1, action.
slots().size());
612 ASSERT_NE(
nullptr, slot_1);
613 EXPECT_STREQ(object->id.name, slot_1->
identifier);
614 EXPECT_STREQ(object->adt->last_slot_identifier, slot_1->
identifier);
618 ASSERT_EQ(1, action.
layers().size());
625 ASSERT_NE(
nullptr, channelbag_1);
634 &armature_object_rna_pointer,
636 {{
"empty_display_size"}},
643 ASSERT_EQ(2, action.
slots().size());
645 ASSERT_NE(
nullptr, slot_2);
646 EXPECT_STREQ(armature_object->id.name, slot_2->
identifier);
647 EXPECT_STREQ(armature_object->adt->last_slot_identifier, slot_2->
identifier);
651 ASSERT_NE(
nullptr, channelbag_2);
667 bAction *action =
object->adt->action;
668 EXPECT_TRUE(action->wrap().is_action_legacy());
669 EXPECT_FALSE(action->wrap().is_action_layered());
685 EXPECT_TRUE(action->wrap().is_action_legacy());
686 EXPECT_FALSE(action->wrap().is_action_layered());
699 {{
"rotation_euler"}},
710 ASSERT_NE(
nullptr, object->adt);
713 ASSERT_EQ(
nullptr, object->adt->action);
721 {
"rotation_euler", std::nullopt, 0},
722 {
"rotation_euler", std::nullopt, 2},
731 Action &action =
object->adt->action->wrap();
732 ASSERT_EQ(1, action.slots().size());
733 ASSERT_EQ(1, action.layers().size());
734 ASSERT_EQ(1, action.layer(0)->strips().size());
735 EXPECT_EQ(object->adt->slot_handle, action.slot(0)->handle);
747 {{
"rotation_euler"}},
755 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"rotation_euler", 0}));
756 EXPECT_NE(
nullptr, channelbag->
fcurve_find({
"rotation_euler", 2}));
765 object->rot[0] = 42.0;
766 object->rot[1] = 42.0;
767 object->rot[2] = 42.0;
771 {{
"rotation_euler"}},
784 {
"rotation_euler", std::nullopt, 0},
785 {
"rotation_euler", std::nullopt, 2},
792 ASSERT_NE(
nullptr, object->adt);
793 ASSERT_NE(
nullptr, object->adt->action);
794 Action &action =
object->adt->action->wrap();
795 ASSERT_EQ(1, action.
slots().size());
796 ASSERT_EQ(1, action.
layers().size());
802 ASSERT_EQ(2, channelbag->
fcurves().size());
814 object->rot[0] = 86.0;
815 object->rot[1] = 86.0;
816 object->rot[2] = 86.0;
820 {{
"rotation_euler"}},
839 {{
"rotation_euler"}},
863 {{
"rotation_euler"}},
869 ASSERT_NE(
nullptr, object->adt);
870 ASSERT_NE(
nullptr, object->adt->action);
871 Action &action =
object->adt->action->wrap();
872 ASSERT_EQ(1, action.
slots().size());
873 ASSERT_EQ(1, action.
layers().size());
879 ASSERT_EQ(3, channelbag->
fcurves().size());
892 {{
"rotation_euler"}},
905 object->rot[0] = 123.0;
906 object->rot[2] = 123.0;
910 {{
"rotation_euler"}},
934 object->empty_drawsize = 42.0;
935 ensure_legacy_action_assigned(object->id);
939 {{
"empty_display_size"}},
945 ASSERT_NE(
nullptr, object->adt);
946 ASSERT_NE(
nullptr, object->adt->action);
949 ASSERT_NE(
nullptr, fcurve);
950 ASSERT_NE(
nullptr, fcurve->
bezt);
957 object->empty_drawsize = 86.0;
961 {{
"empty_display_size"}},
972 object->empty_drawsize = 7.0;
976 {{
"empty_display_size"}},
997 ensure_legacy_action_assigned(object->id);
1001 {{
"rotation_mode"}},
1014 &object_rna_pointer,
1016 {{
"rotation_mode"}},
1034 ensure_legacy_action_assigned(object->id);
1037 &object_rna_pointer,
1039 {{
"location", std::nullopt, 0}, {
"visible_shadow"}},
1048 ASSERT_NE(
nullptr, fcurve_location_x->
grp);
1053 &object->adt->action->curves,
"visible_shadow", 0);
1054 ASSERT_EQ(
nullptr, fcurve_visible_shadow->
grp);
1059 &object_rna_pointer,
1061 {{
"location", std::nullopt, 1}, {
"hide_render"}},
1070 ASSERT_NE(
nullptr, fcurve_location_y->
grp);
1073 ASSERT_NE(
nullptr, fcurve_hide_render->
grp);
1082 ensure_legacy_action_assigned(object->id);
1084 &object_rna_pointer,
1086 {{
"rotation_euler", std::nullopt, 0}},
1093 ASSERT_NE(
nullptr, object->adt);
1094 ASSERT_NE(
nullptr, object->adt->action);
1096 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 0));
1104 ensure_legacy_action_assigned(object->id);
1106 &object_rna_pointer,
1108 {{
"rotation_euler"}},
1115 ASSERT_NE(
nullptr, object->adt);
1116 ASSERT_NE(
nullptr, object->adt->action);
1118 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 0));
1119 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 1));
1120 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 2));
1129 &armature_object->id, &RNA_PoseBone, pchan);
1131 ensure_legacy_action_assigned(armature_object->id);
1133 &pose_bone_rna_pointer,
1135 {{
"rotation_euler", std::nullopt, 0}},
1142 ASSERT_NE(
nullptr, armature_object->adt);
1143 ASSERT_NE(
nullptr, armature_object->adt->action);
1147 &armature_object->adt->action->curves,
"pose.bones[\"Bone\"].rotation_euler", 0));
1155 ensure_legacy_action_assigned(armature_object->id);
1158 &armature_object_rna_pointer,
1160 {{
"pose.bones[\"Bone\"].rotation_euler", std::nullopt, 0}},
1167 ASSERT_NE(
nullptr, armature_object->adt);
1168 ASSERT_NE(
nullptr, armature_object->adt->action);
1172 &armature_object->adt->action->curves,
"pose.bones[\"Bone\"].rotation_euler", 0));
1180 ensure_legacy_action_assigned(object->id);
1184 &object_rna_pointer,
1187 {
"empty_display_size"},
1189 {
"rotation_euler", std::nullopt, 0},
1190 {
"rotation_euler", std::nullopt, 2},
1198 ASSERT_NE(
nullptr, object->adt);
1199 ASSERT_NE(
nullptr, object->adt->action);
1201 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"empty_display_size", 0));
1202 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"location", 0));
1203 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"location", 1));
1204 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"location", 2));
1205 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 0));
1206 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 2));
1216 &object_rna_pointer,
1218 {{
"rotation_euler"}},
1229 ASSERT_NE(
nullptr, object->adt);
1232 ASSERT_EQ(
nullptr, object->adt->action);
1236 ensure_legacy_action_assigned(object->id);
1241 &object_rna_pointer,
1244 {
"rotation_euler", std::nullopt, 0},
1245 {
"rotation_euler", std::nullopt, 2},
1255 &object_rna_pointer,
1257 {{
"rotation_euler"}},
1265 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 0));
1266 EXPECT_NE(
nullptr,
BKE_fcurve_find(&object->adt->action->curves,
"rotation_euler", 2));
1275 object->rot[0] = 42.0;
1276 object->rot[1] = 42.0;
1277 object->rot[2] = 42.0;
1278 ensure_legacy_action_assigned(object->id);
1280 &object_rna_pointer,
1282 {{
"rotation_euler"}},
1292 &object_rna_pointer,
1295 {
"rotation_euler", std::nullopt, 0},
1296 {
"rotation_euler", std::nullopt, 2},
1303 ASSERT_NE(
nullptr, object->adt);
1304 ASSERT_NE(
nullptr, object->adt->action);
1308 ASSERT_NE(
nullptr, fcurve_x);
1309 ASSERT_NE(
nullptr, fcurve_z);
1310 ASSERT_NE(
nullptr, fcurve_x->
bezt);
1311 ASSERT_NE(
nullptr, fcurve_z->
bezt);
1321 object->rot[0] = 86.0;
1322 object->rot[1] = 86.0;
1323 object->rot[2] = 86.0;
1325 &object_rna_pointer,
1327 {{
"rotation_euler"}},
1344 &object_rna_pointer,
1346 {{
"rotation_euler"}},
1367 ensure_legacy_action_assigned(object->id);
1369 &object_rna_pointer,
1371 {{
"rotation_euler"}},
1378 ASSERT_NE(
nullptr, object->adt);
1379 ASSERT_NE(
nullptr, object->adt->action);
1384 ASSERT_NE(
nullptr, fcurve_x);
1385 ASSERT_NE(
nullptr, fcurve_y);
1386 ASSERT_NE(
nullptr, fcurve_z);
1392 &object_rna_pointer,
1394 {{
"rotation_euler"}},
1408 object->rot[0] = 123.0;
1409 object->rot[2] = 123.0;
1411 &object_rna_pointer,
1413 {{
"rotation_euler"}},
1433 &object_with_nla_rna_pointer,
1435 {{
"location", std::nullopt, 0}},
1444 ASSERT_NE(
nullptr, fcurve);
1445 ASSERT_NE(
nullptr, fcurve->
bezt);
1465 &object_with_nla_rna_pointer,
1467 {{
"rotation_quaternion", std::nullopt, 0}},
1488 &object_with_nla_rna_pointer,
1490 {{
"rotation_quaternion", std::nullopt, 0}},
1500 bmain, nla_action,
nullptr, &id_rna_ptr, {
"rotation_quaternion", 0});
1507 &object_with_nla_rna_pointer,
1509 {{
"rotation_quaternion", std::nullopt, 0}},
1528 &object_with_nla_rna_pointer,
1530 {{
"rotation_quaternion", std::nullopt, 0}},
1540 bmain, nla_action,
nullptr, &id_rna_ptr, {
"rotation_quaternion", 0});
1548 &object_with_nla_rna_pointer,
1550 {{
"rotation_quaternion", std::nullopt, 0}},
1563 &object_with_nla_rna_pointer,
1565 {{
"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)
AnimData * BKE_animdata_from_id(const 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)
void BKE_main_free(Main *bmain)
General operations, lookup, etc. for materials.
Material * BKE_material_add(Main *bmain, const char *name)
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
Mesh * BKE_mesh_add(Main *bmain, const char *name)
void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *mesh)
NlaStrip * BKE_nlastack_add_strip(OwnedAnimData owned_adt, const bool is_liboverride)
NlaTrack * BKE_nlatrack_new_head(ListBase *nla_tracks, bool is_liboverride)
bool BKE_nla_tweakmode_enter(OwnedAnimData owned_adt)
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(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * STRNCPY(char(&dst)[N], const char *src)
#define UNUSED_VARS_NDEBUG(...)
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(const 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_for_slot(const Slot &slot) const
blender::Span< const Channelbag * > channelbags() const
const Channelbag * channelbag(int64_t index) const
const T & data(const Action &owning_action) const
PointerRNA material_rna_pointer
PointerRNA object_rna_pointer
void ensure_legacy_action_assigned(ID &id)
static void TearDownTestSuite()
static void SetUpTestSuite()
PointerRNA object_with_nla_rna_pointer
PointerRNA armature_object_rna_pointer
PointerRNA cube_rna_pointer
void ensure_action_is_legacy(bAction &action)
PointerRNA cube_mesh_rna_pointer
#define ID_REFCOUNTING_USERS(id)
void * MEM_callocN(size_t len, const char *str)
TEST_F(ActionIteratorsTest, iterate_all_fcurves_of_slot)
Action & action_add(Main &bmain, StringRefNull name)
FCurve * action_fcurve_ensure_legacy(Main *bmain, bAction *act, const char group[], PointerRNA *ptr, const 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_discrete(ID *id, StructRNA *type, void *data)
PointerRNA RNA_id_pointer_create(ID *id)