Merge remote-tracking branch 'origin/blender-v4.4-release'
This commit is contained in:
@@ -1242,10 +1242,16 @@ static void nlastrips_apply_all_curves_cb(ID *id,
|
||||
ListBase *strips,
|
||||
const FunctionRef<void(ID *, FCurve *)> func)
|
||||
{
|
||||
/* This function is used (via `BKE_fcurves_id_cb()`) by the versioning system.
|
||||
* As such, legacy Actions should always be expected here. */
|
||||
|
||||
LISTBASE_FOREACH (NlaStrip *, strip, strips) {
|
||||
/* fix strip's action */
|
||||
if (strip->act) {
|
||||
fcurves_apply_cb(id, blender::animrig::legacy::fcurves_all(strip->act), func);
|
||||
fcurves_apply_cb(
|
||||
id,
|
||||
blender::animrig::legacy::fcurves_for_action_slot(strip->act, strip->action_slot_handle),
|
||||
func);
|
||||
}
|
||||
|
||||
/* Check sub-strips (if meta-strips). */
|
||||
@@ -1259,12 +1265,21 @@ static void adt_apply_all_fcurves_cb(ID *id,
|
||||
AnimData *adt,
|
||||
const FunctionRef<void(ID *, FCurve *)> func)
|
||||
{
|
||||
/* This function is used (via `BKE_fcurves_id_cb()`) by the versioning system.
|
||||
* As such, legacy Actions should always be expected here. */
|
||||
|
||||
if (adt->action) {
|
||||
fcurves_apply_cb(id, blender::animrig::legacy::fcurves_all(adt->action), func);
|
||||
fcurves_apply_cb(
|
||||
id,
|
||||
blender::animrig::legacy::fcurves_for_action_slot(adt->action, adt->slot_handle),
|
||||
func);
|
||||
}
|
||||
|
||||
if (adt->tmpact) {
|
||||
fcurves_apply_cb(id, blender::animrig::legacy::fcurves_all(adt->tmpact), func);
|
||||
fcurves_apply_cb(
|
||||
id,
|
||||
blender::animrig::legacy::fcurves_for_action_slot(adt->tmpact, adt->tmp_slot_handle),
|
||||
func);
|
||||
}
|
||||
|
||||
/* free drivers - stored as a list of F-Curves */
|
||||
|
||||
75
source/blender/blenkernel/intern/anim_data_test.cc
Normal file
75
source/blender/blenkernel/intern/anim_data_test.cc
Normal file
@@ -0,0 +1,75 @@
|
||||
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BKE_action.hh"
|
||||
|
||||
#include "ANIM_action.hh"
|
||||
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_anim_types.h"
|
||||
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "testing/testing.h"
|
||||
|
||||
namespace blender::bke::tests {
|
||||
|
||||
TEST(anim_data, BKE_fcurves_id_cb_test)
|
||||
{
|
||||
/* BKE_id_free() hits a code path that uses CLOG, which crashes if not initialized properly. */
|
||||
CLG_init();
|
||||
/* To make id_can_have_animdata() and friends work, the `id_types` array needs to be set up. */
|
||||
BKE_idtype_init();
|
||||
|
||||
Main *bmain = BKE_main_new();
|
||||
Action *action = static_cast<Action *>(BKE_id_new(bmain, ID_AC, "ACÄnimåtië"));
|
||||
Object *cube = BKE_object_add_only_object(bmain, OB_EMPTY, "Küüübus");
|
||||
Object *suzanne = BKE_object_add_only_object(bmain, OB_EMPTY, "OBSuzanne");
|
||||
|
||||
/* Create F-Curves for Cube. */
|
||||
ASSERT_TRUE(animrig::assign_action(action, cube->id));
|
||||
const FCurve *fcurve_cube_loc1 = animrig::action_fcurve_ensure(
|
||||
bmain, *action, cube->id, {"location", 1});
|
||||
const FCurve *fcurve_cube_scale2 = animrig::action_fcurve_ensure(
|
||||
bmain, *action, cube->id, {"scale", 2});
|
||||
|
||||
/* Create F-Curves for Suzanne. */
|
||||
ASSERT_TRUE(animrig::assign_action(action, suzanne->id));
|
||||
const FCurve *fcurve_suzanne_loc0 = animrig::action_fcurve_ensure(
|
||||
bmain, *action, suzanne->id, {"location", 0});
|
||||
const FCurve *fcurve_suzanne_scale1 = animrig::action_fcurve_ensure(
|
||||
bmain, *action, suzanne->id, {"scale", 1});
|
||||
|
||||
/* Test that BKE_fcurves_id_cb only reports F-Curves that are meant for that ID. */
|
||||
Vector<ID *> reported_ids;
|
||||
Vector<FCurve *> reported_fcurves;
|
||||
const auto callback = [&reported_fcurves](ID *id, FCurve *fcurve) {
|
||||
reported_ids.push_back(id);
|
||||
reported_fcurves.push_back(fcurve);
|
||||
};
|
||||
|
||||
BKE_fcurves_id_cb(&cube->id, callback);
|
||||
EXPECT_EQ(1, reported_ids.size());
|
||||
EXPECT_EQ(2, reported_fcurves.size());
|
||||
EXPECT_EQ(&cube->id, reported_ids[0]);
|
||||
EXPECT_EQ(fcurve_cube_loc1, reported_fcurves[0]);
|
||||
EXPECT_EQ(fcurve_cube_scale2, reported_fcurves[1]);
|
||||
|
||||
/* Also test for Suzanne, as that's a different slot. The first slot could
|
||||
* have been covered by legacy-compatible code. */
|
||||
reported_ids.clear();
|
||||
reported_fcurves.clear();
|
||||
|
||||
BKE_fcurves_id_cb(&cube->id, callback);
|
||||
EXPECT_EQ(1, reported_ids.size());
|
||||
EXPECT_EQ(2, reported_fcurves.size());
|
||||
EXPECT_EQ(&suzanne->id, reported_ids[0]);
|
||||
EXPECT_EQ(fcurve_suzanne_loc0, reported_fcurves[0]);
|
||||
EXPECT_EQ(fcurve_suzanne_scale1, reported_fcurves[1]);
|
||||
|
||||
BKE_main_free(bmain);
|
||||
CLG_exit();
|
||||
}
|
||||
|
||||
} // namespace blender::bke::tests
|
||||
@@ -143,8 +143,8 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t)
|
||||
const IndexMask bezier_points = bke::curves::curve_to_point_selection(
|
||||
curves.points_by_curve(), bezier_curves[layer_offset], curves_transform_data->memory);
|
||||
|
||||
tc.data_len += curves.points_num() + 2 * bezier_points.size();
|
||||
points_to_transform_per_attribute[layer_offset].append(curves.points_range());
|
||||
tc.data_len += editable_points.size() + 2 * bezier_points.size();
|
||||
points_to_transform_per_attribute[layer_offset].append(editable_points);
|
||||
|
||||
if (selection_attribute_names.size() > 1) {
|
||||
points_to_transform_per_attribute[layer_offset].append(bezier_points);
|
||||
|
||||
Reference in New Issue
Block a user