17#include "RNA_prototypes.hh"
19#include "testing/testing.h"
41 Slot &cube_slot = action->slot_add();
42 Slot &monkey_slot = action->slot_add();
47 *action, cube_slot.
handle, [&](
const FCurve &fcurve) { no_fcurves.append(&fcurve); });
57 for (
int i = 0; i < 3; i++) {
59 bmain, cube_slot, {
"location", i}, {1.0f, 0.0f}, settings);
61 <<
"Expected keyframe insertion to be successful";
64 bmain, monkey_slot, {
"rotation", i}, {1.0f, 0.0f}, settings);
66 <<
"Expected keyframe insertion to be successful";
72 *action, cube_slot.
handle, [&](
const FCurve &fcurve) { cube_fcurves.append(&fcurve); });
74 ASSERT_EQ(cube_fcurves.
size(), 3);
75 for (
const FCurve *fcurve : cube_fcurves) {
76 ASSERT_EQ(fcurve->rna_path(),
"location");
82 if (fcurve.array_index == 0) {
83 monkey_fcurves.append(&fcurve);
87 ASSERT_EQ(monkey_fcurves.size(), 1);
88 ASSERT_EQ(monkey_fcurves[0]->
rna_path(),
"rotation");
94 *action, monkey_slot.handle + cube_slot.handle, [&](
const FCurve &fcurve) {
95 invalid_slot_fcurves.append(&fcurve);
97 ASSERT_TRUE(invalid_slot_fcurves.
is_empty());
105 ASSERT_NE(slot_cube,
nullptr);
111 std::optional<ActionSlotAssignmentResult> slot_assignment_result;
113 bool all_assigns_ok =
true;
114 const auto assign_other_action = [&](
ID & ,
117 char *last_slot_identifier) ->
bool {
120 cube->id, &other_action, action_ptr_ref, slot_handle_ref, last_slot_identifier);
124 &another_slot, cube->id, action_ptr_ref, slot_handle_ref, last_slot_identifier);
130 ASSERT_TRUE(all_assigns_ok);
133 ASSERT_TRUE(slot_assignment_result.has_value());
138 ASSERT_TRUE(action_and_slot.has_value());
139 EXPECT_EQ(&other_action, action_and_slot->first)
140 <<
"Expected Action " << other_action.
id.
name <<
" but found "
141 << action_and_slot->first->id.name;
142 EXPECT_EQ(&another_slot, action_and_slot->second)
143 <<
"Expected Slot " << another_slot.
identifier <<
" but found "
144 << action_and_slot->second->identifier;
152 ASSERT_NE(slot_cube,
nullptr);
153 Slot &another_slot = action->slot_add();
155 const auto assign_other_slot = [&](
ID & ,
170 ASSERT_TRUE(action_and_slot.has_value());
171 EXPECT_EQ(action, action_and_slot->first)
172 <<
"Expected Action " << action->id.name <<
" but found " << action_and_slot->first->id.name;
173 EXPECT_EQ(&another_slot, action_and_slot->second)
174 <<
"Expected Slot " << another_slot.
identifier <<
" but found "
175 << action_and_slot->second->identifier;
Functions and classes to work with Actions.
Functionality to iterate an Action in various ways.
General operations, lookup, etc. for blender objects.
Object is a sort of wrapper for general info.
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)
const T & data(const Action &owning_action) const
TEST_F(ActionIteratorsTest, iterate_all_fcurves_of_slot)
void foreach_fcurve_in_action_slot(Action &action, slot_handle_t handle, FunctionRef< void(FCurve &fcurve)> callback)
decltype(blender::ActionSlot::handle) slot_handle_t
KeyframeSettings get_keyframe_settings(bool from_userprefs)
Slot * assign_action_ensure_slot_for_keying(Action &action, ID &animated_id)
bool generic_assign_action(ID &animated_id, bAction *action_to_assign, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_identifier)
ActionSlotAssignmentResult generic_assign_action_slot(Slot *slot_to_assign, ID &animated_id, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_identifier)
bool foreach_action_slot_use_with_rna(ID &animated_id, FunctionRef< bool(ID &animated_id, bAction *action, PointerRNA &action_slot_owner_ptr, PropertyRNA &action_slot_prop, char *last_slot_identifier)> callback)
std::optional< std::pair< Action *, Slot * > > get_action_slot_pair(ID &animated_id)
bool foreach_action_slot_use_with_references(ID &animated_id, FunctionRef< bool(ID &animated_id, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *last_slot_identifier)> callback)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void BKE_main_free(Main *bmain)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
void * BKE_id_new(Main *bmain, short type, const char *name)