Blender V5.3
paint_test.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_gtest_base.hh"
6#include "BKE_idtype.hh"
7#include "BKE_lib_id.hh"
8#include "BKE_paint_bvh.hh"
9#include "BKE_subdiv.hh"
10#include "BKE_subdiv_ccg.hh"
11#include "BKE_subdiv_eval.hh"
12
13#include "DNA_mesh_types.h"
14
16
17#include "CLG_log.h"
18
19#include "intern/bmesh_mesh.hh"
21
22#include "sculpt_dyntopo.hh"
23
24#include "testing/testing.h"
25
26namespace blender::bke::tests {
28 public:
30
31 void SetUp() override
32 {
33 cube_mesh = geometry::create_cuboid_mesh(float3(1.0, 1.0, 1.0), 10, 10, 10);
34 }
35
36 void TearDown() override
37 {
38 BKE_id_free(nullptr, cube_mesh);
39 }
40};
41
43{
44 pbvh::Tree tree = pbvh::Tree::from_mesh(*cube_mesh);
45 EXPECT_GT(tree.nodes<pbvh::MeshNode>().size(), 0)
46 << "Paint BVH should have some non-zero amount of nodes";
47}
48
50 public:
52 std::unique_ptr<SubdivCCG> subdiv_ccg;
53
54 void SetUp() override
55 {
56 cube_mesh = geometry::create_cuboid_mesh(float3(1.0, 1.0, 1.0), 10, 10, 10);
57 subdiv::Settings settings;
58 settings.is_adaptive = true;
59 settings.level = 4;
60 settings.use_creases = true;
63
66
67 SubdivToCCGSettings subdiv_to_ccg_settings;
68 subdiv_to_ccg_settings.resolution = 3;
69 subdiv_to_ccg_settings.need_normal = true;
70 subdiv_to_ccg_settings.need_mask = false;
71 subdiv_ccg = BKE_subdiv_to_ccg(*subdiv, subdiv_to_ccg_settings, *cube_mesh, nullptr);
72 }
73
74 void TearDown() override
75 {
76 BKE_id_free(nullptr, cube_mesh);
77 }
78};
79
80TEST_F(GridsBVHTest, from_grids)
81{
82 pbvh::Tree tree = pbvh::Tree::from_grids(*cube_mesh, *subdiv_ccg);
83 EXPECT_GT(tree.nodes<pbvh::GridsNode>().size(), 0)
84 << "Paint BVH should have some non-zero amount of nodes";
85}
86
88 public:
91
92 void SetUp() override
93 {
94 cube_mesh = geometry::create_cuboid_mesh(float3(1.0, 1.0, 1.0), 10, 10, 10);
95 /* Create triangles-only BMesh. */
97
98 BMeshCreateParams create_params{};
99 create_params.use_toolflags = false;
100
101 bm = BM_mesh_create(&allocsize, &create_params);
102
103 BMeshFromMeshParams convert_params{};
104 convert_params.calc_face_normal = true;
105 convert_params.calc_vert_normal = true;
106 BM_mesh_bm_from_me(bm, cube_mesh, &convert_params);
107
109
110 BM_data_layer_ensure_named(bm, &bm->vdata, CD_PROP_INT32, ".sculpt_dyntopo_node_id_vertex");
111 BM_data_layer_ensure_named(bm, &bm->pdata, CD_PROP_INT32, ".sculpt_dyntopo_node_id_face");
112 }
113
114 void TearDown() override
115 {
117 BKE_id_free(nullptr, cube_mesh);
118 }
119};
120
122{
124 EXPECT_GT(tree.nodes<pbvh::BMeshNode>().size(), 0)
125 << "Paint BVH should have some non-zero amount of nodes";
126}
127} // namespace blender::bke::tests
A BVH for high poly meshes.
#define BMALLOC_TEMPLATE_FROM_ME(...)
static Tree from_bmesh(BMesh &bm)
Span< NodeT > nodes() const
static Tree from_grids(const Mesh &base_mesh, const SubdivCCG &subdiv_ccg)
Definition pbvh.cc:465
static Tree from_mesh(const Mesh &mesh)
Definition pbvh.cc:304
std::unique_ptr< SubdivCCG > subdiv_ccg
Definition paint_test.cc:52
#define EXPECT_GT(result, expect)
bool eval_begin_from_mesh(Subdiv *subdiv, const Mesh *mesh, eSubdivEvaluatorType evaluator_type, Span< float3 > coarse_vert_positions={}, OpenSubdiv_EvaluatorCache *evaluator_cache=nullptr)
@ SUBDIV_FVAR_LINEAR_INTERPOLATION_BOUNDARIES
Definition BKE_subdiv.hh:45
Subdiv * new_from_mesh(const Settings *settings, const Mesh *mesh)
Definition subdiv.cc:133
TEST_F(AnimDataTest, BKE_fcurves_id_cb_test)
Mesh * create_cuboid_mesh(const float3 &size, int verts_x, int verts_y, int verts_z, std::optional< StringRef > uv_id)
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *params)
Mesh -> BMesh.
void BKE_id_free(Main *bmain, void *idv)
void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const StringRef name)
std::unique_ptr< SubdivCCG > BKE_subdiv_to_ccg(bke::subdiv::Subdiv &subdiv, const SubdivToCCGSettings &settings, const Mesh &coarse_mesh, SubdivCCGMaskEvaluator *mask_evaluator=nullptr)
VecBase< float, 3 > float3
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
CustomData pdata
CustomData vdata
VtxBoundaryInterpolation vtx_boundary_interpolation
Definition BKE_subdiv.hh:83
FVarLinearInterpolation fvar_linear_interpolation
Definition BKE_subdiv.hh:84