Blender V5.3
sculpt_boundary_tests.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#include "sculpt_boundary.hh"
5
6#include "BKE_gtest_base.hh"
7#include "BKE_lib_id.hh"
8
9#include "DNA_mesh_types.h"
10
13
14#include "testing/testing.h"
15
17
19 public:
20 Mesh *mesh = nullptr;
21
22 void TearDown() override
23 {
24 if (mesh) {
25 BKE_id_free(nullptr, mesh);
26 }
27 }
28};
29
30TEST_F(SculptBoundaryTests, create_boundary_info__cube)
31{
32 mesh = geometry::create_cuboid_mesh(float3(1.0, 1.0, 1.0), 2, 2, 2);
33
35
36 ASSERT_EQ(boundary_info_cache.verts.size(), mesh->verts_num);
37 int num_false = 0;
38 for (int i = 0; i < mesh->verts_num; ++i) {
39 if (!boundary_info_cache.verts[i].test()) {
40 num_false++;
41 }
42 }
43 ASSERT_EQ(num_false, mesh->verts_num);
44 ASSERT_EQ(boundary_info_cache.edges.size(), 0);
45}
46
47TEST_F(SculptBoundaryTests, create_boundary_info__grid)
48{
49 mesh = geometry::create_grid_mesh(3, 3, 1.0, 1.0, {});
50
52
53 ASSERT_EQ(boundary_info_cache.verts.size(), mesh->verts_num);
54 int num_true = 0;
55 for (int i = 0; i < mesh->verts_num; ++i) {
56 if (boundary_info_cache.verts[i].test()) {
57 num_true++;
58 }
59 }
60
61 ASSERT_EQ(num_true, 8);
62 ASSERT_EQ(boundary_info_cache.edges.size(), 8);
63 ASSERT_NE(boundary_info_cache.edges.size(), mesh->edges().size());
64}
65
66TEST_F(SculptBoundaryTests, create_boundary_info__1D_strip)
67{
68 mesh = geometry::create_grid_mesh(3, 2, 1.0, 1.0, {});
69
71
72 ASSERT_EQ(boundary_info_cache.verts.size(), mesh->verts_num);
73 int num_true = 0;
74 for (int i = 0; i < mesh->verts_num; ++i) {
75 if (boundary_info_cache.verts[i].test()) {
76 num_true++;
77 }
78 }
79 ASSERT_EQ(num_true, mesh->verts_num);
80 ASSERT_EQ(boundary_info_cache.edges.size(), 6);
81 ASSERT_NE(boundary_info_cache.edges.size(), mesh->edges().size());
82}
83
84} // namespace blender::ed::sculpt_paint::tests
SculptBoundaryInfoCache create_boundary_info(const Mesh &mesh)
Definition sculpt.cc:599
TEST_F(MeshBrushCommonTests, calc_vert_neighbors_interior__cube)
Mesh * create_cuboid_mesh(const float3 &size, int verts_x, int verts_y, int verts_z, std::optional< StringRef > uv_id)
Mesh * create_grid_mesh(int verts_x, int verts_y, float size_x, float size_y, std::optional< StringRef > uv_map_id)
void BKE_id_free(Main *bmain, void *idv)
VecBase< float, 3 > float3