Blender V4.3
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
10namespace blender::bke::tests {
11TEST(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
37TEST(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
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
int BKE_ccg_gridsize(int level)
Definition CCGSubSurf.cc:25
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
draw_view in_light_buf[] float
TEST(action_groups, ReconstructGroupsWithReordering)
int has_mask
Definition BKE_ccg.hh:48
int mask_offset
Definition BKE_ccg.hh:45
int grid_size
Definition BKE_ccg.hh:33
int grid_bytes
Definition BKE_ccg.hh:37
int grid_area
Definition BKE_ccg.hh:35
int level
Definition BKE_ccg.hh:26
int normal_offset
Definition BKE_ccg.hh:41
int elem_size
Definition BKE_ccg.hh:30
int has_normals
Definition BKE_ccg.hh:47
int to_index(const CCGKey &key) const
static SubdivCCGCoord from_index(const CCGKey &key, int index)