Blender
V4.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_subdiv_ccg.hh
"
8
#include "
BKE_subsurf.hh
"
9
10
namespace
blender::bke::tests
{
11
TEST
(subdiv_ccg_coord, to_index)
12
{
13
CCGKey
key;
14
key.
level
= 2;
15
key.
elem_size
=
sizeof
(
float
);
16
17
key.
has_normals
=
false
;
18
key.
has_mask
=
false
;
19
20
key.
normal_offset
= -1;
21
key.
mask_offset
= -1;
22
23
key.
grid_size
=
BKE_ccg_gridsize
(key.
level
);
/* 3 */
24
key.
grid_area
= key.
grid_size
* key.
grid_size
;
/* 9 */
25
key.
grid_bytes
= key.
grid_area
* key.
elem_size
;
26
27
SubdivCCGCoord
coord;
28
coord.
grid_index
= 2;
29
coord.
x
= 1;
30
coord.
y
= 1;
31
32
/* (grid_index * grid_area) + y * grid_size + x */
33
/* (2 * 9) + (1 * 3) + 1 */
34
EXPECT_EQ
(coord.
to_index
(key), 22);
35
}
36
37
TEST
(subdiv_ccg_coord, constructor)
38
{
39
CCGKey
key;
40
key.
level
= 2;
41
key.
elem_size
=
sizeof
(
float
);
42
43
key.
has_normals
=
false
;
44
key.
has_mask
=
false
;
45
46
key.
normal_offset
= -1;
47
key.
mask_offset
= -1;
48
49
key.
grid_size
=
BKE_ccg_gridsize
(key.
level
);
/* 3 */
50
key.
grid_area
= key.
grid_size
* key.
grid_size
;
/* 9 */
51
key.
grid_bytes
= key.
grid_area
* key.
elem_size
;
52
53
SubdivCCGCoord
coord =
SubdivCCGCoord::from_index
(key, 22);
54
coord.
grid_index
= 2;
55
coord.
x
= 1;
56
coord.
y
= 1;
57
58
EXPECT_EQ
(coord.
grid_index
, 2);
59
EXPECT_EQ
(coord.
x
, 1);
60
EXPECT_EQ
(coord.
y
, 1);
61
}
62
}
// namespace blender::bke::tests
BKE_subdiv_ccg.hh
BKE_subsurf.hh
BKE_ccg_gridsize
int BKE_ccg_gridsize(int level)
Definition
CCGSubSurf.cc:25
EXPECT_EQ
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
float
draw_view in_light_buf[] float
Definition
eevee_light_culling_info.hh:42
blender::bke::tests
Definition
blenkernel/intern/action_test.cc:20
blender::bke::tests::TEST
TEST(action_groups, ReconstructGroupsWithReordering)
Definition
blenkernel/intern/action_test.cc:22
CCGKey
Definition
BKE_ccg.hh:25
CCGKey::has_mask
int has_mask
Definition
BKE_ccg.hh:48
CCGKey::mask_offset
int mask_offset
Definition
BKE_ccg.hh:45
CCGKey::grid_size
int grid_size
Definition
BKE_ccg.hh:33
CCGKey::grid_bytes
int grid_bytes
Definition
BKE_ccg.hh:37
CCGKey::grid_area
int grid_area
Definition
BKE_ccg.hh:35
CCGKey::level
int level
Definition
BKE_ccg.hh:26
CCGKey::normal_offset
int normal_offset
Definition
BKE_ccg.hh:41
CCGKey::elem_size
int elem_size
Definition
BKE_ccg.hh:30
CCGKey::has_normals
int has_normals
Definition
BKE_ccg.hh:47
SubdivCCGCoord
Definition
BKE_subdiv_ccg.hh:66
SubdivCCGCoord::y
short y
Definition
BKE_subdiv_ccg.hh:71
SubdivCCGCoord::grid_index
int grid_index
Definition
BKE_subdiv_ccg.hh:68
SubdivCCGCoord::to_index
int to_index(const CCGKey &key) const
Definition
BKE_subdiv_ccg.hh:90
SubdivCCGCoord::from_index
static SubdivCCGCoord from_index(const CCGKey &key, int index)
Definition
BKE_subdiv_ccg.hh:75
SubdivCCGCoord::x
short x
Definition
BKE_subdiv_ccg.hh:71
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0