Blender V5.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_ccg.hh"
8#include "BKE_gtest_base.hh"
9#include "BKE_subdiv_ccg.hh"
10
11namespace blender::bke::tests {
12
14
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
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
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
TEST_F(AnimDataTest, BKE_fcurves_id_cb_test)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
int CCG_grid_size(const int level)
Definition BKE_ccg.hh:106
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
static SubdivCCGCoord from_index(const CCGKey &key, int index)
int to_index(const CCGKey &key) const