Blender
V5.3
source
blender
blenkernel
intern
subdiv_ccg_test.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2024 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#include "testing/testing.h"
6
7
#include "
BKE_ccg.hh
"
8
#include "
BKE_gtest_base.hh
"
9
#include "
BKE_subdiv_ccg.hh
"
10
11
namespace
blender::bke::tests
{
12
13
class
SubdivCcgCoordTest
:
public
BlenderGTestBase
{};
14
15
TEST_F
(
SubdivCcgCoordTest
, to_index)
16
{
17
CCGKey
key;
18
key.
level
= 2;
19
key.
elem_size
=
sizeof
(
float
);
20
21
key.
has_normals
=
false
;
22
key.
has_mask
=
false
;
23
24
key.
normal_offset
= -1;
25
key.
mask_offset
= -1;
26
27
key.
grid_size
=
CCG_grid_size
(key.
level
);
/* 3 */
28
key.
grid_area
= key.
grid_size
* key.
grid_size
;
/* 9 */
29
key.
grid_bytes
= key.
grid_area
* key.
elem_size
;
30
31
SubdivCCGCoord
coord;
32
coord.
grid_index
= 2;
33
coord.
x
= 1;
34
coord.
y
= 1;
35
36
/* (grid_index * grid_area) + y * grid_size + x */
37
/* (2 * 9) + (1 * 3) + 1 */
38
EXPECT_EQ
(coord.
to_index
(key), 22);
39
}
40
41
TEST_F
(
SubdivCcgCoordTest
, constructor)
42
{
43
CCGKey
key;
44
key.
level
= 2;
45
key.
elem_size
=
sizeof
(
float
);
46
47
key.
has_normals
=
false
;
48
key.
has_mask
=
false
;
49
50
key.
normal_offset
= -1;
51
key.
mask_offset
= -1;
52
53
key.
grid_size
=
CCG_grid_size
(key.
level
);
/* 3 */
54
key.
grid_area
= key.
grid_size
* key.
grid_size
;
/* 9 */
55
key.
grid_bytes
= key.
grid_area
* key.
elem_size
;
56
57
SubdivCCGCoord
coord =
SubdivCCGCoord::from_index
(key, 22);
58
coord.
grid_index
= 2;
59
coord.
x
= 1;
60
coord.
y
= 1;
61
62
EXPECT_EQ
(coord.
grid_index
, 2);
63
EXPECT_EQ
(coord.
x
, 1);
64
EXPECT_EQ
(coord.
y
, 1);
65
}
66
}
// namespace blender::bke::tests
BKE_ccg.hh
BKE_gtest_base.hh
BKE_subdiv_ccg.hh
blender::bke::BlenderGTestBase
Definition
BKE_gtest_base.hh:17
blender::bke::tests::SubdivCcgCoordTest
Definition
subdiv_ccg_test.cc:13
blender::bke::tests
Definition
anim_data_test.cc:23
blender::bke::tests::TEST_F
TEST_F(AnimDataTest, BKE_fcurves_id_cb_test)
Definition
anim_data_test.cc:27
blender::EXPECT_EQ
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
blender::CCG_grid_size
int CCG_grid_size(const int level)
Definition
BKE_ccg.hh:106
float
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
Definition
shadow_state_template.h:80
blender::CCGKey
Definition
BKE_ccg.hh:27
blender::CCGKey::elem_size
int elem_size
Definition
BKE_ccg.hh:32
blender::CCGKey::has_normals
int has_normals
Definition
BKE_ccg.hh:49
blender::CCGKey::mask_offset
int mask_offset
Definition
BKE_ccg.hh:47
blender::CCGKey::normal_offset
int normal_offset
Definition
BKE_ccg.hh:43
blender::CCGKey::grid_bytes
int grid_bytes
Definition
BKE_ccg.hh:39
blender::CCGKey::grid_size
int grid_size
Definition
BKE_ccg.hh:35
blender::CCGKey::level
int level
Definition
BKE_ccg.hh:28
blender::CCGKey::has_mask
int has_mask
Definition
BKE_ccg.hh:50
blender::CCGKey::grid_area
int grid_area
Definition
BKE_ccg.hh:37
blender::SubdivCCGCoord
Definition
BKE_subdiv_ccg.hh:73
blender::SubdivCCGCoord::y
short y
Definition
BKE_subdiv_ccg.hh:78
blender::SubdivCCGCoord::x
short x
Definition
BKE_subdiv_ccg.hh:78
blender::SubdivCCGCoord::from_index
static SubdivCCGCoord from_index(const CCGKey &key, int index)
Definition
BKE_subdiv_ccg.hh:84
blender::SubdivCCGCoord::to_index
int to_index(const CCGKey &key) const
Definition
BKE_subdiv_ccg.hh:101
blender::SubdivCCGCoord::grid_index
int grid_index
Definition
BKE_subdiv_ccg.hh:75
Generated on
for Blender by
doxygen
1.18.0