Blender
V4.5
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:24
EXPECT_EQ
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
key
int key
Definition
BLI_set_test.cc:631
blender::bke::tests
Definition
blenkernel/intern/action_test.cc:18
blender::bke::tests::TEST
TEST(action_groups, ReconstructGroupsWithReordering)
Definition
blenkernel/intern/action_test.cc:20
CCGKey
Definition
BKE_ccg.hh:25
CCGKey::level
int level
Definition
BKE_ccg.hh:26
SubdivCCGCoord
Definition
BKE_subdiv_ccg.hh:65
SubdivCCGCoord::y
short y
Definition
BKE_subdiv_ccg.hh:70
SubdivCCGCoord::grid_index
int grid_index
Definition
BKE_subdiv_ccg.hh:67
SubdivCCGCoord::to_index
int to_index(const CCGKey &key) const
Definition
BKE_subdiv_ccg.hh:89
SubdivCCGCoord::from_index
static SubdivCCGCoord from_index(const CCGKey &key, int index)
Definition
BKE_subdiv_ccg.hh:74
SubdivCCGCoord::x
short x
Definition
BKE_subdiv_ccg.hh:70
Generated on Fri Apr 3 2026 06:33:18 for Blender by
doxygen
1.11.0