Blender V4.3
bmesh_core_test.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "testing/testing.h"
6
7#include "BLI_math_vector.h"
8#include "BLI_utildefines.h"
9#include "bmesh.hh"
10
11TEST(bmesh_core, BMVertCreate)
12{
13 BMesh *bm;
14 BMVert *bv1, *bv2, *bv3;
15 const float co1[3] = {1.0f, 2.0f, 0.0f};
16
17 BMeshCreateParams bmesh_create_params{};
18 bmesh_create_params.use_toolflags = true;
19 bm = BM_mesh_create(&bm_mesh_allocsize_default, &bmesh_create_params);
20 EXPECT_EQ(bm->totvert, 0);
21 /* make a custom layer so we can see if it is copied properly */
23 bv1 = BM_vert_create(bm, co1, nullptr, BM_CREATE_NOP);
24 ASSERT_TRUE(bv1 != nullptr);
25 EXPECT_EQ(bv1->co[0], 1.0f);
26 EXPECT_EQ(bv1->co[1], 2.0f);
27 EXPECT_EQ(bv1->co[2], 0.0f);
28 EXPECT_TRUE(is_zero_v3(bv1->no));
29 EXPECT_EQ(bv1->head.htype, char(BM_VERT));
30 EXPECT_EQ(bv1->head.hflag, 0);
31 EXPECT_EQ(bv1->head.api_flag, 0);
32 bv2 = BM_vert_create(bm, nullptr, nullptr, BM_CREATE_NOP);
33 ASSERT_TRUE(bv2 != nullptr);
34 EXPECT_TRUE(is_zero_v3(bv2->co));
35 /* create with example should copy custom data but not select flag */
36 BM_vert_select_set(bm, bv2, true);
38 bv3 = BM_vert_create(bm, co1, bv2, BM_CREATE_NOP);
39 ASSERT_TRUE(bv3 != nullptr);
40 EXPECT_FALSE(BM_elem_flag_test((BMElem *)bv3, BM_ELEM_SELECT));
44}
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
@ CD_PROP_FLOAT
@ BM_ELEM_SELECT
BMVert * BM_vert_create(BMesh *bm, const float co[3], const BMVert *v_example, const eBMCreateFlag create_flag)
Main function for creating a new vertex.
Definition bmesh_core.cc:43
@ BM_CREATE_NOP
Definition bmesh_core.hh:24
TEST(bmesh_core, BMVertCreate)
#define BM_elem_flag_test(ele, hflag)
float BM_elem_float_data_get(CustomData *cd, void *element, int type)
void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
void BM_elem_float_data_set(CustomData *cd, void *element, int type, const float val)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select)
Select Vert.
const BMAllocTemplate bm_mesh_allocsize_default
Definition bmesh_mesh.cc:29
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
int BM_mesh_elem_count(BMesh *bm, const char htype)
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
#define BM_VERT
char api_flag
float co[3]
float no[3]
BMHeader head
int totvert
CustomData vdata