28#include "testing/testing.h"
32TEST(action, low_level_initialisation)
37 <<
"bAction::last_slot_handle should not be initialised to 0";
81 Layer &layer = action->layer_add(
"layer name");
87 <<
"Expected newly added layer to become the active layer.";
88 ASSERT_EQ(0, layer.
strips().size()) <<
"Expected newly added layer to have no strip.";
96 action->idroot =
ID_CA;
97 ASSERT_NE(0, action->idroot) <<
"action->idroot should not be zero at the start of this test.";
99 action->layer_add(
"layer name");
102 <<
"action->idroot should get reset when the Action becomes layered.";
107 Layer &layer0 = action->layer_add(
"Test Læür nul");
108 Layer &layer1 = action->layer_add(
"Test Læür één");
109 Layer &layer2 = action->layer_add(
"Test Læür twee");
113 layer0.
strip_add(*action, Strip::Type::Keyframe);
114 layer1.
strip_add(*action, Strip::Type::Keyframe);
115 layer2.
strip_add(*action, Strip::Type::Keyframe);
120 EXPECT_FALSE(action->layer_remove(other_layer))
121 <<
"Removing a layer not owned by the Action should be gracefully rejected";
125 EXPECT_TRUE(action->layer_remove(layer1));
127 EXPECT_STREQ(layer0.
name, action->layer(0)->name);
128 EXPECT_STREQ(layer2.
name, action->layer(1)->name);
130 EXPECT_TRUE(action->layer_remove(layer2));
132 EXPECT_STREQ(layer0.
name, action->layer(0)->name);
134 EXPECT_TRUE(action->layer_remove(layer0));
140 Layer &layer = action->layer_add(
"Test Læür");
143 ASSERT_EQ(1, layer.
strips().size());
146 constexpr float inf = std::numeric_limits<float>::infinity();
151 Strip &another_strip = layer.
strip_add(*action, Strip::Type::Keyframe);
152 ASSERT_EQ(2, layer.
strips().size());
161 Slot &slot = action->slot_add();
163 bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
165 bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
170 Layer &layer = action->layer_add(
"Test Læür");
182 Slot &slot = action->slot_add();
183 strip_data0.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
184 strip_data1.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 48.0f}, settings);
185 strip_data2.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 49.0f}, settings);
186 strip_data3.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 50.0f}, settings);
188 EXPECT_EQ(4, action->strip_keyframe_data().size());
195 EXPECT_EQ(3, action->strip_keyframe_data().size());
208 EXPECT_EQ(2, action->strip_keyframe_data().size());
218 EXPECT_EQ(1, action->strip_keyframe_data().size());
225 EXPECT_EQ(0, action->strip_keyframe_data().size());
229 Layer &other_layer = action->layer_add(
"Another Layer");
230 Strip &other_strip = other_layer.
strip_add(*action, Strip::Type::Keyframe);
233 <<
"Removing a strip not owned by the layer should be gracefully rejected";
243 Layer &layer = action->layer_add(
"Test Læür");
256 Slot &slot = action->slot_add();
257 strip_data_0_1.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
258 strip_data_2.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 48.0f}, settings);
260 EXPECT_EQ(3, action->strip_keyframe_data().size());
268 EXPECT_EQ(3, action->strip_keyframe_data().size());
279 EXPECT_EQ(2, action->strip_keyframe_data().size());
289 Slot &slot = action->slot_add();
298 Slot &slot = action->slot_add_for_id(cube->id);
311 Slot &slot = action->slot_add_for_id(cube->id);
316 <<
"The last-assigned slot name should be reused";
318 <<
"The ID type encoded in the slot identifier should be correct";
328 action->idroot =
ID_CA;
329 ASSERT_NE(0, action->idroot) <<
"action->idroot should not be zero at the start of this test.";
334 <<
"action->idroot should get reset when the Action becomes layered.";
339 Slot &slot_cube = action->slot_add();
340 Slot &slot_suzanne = action->slot_add();
354 Slot &slot = action->slot_add();
358 EXPECT_TRUE(action->slot_remove(slot));
360 <<
"Removing a slot should not change the last-used slot handle.";
366 EXPECT_FALSE(action->slot_remove(slot));
370 Slot &slot = action->slot_add();
376 action->layer_keystrip_ensure();
382 EXPECT_TRUE(action->slot_remove(slot));
384 <<
"Removing a slot should not change the last-used slot handle.";
393 Slot &slot1 = action->slot_add();
394 Slot &slot2 = action->slot_add();
395 Slot &slot3 = action->slot_add();
405 action->layer_keystrip_ensure();
412 EXPECT_TRUE(action->slot_remove(slot2));
417 EXPECT_EQ(action->slot_for_handle(slot2_handle),
nullptr);
427 Slot &slot = action->slot_add_for_id(cube->id);
431 ASSERT_EQ(cube->adt->slot_handle, slot.
handle);
434 ASSERT_TRUE(action->slot_remove(slot));
435 EXPECT_EQ(cube->adt->slot_handle, removed_slot_handle);
439 action->last_slot_handle = 3;
440 Slot &slot1 = action->slot_add();
441 ASSERT_EQ(4, slot1.
handle);
442 ASSERT_EQ(4, action->last_slot_handle);
443 ASSERT_TRUE(action->slot_remove(slot1));
445 Slot &slot2 = action->slot_add();
453 Slot &slot_a = action->slot_add_for_id_type(
ID_ME);
454 Slot &slot_b = action->slot_add_for_id_type(
ID_CA);
455 Slot &slot_cube = action->slot_add_for_id(cube->id);
456 Slot &slot_suzanne = action->slot_add_for_id(suzanne->id);
466 ASSERT_EQ(action->slot(0)->handle, handle_a);
467 ASSERT_EQ(action->slot(0)->idtype_string(),
"ME");
468 ASSERT_EQ(action->slot(1)->handle, handle_b);
469 ASSERT_EQ(action->slot(1)->idtype_string(),
"CA");
470 ASSERT_EQ(action->slot(2)->handle, handle_cube);
471 ASSERT_EQ(action->slot(2)->idtype_string(),
"OB");
472 ASSERT_EQ(action->slot(2)->users(*bmain)[0], &cube->id);
473 ASSERT_EQ(action->slot(3)->handle, handle_suzanne);
474 ASSERT_EQ(action->slot(3)->idtype_string(),
"OB");
475 ASSERT_EQ(action->slot(3)->users(*bmain)[0], &suzanne->id);
478 action->slot_move_to_index(slot_b, 1);
479 EXPECT_EQ(action->slot(0)->handle, handle_a);
480 EXPECT_EQ(action->slot(0)->idtype_string(),
"ME");
481 EXPECT_EQ(action->slot(1)->handle, handle_b);
482 EXPECT_EQ(action->slot(1)->idtype_string(),
"CA");
483 EXPECT_EQ(action->slot(2)->handle, handle_cube);
484 EXPECT_EQ(action->slot(2)->idtype_string(),
"OB");
485 EXPECT_EQ(action->slot(2)->users(*bmain)[0], &cube->id);
486 EXPECT_EQ(action->slot(3)->handle, handle_suzanne);
487 EXPECT_EQ(action->slot(3)->idtype_string(),
"OB");
488 EXPECT_EQ(action->slot(3)->users(*bmain)[0], &suzanne->id);
492 action->slot_move_to_index(slot_a, 2);
493 EXPECT_EQ(action->slot(0)->handle, handle_b);
494 EXPECT_EQ(action->slot(0)->idtype_string(),
"CA");
495 EXPECT_EQ(action->slot(1)->handle, handle_cube);
496 EXPECT_EQ(action->slot(1)->idtype_string(),
"OB");
497 EXPECT_EQ(action->slot(1)->users(*bmain)[0], &cube->id);
498 EXPECT_EQ(action->slot(2)->handle, handle_a);
499 EXPECT_EQ(action->slot(2)->idtype_string(),
"ME");
500 EXPECT_EQ(action->slot(3)->handle, handle_suzanne);
501 EXPECT_EQ(action->slot(3)->idtype_string(),
"OB");
502 EXPECT_EQ(action->slot(3)->users(*bmain)[0], &suzanne->id);
504 action->slot_move_to_index(slot_suzanne, 1);
505 EXPECT_EQ(action->slot(0)->handle, handle_b);
506 EXPECT_EQ(action->slot(0)->idtype_string(),
"CA");
507 EXPECT_EQ(action->slot(1)->handle, handle_suzanne);
508 EXPECT_EQ(action->slot(1)->idtype_string(),
"OB");
509 EXPECT_EQ(action->slot(1)->users(*bmain)[0], &suzanne->id);
510 EXPECT_EQ(action->slot(2)->handle, handle_cube);
511 EXPECT_EQ(action->slot(2)->idtype_string(),
"OB");
512 EXPECT_EQ(action->slot(2)->users(*bmain)[0], &cube->id);
513 EXPECT_EQ(action->slot(3)->handle, handle_a);
514 EXPECT_EQ(action->slot(3)->idtype_string(),
"ME");
516 action->slot_move_to_index(slot_cube, 3);
517 EXPECT_EQ(action->slot(0)->handle, handle_b);
518 EXPECT_EQ(action->slot(0)->idtype_string(),
"CA");
519 EXPECT_EQ(action->slot(1)->handle, handle_suzanne);
520 EXPECT_EQ(action->slot(1)->idtype_string(),
"OB");
521 EXPECT_EQ(action->slot(1)->users(*bmain)[0], &suzanne->id);
522 EXPECT_EQ(action->slot(2)->handle, handle_a);
523 EXPECT_EQ(action->slot(2)->idtype_string(),
"ME");
524 EXPECT_EQ(action->slot(3)->handle, handle_cube);
525 EXPECT_EQ(action->slot(3)->idtype_string(),
"OB");
526 EXPECT_EQ(action->slot(3)->users(*bmain)[0], &cube->id);
528 action->slot_move_to_index(slot_suzanne, 0);
529 EXPECT_EQ(action->slot(0)->handle, handle_suzanne);
530 EXPECT_EQ(action->slot(0)->idtype_string(),
"OB");
531 EXPECT_EQ(action->slot(0)->users(*bmain)[0], &suzanne->id);
532 EXPECT_EQ(action->slot(1)->handle, handle_b);
533 EXPECT_EQ(action->slot(1)->idtype_string(),
"CA");
534 EXPECT_EQ(action->slot(2)->handle, handle_a);
535 EXPECT_EQ(action->slot(2)->idtype_string(),
"ME");
536 EXPECT_EQ(action->slot(3)->handle, handle_cube);
537 EXPECT_EQ(action->slot(3)->idtype_string(),
"OB");
538 EXPECT_EQ(action->slot(3)->users(*bmain)[0], &cube->id);
544 Slot &slot_cube = action->slot_add();
545 ASSERT_NE(
nullptr, slot_cube.
runtime);
551 EXPECT_STREQ(slot_cube.
identifier, cube->adt->last_slot_identifier)
552 <<
"The slot identifier should be copied to the adt";
555 <<
"Expecting Cube to be registered as animated by its slot.";
561 EXPECT_STREQ(slot_cube.
identifier, cube->adt->last_slot_identifier)
562 <<
"The slot identifier should be copied to the adt";
565 <<
"Expecting Suzanne to be registered as animated by the Cube slot.";
573 <<
"Expecting Cube to no longer be registered as user of its old slot.";
575 <<
"Expecting Cube to be registered as user of its new slot.";
581 const int user_count_pre = action->id.us;
582 Slot &slot_cube_2 = action->slot_add();
585 ASSERT_EQ(action->id.us, user_count_pre)
586 <<
"Assigning to a different slot of the same Action should _not_ change the user "
587 "count of that Action";
589 <<
"Expecting Cube to no longer be registered as animated by the Cube slot.";
591 <<
"Expecting Cube to be registered as animated by the 'cube_2' slot.";
595 const int user_count_pre = action->id.us;
597 ASSERT_EQ(action->id.us, user_count_pre - 1)
598 <<
"Unassigning an Action should lower its user count";
600 ASSERT_EQ(2, action->slots().size()) <<
"Expecting the Action to have two Slots";
601 EXPECT_FALSE(action->slot(0)->users(*bmain).contains(&cube->id))
602 <<
"Expecting Cube to no longer be registered as animated by any slot.";
603 EXPECT_FALSE(action->slot(1)->users(*bmain).contains(&cube->id))
604 <<
"Expecting Cube to no longer be registered as animated by any slot.";
609 Slot &another_slot_cube = action->slot_add();
613 EXPECT_STREQ(
"OBSlot.002", another_slot_cube.
identifier) <<
"The slot should be uniquely named";
614 EXPECT_STREQ(
"OBSlot.002", cube->adt->last_slot_identifier)
615 <<
"The slot identifier should be copied to the adt";
616 EXPECT_TRUE(another_slot_cube.
users(*bmain).
contains(&cube->id))
617 <<
"Expecting Cube to be registered as animated by the 'another_slot_cube' slot.";
623 <<
"Mesh should not be animatable by an Object slot";
625 <<
"Expecting Mesh to not be registered as animated by the 'slot_cube' slot.";
631 Slot &slot_cube = action->slot_add();
635 EXPECT_STREQ(slot_cube.
identifier, cube->adt->last_slot_identifier)
636 <<
"The slot identifier should be copied to the adt";
638 action->slot_identifier_define(slot_cube,
"OBNew Slot Name");
639 EXPECT_STREQ(
"OBNew Slot Name", slot_cube.
identifier);
645 action->slot_identifier_propagate(*bmain, slot_cube);
646 EXPECT_STREQ(
"OBNew Slot Name", cube->adt->last_slot_identifier);
649 action->slot_display_name_set(*bmain, slot_cube,
"Slot's New Display Name");
650 EXPECT_STREQ(
"OBSlot's New Display Name", slot_cube.
identifier);
651 EXPECT_STREQ(
"OBSlot's New Display Name", cube->adt->last_slot_identifier);
656 action->slot_identifier_define(slot_cube,
"OBEven Newer Name");
658 EXPECT_STREQ(
"OBEven Newer Name", cube->adt->last_slot_identifier);
663 class AccessibleSlot :
public Slot {
665 void identifier_ensure_prefix()
671 Slot &raw_slot = action->slot_add();
672 AccessibleSlot &slot =
static_cast<AccessibleSlot &
>(raw_slot);
673 ASSERT_STREQ(
"XXSlot", slot.identifier);
674 ASSERT_EQ(0, slot.idtype);
677 slot.identifier_ensure_prefix();
678 EXPECT_STREQ(
"XXSlot", slot.identifier);
682 slot.identifier_ensure_prefix();
683 EXPECT_STREQ(
"CASlot", slot.identifier);
686 action->slot_identifier_define(slot,
"CANewName");
688 slot.identifier_ensure_prefix();
689 EXPECT_STREQ(
"MENewName", slot.identifier);
693 slot.identifier_ensure_prefix();
694 EXPECT_STREQ(
"XXNewName", slot.identifier);
699 Slot &slot = action->slot_add();
714 Slot &slot1 = action->slot_add();
715 Slot &slot2 = action->slot_add();
717 action->slot_identifier_define(slot1,
"New Slot Name");
718 action->slot_identifier_define(slot2,
"New Slot Name");
719 EXPECT_STREQ(
"New Slot Name", slot1.
identifier);
720 EXPECT_STREQ(
"New Slot Name.001", slot2.
identifier);
732 Slot &slot = action->slot_add();
745 Slot &other_slot = action->slot_add();
774 Slot &ob_slot = action->slot_add_for_id_type(
ID_OB);
775 action->slot_identifier_define(ob_slot,
"OBSlot");
782 Slot &xx_slot = action->slot_add();
783 action->slot_identifier_define(xx_slot,
"XXSlot");
798 action->slot_remove(ob_slot);
807 EXPECT_EQ(
nullptr, action->slot_active_get());
810 EXPECT_EQ(
nullptr, action->slot_active_get());
815 EXPECT_EQ(
nullptr, action->slot_active_get())
816 <<
"Adding the first slot should not change what is the active slot.";
818 action->slot_active_set(slot_cube.
handle);
819 EXPECT_EQ(&slot_cube, action->slot_active_get())
820 <<
"It should be possible to activate the only available slot";
824 EXPECT_EQ(
nullptr, action->slot_active_get())
825 <<
"It should be possible to de-activate the only available slot";
831 Slot &slot_cube = *action->slot(0);
832 action->slot_active_set(slot_cube.
handle);
836 EXPECT_EQ(&slot_cube, action->slot_active_get())
837 <<
"Adding a subsequent slot should not change what is the active slot.";
840 action->slot_active_set(slot_suz.
handle);
841 EXPECT_EQ(&slot_suz, action->slot_active_get());
846 action->slot_active_set(slot_bob.
handle);
847 EXPECT_EQ(&slot_bob, action->slot_active_get());
853 EXPECT_EQ(
nullptr, action->slot_active_get());
867 ASSERT_NE(
nullptr, chosen_slot);
869 EXPECT_STREQ(
"OBKüüübus", chosen_slot->
identifier);
877 ASSERT_NE(
nullptr, chosen_slot);
878 EXPECT_EQ(&slot_for_id, chosen_slot) <<
"The expected slot should be chosen";
879 EXPECT_EQ(cube->adt->action, &action) <<
"The Action should be assigned";
880 EXPECT_EQ(cube->adt->slot_handle, chosen_slot->
handle) <<
"The chosen slot should be assigned";
890 ASSERT_NE(
nullptr, chosen_slot);
891 EXPECT_NE(&slot_for_id, chosen_slot) <<
"A new slot should be chosen";
892 EXPECT_STREQ(
"OBKüüübus.001", chosen_slot->
identifier);
893 EXPECT_EQ(cube->adt->action, &action) <<
"The Action should be assigned";
894 EXPECT_EQ(cube->adt->slot_handle, chosen_slot->
handle) <<
"The chosen slot should be assigned";
910 ASSERT_NE(
nullptr, chosen_slot);
911 EXPECT_EQ(&untyped_slot, chosen_slot) <<
"The untyped slot should be chosen";
912 EXPECT_TRUE(untyped_slot.
has_idtype()) <<
"Slot should have gotten an ID type";
913 EXPECT_STREQ(
"OBJust A Slot", untyped_slot.
identifier);
914 EXPECT_EQ(cube->adt->action, &action) <<
"The Action should be assigned";
915 EXPECT_EQ(cube->adt->slot_handle, chosen_slot->
handle) <<
"The chosen slot should be assigned";
921 constexpr float inf = std::numeric_limits<float>::infinity();
922 Layer &layer0 = action->layer_add(
"Test Læür nul");
933 <<
"Strip should not contain frames before its first frame";
934 EXPECT_TRUE(strip.
contains_frame(1.0f)) <<
"Strip should contain its first frame.";
935 EXPECT_TRUE(strip.
contains_frame(2.0f)) <<
"Strip should contain its last frame.";
937 <<
"Strip should not contain frames after its last frame";
946 strip.
resize(1.0f, 172800.0f);
947 EXPECT_TRUE(strip.
contains_frame(172800.0f)) <<
"Strip should contain its last frame.";
949 <<
"Strip should not contain frames after its last frame";
959 Slot &slot = action->slot_add();
961 Layer &layer = action->layer_add(
"Kübus layer");
968 bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
970 <<
"Expected keyframe insertion to be successful";
979 bmain, slot, {
"location", 0}, {5.0f, 47.1f}, settings);
981 ASSERT_EQ(1, channels->
fcurves().size()) <<
"Expect insertion with the same (slot/rna "
982 "path/array index) tuple to go into the same FCurve";
984 <<
"Expect insertion with the same (slot/rna path/array index) tuple to go into the same "
992 bmain, slot, {
"rotation_quaternion", 0}, {1.0f, 0.25f}, settings);
994 ASSERT_EQ(2, channels->
fcurves().size()) <<
"Expected a second FCurve to be created.";
1002 <<
"nullptr Actions should be assignable to any type.";
1004 <<
"nullptr Actions should be assignable to any type.";
1007 <<
"Empty Actions should be assignable to any type.";
1009 <<
"Empty Actions should be assignable to any type.";
1014 ASSERT_FALSE(action->is_empty());
1015 ASSERT_TRUE(action->is_action_legacy());
1016 ASSERT_EQ(0, action->idroot);
1019 <<
"Legacy Actions with idroot=0 should be assignable to any type.";
1021 <<
"Legacy Actions with idroot=0 should be assignable to any type.";
1024 action->idroot =
ID_CA;
1026 <<
"Legacy Actions with idroot=ID_CA should NOT be assignable to ID_OB.";
1028 <<
"Legacy Actions with idroot=CA should be assignable to ID_CA.";
1032 action->layer_add(
"layer");
1033 ASSERT_EQ(0, action->idroot) <<
"Adding a layer should clear the idroot.";
1036 <<
"Layered Actions should be assignable to any type.";
1038 <<
"Layered Actions should be assignable to any type.";
1046 EXPECT_TRUE(action->is_empty());
1058 EXPECT_FALSE(fcurve ==
nullptr);
1063 EXPECT_TRUE(action->is_action_legacy());
1074 Slot &slot = action->slot_add();
1077 EXPECT_TRUE(action->is_action_layered());
1101 EXPECT_TRUE(action->is_empty());
1103 bmain, action,
"Test",
nullptr, {
"location", 0});
1105 bmain, action,
"Test",
nullptr, {
"location", 1});
1116 ASSERT_TRUE(converted != action);
1117 EXPECT_STREQ(converted->
id.
name,
"ACACÄnimåtië_layered");
1130 ASSERT_STREQ(group->
name,
"Test");
1136 bmain,
"name_for_an_action_that_is_exactly_64_chars_which_is_MAX_ID_NAME");
1141 EXPECT_STREQ(converted->
id.
name,
1142 "ACname_for_an_action_that_is_exactly_64_chars_which_is_MA_layered");
1147 EXPECT_TRUE(action->is_empty());
1155 ASSERT_NE(rename_group,
nullptr);
1156 ASSERT_STREQ(rename_group->name,
"Test_Rename");
1169 EXPECT_STREQ(test_group->
name,
"Test");
1173 EXPECT_STREQ(test_two_group->
name,
"Test_Two");
1178 EXPECT_STREQ(test_three_group->
name,
"Test_Three");
1183 EXPECT_STREQ(test_rename_group->
name,
"Test.001");
1187 ASSERT_NE(converted, action);
1192 ASSERT_TRUE(action->is_empty());
1194 ASSERT_TRUE(converted != action);
1202 EXPECT_TRUE(action->is_empty());
1204 Slot &slot_cube = action->slot_add();
1219 ASSERT_EQ(action->layer_array_num, 1);
1222 Layer *layer_1 = action->layer(0);
1240 move_slot(*bmain, slot_suzanne, *action_2, *action);
1245 ASSERT_EQ(action->slot_array_num, 2);
1249 ASSERT_EQ(action, cube->adt->action);
1250 ASSERT_EQ(action, suzanne->adt->action);
1256 EXPECT_TRUE(action->is_empty());
1258 Slot &slot_cube = action->slot_add();
1273 ASSERT_EQ(action->layer_array_num, 1);
1276 Layer *layer_1 = action->layer(0);
1287 <<
"the keyframe strip of action_2 should NOT have a channelbag in this test";
1292 move_slot(*bmain, slot_suzanne, *action_2, *action);
1297 ASSERT_EQ(action->slot_array_num, 2);
1301 ASSERT_EQ(action, cube->adt->action);
1302 ASSERT_EQ(action, suzanne->adt->action);
1307 ASSERT_TRUE(action->is_empty());
1309 Slot &slot_cube = action->slot_add();
1317 ASSERT_EQ(action->layer_array_num, 1);
1318 Layer *layer = action->layer(0);
1331 ASSERT_EQ(action->slot_array_num, 2);
1332 EXPECT_EQ(&dupli_slot, action->slot(1));
1351 ASSERT_TRUE(action->is_empty());
1353 Slot &slot_cube = action->slot_add();
1357 action->layer_keystrip_ensure();
1359 ASSERT_EQ(action->layer_array_num, 1);
1360 Layer *layer = action->layer(0);
1371 ASSERT_EQ(action->slot_array_num, 2);
1372 EXPECT_EQ(&dupli_slot, action->slot(1));
1397 the_keyframe.
vec[0][0] =
x - 1.0f;
1398 the_keyframe.
vec[0][1] =
y;
1399 the_keyframe.
vec[1][0] =
x;
1400 the_keyframe.
vec[1][1] =
y;
1401 the_keyframe.
vec[2][0] =
x + 1.0f;
1402 the_keyframe.
vec[2][1] =
y;
1404 memcpy(&fcu.
bezt[fcu.
totvert], &the_keyframe,
sizeof(the_keyframe));
1455 const Action &empty = action_new();
1465 Action &action = action_new();
1469 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1470 EXPECT_FLOAT_EQ(frame_range[1], 1.0f);
1482 Action &action = action_new();
1487 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1488 EXPECT_FLOAT_EQ(frame_range[1], 1.5f);
1498 Action &action = action_new();
1502 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1503 EXPECT_FLOAT_EQ(frame_range[1], 1.5f);
1532 FCurve &existing1 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1533 FCurve &existing2 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 1, {}, {},
"group0"});
1534 FCurve &existing3 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 1, {}, {},
"group1"});
1535 FCurve &existing4 = channelbag->fcurve_ensure(
nullptr, {
"fcu_", 0});
1536 ASSERT_EQ(2, channelbag->channel_groups().size());
1537 ASSERT_EQ(4, channelbag->fcurves().size());
1541 {
"fcu2", 0, {}, {},
"group2"},
1542 {
"fcu2", 1, {}, {},
"group2"},
1543 {
"fcu2", 2, {}, {},
"group2"},
1545 {
"fcu3", 0, {}, {},
"group1"},
1546 {
"fcu4", 0, {}, {},
"group0"},
1547 {
"fcu5", 0, {}, {},
"group1"},
1548 {
"fcu6", 0, {}, {},
"group0"},
1549 {
"fcu7", 0, {}, {},
"group2"},
1554 {
"", 0, {}, {},
"irrelevant"},
1556 {
"fcu0", 1, {}, {},
"irrelevant"},
1557 {
"fcu5", 0, {}, {},
"also unused"},
1558 {
"fcu2", 0, {}, {},
"group2"},
1562 ASSERT_EQ(15, fcurves.
size());
1564 EXPECT_STREQ(
"group2", fcurves[0]->grp->name);
1565 EXPECT_STREQ(
"group2", fcurves[1]->grp->name);
1566 EXPECT_STREQ(
"group2", fcurves[2]->grp->name);
1567 EXPECT_STREQ(
"group1", fcurves[3]->grp->name);
1568 EXPECT_STREQ(
"group0", fcurves[4]->grp->name);
1569 EXPECT_STREQ(
"group1", fcurves[5]->grp->name);
1570 EXPECT_STREQ(
"group0", fcurves[6]->grp->name);
1571 EXPECT_STREQ(
"group2", fcurves[7]->grp->name);
1580 EXPECT_EQ(3, channelbag->channel_groups().size());
1581 EXPECT_EQ(14, channelbag->fcurves().size());
1583 EXPECT_STREQ(
"group0", existing1.
grp->
name);
1584 EXPECT_STREQ(
"group0", existing2.
grp->
name);
1585 EXPECT_STREQ(
"group1", existing3.
grp->
name);
1591 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1592 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1593 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1594 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
1595 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1597 ASSERT_EQ(5, channelbag->fcurves().size());
1598 ASSERT_EQ(2, channelbag->channel_groups().size());
1604 channelbag->fcurve_move_to_index(fcu0, 0);
1605 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1606 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1607 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1608 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1609 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1617 channelbag->fcurve_move_to_index(fcu4, 0);
1622 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
1623 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1624 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
1625 EXPECT_EQ(&fcu2, channelbag->fcurve(3));
1626 EXPECT_EQ(&fcu3, channelbag->fcurve(4));
1634 channelbag->fcurve_move_to_index(fcu1, 4);
1639 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
1640 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1641 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1642 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1643 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
1651 channelbag->fcurve_move_to_index(fcu4, 2);
1656 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1657 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
1658 EXPECT_EQ(&fcu4, channelbag->fcurve(2));
1659 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1660 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
1670 ASSERT_TRUE(channelbag->channel_groups().is_empty());
1672 bActionGroup &group0 = channelbag->channel_group_create(
"Foo");
1673 ASSERT_EQ(channelbag->channel_groups().size(), 1);
1677 EXPECT_EQ(&group0, channelbag->channel_group(0));
1682 bActionGroup &group1 = channelbag->channel_group_create(
"Bar");
1683 ASSERT_EQ(channelbag->channel_groups().size(), 2);
1687 EXPECT_EQ(&group0, channelbag->channel_group(0));
1688 EXPECT_EQ(&group1, channelbag->channel_group(1));
1693 bActionGroup &group2 = channelbag->channel_group_create(
"Yar");
1694 ASSERT_EQ(channelbag->channel_groups().size(), 3);
1698 EXPECT_EQ(&group0, channelbag->channel_group(0));
1699 EXPECT_EQ(&group1, channelbag->channel_group(1));
1700 EXPECT_EQ(&group2, channelbag->channel_group(2));
1705 bActionGroup &group0 = channelbag->channel_group_create(
"Group0");
1706 bActionGroup &group1 = channelbag->channel_group_create(
"Group1");
1707 bActionGroup &group2 = channelbag->channel_group_create(
"Group2");
1709 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"Group0"});
1710 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"Group0"});
1711 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"Group2"});
1712 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"Group2"});
1713 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1715 ASSERT_EQ(3, channelbag->channel_groups().size());
1716 ASSERT_EQ(5, channelbag->fcurves().size());
1721 EXPECT_EQ(
false, channelbag->channel_group_remove(bogus));
1722 ASSERT_EQ(3, channelbag->channel_groups().size());
1723 ASSERT_EQ(5, channelbag->fcurves().size());
1724 EXPECT_EQ(&group0, channelbag->channel_group(0));
1725 EXPECT_EQ(&group1, channelbag->channel_group(1));
1726 EXPECT_EQ(&group2, channelbag->channel_group(2));
1727 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1728 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1729 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1730 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1731 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1739 EXPECT_EQ(
true, channelbag->channel_group_remove(group1));
1740 ASSERT_EQ(2, channelbag->channel_groups().size());
1741 ASSERT_EQ(5, channelbag->fcurves().size());
1742 EXPECT_EQ(&group0, channelbag->channel_group(0));
1743 EXPECT_EQ(&group2, channelbag->channel_group(1));
1744 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1745 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1746 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1747 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1748 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1757 EXPECT_EQ(
true, channelbag->channel_group_remove(group0));
1758 ASSERT_EQ(1, channelbag->channel_groups().size());
1759 ASSERT_EQ(5, channelbag->fcurves().size());
1760 EXPECT_EQ(&group2, channelbag->channel_group(0));
1761 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
1762 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1763 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1764 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
1765 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1774 EXPECT_EQ(
true, channelbag->channel_group_remove(group2));
1775 ASSERT_EQ(0, channelbag->channel_groups().size());
1776 ASSERT_EQ(5, channelbag->fcurves().size());
1777 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
1778 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1779 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1780 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
1781 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1791 bActionGroup &group0a = channelbag->channel_group_create(
"Foo");
1792 bActionGroup &group1a = channelbag->channel_group_create(
"Bar");
1793 bActionGroup &group2a = channelbag->channel_group_create(
"Yar");
1795 bActionGroup *group0b = channelbag->channel_group_find(
"Foo");
1796 bActionGroup *group1b = channelbag->channel_group_find(
"Bar");
1797 bActionGroup *group2b = channelbag->channel_group_find(
"Yar");
1803 EXPECT_EQ(
nullptr, channelbag->channel_group_find(
"Wat"));
1808 bActionGroup &group0 = channelbag->channel_group_create(
"Foo");
1809 bActionGroup &group1 = channelbag->channel_group_create(
"Bar");
1810 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1812 EXPECT_EQ(&group0, &channelbag->channel_group_ensure(
"Foo"));
1813 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1815 EXPECT_EQ(&group1, &channelbag->channel_group_ensure(
"Bar"));
1816 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1818 bActionGroup &group2 = channelbag->channel_group_ensure(
"Yar");
1819 ASSERT_EQ(channelbag->channel_groups().size(), 3);
1820 EXPECT_EQ(&group2, channelbag->channel_group(2));
1825 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0});
1826 EXPECT_EQ(1, channelbag->fcurves().size());
1827 EXPECT_TRUE(channelbag->channel_groups().is_empty());
1832 channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1833 EXPECT_EQ(1, channelbag->fcurves().size());
1835 EXPECT_TRUE(channelbag->channel_groups().is_empty());
1840 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1841 ASSERT_EQ(2, channelbag->fcurves().size());
1842 ASSERT_EQ(1, channelbag->channel_groups().size());
1844 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1845 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1855 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1856 ASSERT_EQ(3, channelbag->fcurves().size());
1857 ASSERT_EQ(2, channelbag->channel_groups().size());
1858 EXPECT_EQ(&group0, channelbag->channel_group(0));
1860 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1861 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
1862 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1873 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group0"});
1874 ASSERT_EQ(4, channelbag->fcurves().size());
1875 ASSERT_EQ(2, channelbag->channel_groups().size());
1876 EXPECT_EQ(&group0, channelbag->channel_group(0));
1877 EXPECT_EQ(&group1, channelbag->channel_group(1));
1878 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1879 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1880 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1881 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
1893 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0, {}, {},
"group1"});
1894 ASSERT_EQ(5, channelbag->fcurves().size());
1895 ASSERT_EQ(2, channelbag->channel_groups().size());
1896 EXPECT_EQ(&group0, channelbag->channel_group(0));
1897 EXPECT_EQ(&group1, channelbag->channel_group(1));
1898 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1899 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1900 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1901 EXPECT_EQ(&fcu4, channelbag->fcurve(3));
1902 EXPECT_EQ(&fcu0, channelbag->fcurve(4));
1916 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1917 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1918 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1919 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
1920 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1922 ASSERT_EQ(5, channelbag->fcurves().size());
1923 ASSERT_EQ(2, channelbag->channel_groups().size());
1938 channelbag->fcurve_remove(fcu3);
1939 ASSERT_EQ(4, channelbag->fcurves().size());
1940 ASSERT_EQ(2, channelbag->channel_groups().size());
1941 EXPECT_EQ(&group0, channelbag->channel_group(0));
1942 EXPECT_EQ(&group1, channelbag->channel_group(1));
1952 channelbag->fcurve_remove(fcu0);
1953 ASSERT_EQ(3, channelbag->fcurves().size());
1954 ASSERT_EQ(2, channelbag->channel_groups().size());
1955 EXPECT_EQ(&group0, channelbag->channel_group(0));
1956 EXPECT_EQ(&group1, channelbag->channel_group(1));
1965 channelbag->fcurve_remove(fcu1);
1966 ASSERT_EQ(2, channelbag->fcurves().size());
1967 ASSERT_EQ(1, channelbag->channel_groups().size());
1968 EXPECT_EQ(&group1, channelbag->channel_group(0));
1974 channelbag->fcurve_remove(fcu4);
1975 ASSERT_EQ(1, channelbag->fcurves().size());
1976 ASSERT_EQ(1, channelbag->channel_groups().size());
1977 EXPECT_EQ(&group1, channelbag->channel_group(0));
1982 channelbag->fcurve_remove(fcu2);
1983 ASSERT_EQ(0, channelbag->fcurves().size());
1984 ASSERT_EQ(0, channelbag->channel_groups().size());
1989 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1990 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group1"});
1991 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1992 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group2"});
1993 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1995 ASSERT_EQ(5, channelbag->fcurves().size());
1996 ASSERT_EQ(3, channelbag->channel_groups().size());
2002 channelbag->channel_group_move_to_index(group0, 2);
2003 EXPECT_EQ(&group1, channelbag->channel_group(0));
2004 EXPECT_EQ(&group2, channelbag->channel_group(1));
2005 EXPECT_EQ(&group0, channelbag->channel_group(2));
2012 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2013 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2014 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2015 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2016 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2023 channelbag->channel_group_move_to_index(group1, 1);
2024 EXPECT_EQ(&group2, channelbag->channel_group(0));
2025 EXPECT_EQ(&group1, channelbag->channel_group(1));
2026 EXPECT_EQ(&group0, channelbag->channel_group(2));
2033 EXPECT_EQ(&fcu3, channelbag->fcurve(0));
2034 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
2035 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2036 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2037 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2044 channelbag->channel_group_move_to_index(group0, 0);
2045 EXPECT_EQ(&group0, channelbag->channel_group(0));
2046 EXPECT_EQ(&group2, channelbag->channel_group(1));
2047 EXPECT_EQ(&group1, channelbag->channel_group(2));
2054 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2055 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
2056 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2057 EXPECT_EQ(&fcu2, channelbag->fcurve(3));
2058 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2068 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0});
2069 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0});
2070 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0});
2071 bActionGroup &group0 = channelbag->channel_group_create(
"group0");
2072 bActionGroup &group1 = channelbag->channel_group_create(
"group1");
2074 ASSERT_EQ(3, channelbag->fcurves().size());
2075 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2076 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
2077 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2078 ASSERT_EQ(2, channelbag->channel_groups().size());
2079 EXPECT_EQ(&group0, channelbag->channel_group(0));
2080 EXPECT_EQ(&group1, channelbag->channel_group(1));
2086 channelbag->fcurve_assign_to_channel_group(fcu2, group1);
2087 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
2088 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2089 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2095 channelbag->fcurve_assign_to_channel_group(fcu1, group0);
2096 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2097 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2098 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2104 channelbag->fcurve_assign_to_channel_group(fcu0, group1);
2105 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2106 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2107 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2113 channelbag->fcurve_assign_to_channel_group(fcu0, group0);
2114 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2115 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2116 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2122 channelbag->fcurve_assign_to_channel_group(fcu1, group1);
2123 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2124 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2125 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2134 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
2135 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
2136 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
2137 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
2138 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
2140 ASSERT_EQ(5, channelbag->fcurves().size());
2141 ASSERT_EQ(2, channelbag->channel_groups().size());
2148 EXPECT_FALSE(channelbag->fcurve_ungroup(bogus));
2151 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu4));
2155 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu0));
2160 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2161 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2162 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2163 EXPECT_EQ(&fcu4, channelbag->fcurve(3));
2164 EXPECT_EQ(&fcu0, channelbag->fcurve(4));
2171 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu3));
2176 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2177 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2178 EXPECT_EQ(&fcu4, channelbag->fcurve(2));
2179 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2180 EXPECT_EQ(&fcu3, channelbag->fcurve(4));
2187 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu1));
2188 EXPECT_EQ(1, channelbag->channel_groups().size());
2189 EXPECT_EQ(&group1, channelbag->channel_group(0));
2192 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
2193 EXPECT_EQ(&fcu4, channelbag->fcurve(1));
2194 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2195 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
2196 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
2203 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu2));
2204 EXPECT_EQ(0, channelbag->channel_groups().size());
2205 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
2206 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2207 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2208 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
2209 EXPECT_EQ(&fcu2, channelbag->fcurve(4));
2262 FCurve *fcurve_to_move = fcurve_create(
"source_prop", 2);
2277 <<
"F-Curve should no longer exist in source Action";
2279 <<
"F-Curve should exist in destination Action";
2282 <<
"Source Action should still have the other F-Curve";
2284 <<
"Destination Action should have its original and the moved F-Curve";
2300 FCurve &fcurve_to_move = cbag_src.fcurve_ensure(this->bmain, {
"source_prop", 2});
2301 bActionGroup &group_src = cbag_src.channel_group_create(
"Gröpje");
2302 cbag_src.fcurve_assign_to_channel_group(fcurve_to_move, group_src);
2321 EXPECT_EQ(
nullptr, cbag_src.fcurve_find({fcurve_to_move.rna_path, fcurve_to_move.array_index}))
2322 <<
"F-Curve should no longer exist in source Action";
2324 cbag_dst.fcurve_find({fcurve_to_move.rna_path, fcurve_to_move.array_index}))
2325 <<
"F-Curve should exist in destination Action";
2327 EXPECT_EQ(1, cbag_src.fcurves().size()) <<
"Source Action should still have the other F-Curve";
2329 <<
"Destination Action should have its original and the moved F-Curve";
2331 bActionGroup *group_dst = cbag_dst.channel_group_find(
"Gröpje");
2332 ASSERT_NE(
nullptr, group_dst) <<
"Expected channel group to be created";
2333 ASSERT_EQ(group_dst, fcurve_to_move.
grp) <<
"Expected group membership to move as well";
Functions and classes to work with Actions.
Blender kernel action and pose functionality.
AnimData * BKE_animdata_ensure_id(ID *id)
FCurve * BKE_fcurve_create()
FModifier * add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
void BKE_id_free(Main *bmain, void *idv)
void * BKE_id_new(Main *bmain, short type, const char *name)
void * BKE_id_new_nomain(short type, const char *name)
void BKE_main_free(Main *bmain)
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)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_poptail(ListBase *listbase) ATTR_NONNULL(1)
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 * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define STRNCPY_UTF8(dst, src)
#define DNA_DEFAULT_ACTION_LAST_SLOT_HANDLE
Object is a sort of wrapper for general info.
constexpr bool contains(const T &value) const
bool contains(const T &value) const
constexpr const char * c_str() const
Slot & slot_add_for_id(const ID &animated_id)
void layer_keystrip_ensure()
const Layer * layer(int64_t index) const
const Slot * slot(int64_t index) const
bool is_action_legacy() const
bool is_action_layered() const
float2 get_frame_range_of_keys(bool include_modifiers) const ATTR_WARN_UNUSED_RESULT
void slot_identifier_define(Slot &slot, StringRefNull new_identifier)
Layer & layer_add(std::optional< StringRefNull > name)
const bActionGroup * channel_group(int64_t index) const
FCurve & fcurve_ensure(Main *bmain, const FCurveDescriptor &fcurve_descriptor)
FCurve * fcurve_create_unique(Main *bmain, const FCurveDescriptor &fcurve_descriptor)
void fcurve_append(FCurve &fcurve)
blender::Span< const FCurve * > fcurves() const
blender::Span< const bActionGroup * > channel_groups() const
bool strip_remove(Action &owning_action, Strip &strip)
blender::Span< const Strip * > strips() const
const Strip * strip(int64_t index) const
Strip & strip_add(Action &owning_action, Strip::Type strip_type)
Vector< ID * > runtime_users()
StringRef identifier_prefix() const
void identifier_ensure_prefix()
std::string idtype_string() const
Span< ID * > users(Main &bmain) const
static constexpr slot_handle_t unassigned
const Channelbag * channelbag_for_slot(const Slot &slot) const
SingleKeyingResult keyframe_insert(Main *bmain, const Slot &slot, const FCurveDescriptor &fcurve_descriptor, float2 time_value, const KeyframeSettings &settings, eInsertKeyFlags insert_key_flags=INSERTKEY_NOFLAGS, std::optional< float2 > cycle_range=std::nullopt)
Channelbag & channelbag_for_slot_ensure(const Slot &slot)
blender::Span< const Channelbag * > channelbags() const
const Channelbag * channelbag(int64_t index) const
bool is_last_frame(float frame_time) const
void resize(float frame_start, float frame_end)
const T & data(const Action &owning_action) const
bool contains_frame(float frame_time) const
static FCurve * fcurve_create(const StringRefNull rna_path, const int array_index)
static void TearDownTestSuite()
static void SetUpTestSuite()
static void SetUpTestSuite()
static void TearDownTestSuite()
static void TearDownTestSuite()
static void SetUpTestSuite()
static void SetUpTestSuite()
static void TearDownTestSuite()
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
static void add_fcurve_to_action(Action &action, FCurve &fcu)
static void allocate_keyframes(FCurve &fcu, const size_t num_keyframes)
TEST_F(ActionIteratorsTest, iterate_all_fcurves_of_slot)
TEST(action, low_level_initialisation)
static void add_keyframe(FCurve &fcu, float x, float y)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
Slot * assign_action_ensure_slot_for_keying(Action &action, ID &animated_id)
void action_fcurve_move(Action &action_dst, slot_handle_t action_slot_dst, Action &action_src, FCurve &fcurve)
Action & action_add(Main &bmain, StringRefNull name)
Slot & duplicate_slot(Action &action, const Slot &slot)
FCurve * action_fcurve_ensure_legacy(Main *bmain, bAction *act, const char group[], PointerRNA *ptr, const FCurveDescriptor &fcurve_descriptor)
ActionSlotAssignmentResult assign_action_and_slot(Action *action, Slot *slot_to_assign, ID &animated_id)
decltype(::ActionSlot::handle) slot_handle_t
bool is_action_assignable_to(const bAction *dna_action, ID_Type id_code)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
ID * action_slot_get_id_for_keying(Main &bmain, Action &action, slot_handle_t slot_handle, ID *primary_id)
FCurve * action_fcurve_ensure_ex(Main *bmain, bAction *act, const char group[], PointerRNA *ptr, const FCurveDescriptor &fcurve_descriptor)
Action * convert_to_layered_action(Main &bmain, const Action &legacy_action)
bool unassign_action(ID &animated_id)
bool assign_action(bAction *action, ID &animated_id)
ActionSlotAssignmentResult assign_action_slot(Slot *slot_to_assign, ID &animated_id)
void move_slot(Main &bmain, Slot &slot, Action &from_action, Action &to_action)
Slot * generic_slot_for_autoassign(const ID &animated_id, Action &action, StringRefNull last_slot_identifier)
VecBase< float, 2 > float2
PointerRNA RNA_id_pointer_create(ID *id)
struct FCurve ** fcurve_array
ActionSlotRuntimeHandle * runtime
char last_slot_identifier[66]