Blender
V5.0
source
blender
editors
animation
anim_draw_test.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2025 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#include "
BLI_math_constants.h
"
6
7
#include "
ED_anim_api.hh
"
8
9
#include "
DNA_anim_types.h
"
10
11
#include "
BKE_fcurve.hh
"
12
#include "
BKE_idtype.hh
"
13
#include "
BKE_lib_id.hh
"
14
#include "
BKE_main.hh
"
15
16
#include "
CLG_log.h
"
17
#include "testing/testing.h"
18
19
namespace
blender::animrig::tests
{
20
21
class
AnimDrawTest
:
public
testing::Test {
22
public
:
23
Main
*
bmain
;
24
Object
*
object
;
25
26
static
void
SetUpTestSuite
()
27
{
28
CLG_init
();
29
BKE_idtype_init
();
30
}
31
32
static
void
TearDownTestSuite
()
33
{
34
CLG_exit
();
35
}
36
37
void
SetUp
()
override
38
{
39
this->bmain =
BKE_main_new
();
40
this->
object
=
BKE_id_new<Object>
(this->bmain,
"OBTestObject"
);
41
}
42
43
void
TearDown
()
override
44
{
45
BKE_main_free
(this->bmain);
46
}
47
};
48
49
TEST_F
(
AnimDrawTest
, anim_unit_mapping_get_factor_not_normalizing)
50
{
51
FCurve
*fcurve =
MEM_callocN<FCurve>
(__func__);
52
fcurve->
array_index
= 0;
53
54
/* Avoid creating a Scene via BKE_id_new<Scene>(this->bmain, "SCTestScene"); as that requires
55
* much more setup (appdirs, imbuf for color management, and maybe more). This test doesn't
56
* actually need a full Scene, it just needs its `units` field. */
57
Scene
scene;
58
memset(&scene.
unit
, 0,
sizeof
(scene.
unit
));
59
scene.
unit
.
scale_length
= 1.0f;
60
61
{
/* Rotation: Degrees. */
62
scene.
unit
.
system_rotation
= 0;
63
BKE_fcurve_rnapath_set
(*fcurve,
"rotation_euler"
);
64
65
EXPECT_FLOAT_EQ(
RAD2DEGF
(1.0f),
66
ANIM_unit_mapping_get_factor
(&scene, &this->object->
id
, fcurve, 0,
nullptr
));
67
EXPECT_FLOAT_EQ(1.0f /
RAD2DEGF
(1.0f),
68
ANIM_unit_mapping_get_factor
(
69
&scene, &this->object->
id
, fcurve,
ANIM_UNITCONV_RESTORE
,
nullptr
));
70
}
71
72
{
/* Rotation: Radians. */
73
scene.
unit
.
system_rotation
=
USER_UNIT_ROT_RADIANS
;
74
BKE_fcurve_rnapath_set
(*fcurve,
"rotation_euler"
);
75
76
EXPECT_FLOAT_EQ(1.0f,
77
ANIM_unit_mapping_get_factor
(&scene, &this->object->
id
, fcurve, 0,
nullptr
));
78
EXPECT_FLOAT_EQ(1.0f,
79
ANIM_unit_mapping_get_factor
(
80
&scene, &this->object->
id
, fcurve,
ANIM_UNITCONV_RESTORE
,
nullptr
));
81
}
82
83
BKE_fcurve_free
(fcurve);
84
}
85
86
}
// namespace blender::animrig::tests
BKE_fcurve.hh
BKE_fcurve_rnapath_set
void BKE_fcurve_rnapath_set(FCurve &fcu, blender::StringRef rna_path)
Definition
blenkernel/intern/fcurve.cc:167
BKE_fcurve_free
void BKE_fcurve_free(FCurve *fcu)
Definition
blenkernel/intern/fcurve.cc:74
BKE_idtype.hh
BKE_idtype_init
void BKE_idtype_init()
Definition
idtype.cc:121
BKE_lib_id.hh
BKE_id_new
void * BKE_id_new(Main *bmain, short type, const char *name)
Definition
lib_id.cc:1514
BKE_main.hh
BKE_main_new
Main * BKE_main_new()
Definition
main.cc:89
BKE_main_free
void BKE_main_free(Main *bmain)
Definition
main.cc:192
BLI_math_constants.h
RAD2DEGF
#define RAD2DEGF(_rad)
Definition
BLI_math_constants.h:74
CLG_log.h
CLG_exit
void CLG_exit()
Definition
clog.cc:880
CLG_init
void CLG_init()
Definition
clog.cc:873
DNA_anim_types.h
USER_UNIT_ROT_RADIANS
@ USER_UNIT_ROT_RADIANS
Definition
DNA_scene_types.h:3011
ED_anim_api.hh
ANIM_UNITCONV_RESTORE
@ ANIM_UNITCONV_RESTORE
Definition
ED_anim_api.hh:1098
ANIM_unit_mapping_get_factor
float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag, float *r_offset)
Definition
anim_draw.cc:624
blender::animrig::tests::AnimDrawTest
Definition
anim_draw_test.cc:21
blender::animrig::tests::AnimDrawTest::TearDownTestSuite
static void TearDownTestSuite()
Definition
anim_draw_test.cc:32
blender::animrig::tests::AnimDrawTest::bmain
Main * bmain
Definition
anim_draw_test.cc:23
blender::animrig::tests::AnimDrawTest::object
Object * object
Definition
anim_draw_test.cc:24
blender::animrig::tests::AnimDrawTest::TearDown
void TearDown() override
Definition
anim_draw_test.cc:43
blender::animrig::tests::AnimDrawTest::SetUpTestSuite
static void SetUpTestSuite()
Definition
anim_draw_test.cc:26
blender::animrig::tests::AnimDrawTest::SetUp
void SetUp() override
Definition
anim_draw_test.cc:37
MEM_callocN
void * MEM_callocN(size_t len, const char *str)
Definition
mallocn.cc:118
blender::animrig::tests
Definition
action_iterators_test.cc:21
blender::animrig::tests::TEST_F
TEST_F(ActionIteratorsTest, iterate_all_fcurves_of_slot)
Definition
action_iterators_test.cc:53
FCurve
Definition
DNA_anim_types.h:329
FCurve::array_index
int array_index
Definition
DNA_anim_types.h:379
Main
Definition
BKE_main.hh:160
Object
Definition
DNA_object_types.h:191
Scene
Definition
DNA_scene_types.h:2120
Scene::id
ID id
Definition
DNA_scene_types.h:2126
Scene::unit
struct UnitSettings unit
Definition
DNA_scene_types.h:2197
UnitSettings::scale_length
float scale_length
Definition
DNA_scene_types.h:1930
UnitSettings::system_rotation
char system_rotation
Definition
DNA_scene_types.h:1934
Generated on
for Blender by
doxygen
1.16.1