Blender  V2.93
bmesh_core_test.cc
Go to the documentation of this file.
1 #include "testing/testing.h"
2 
3 #include "BLI_math.h"
4 #include "BLI_utildefines.h"
5 #include "bmesh.h"
6 
7 TEST(bmesh_core, BMVertCreate)
8 {
9  BMesh *bm;
10  BMVert *bv1, *bv2, *bv3;
11  const float co1[3] = {1.0f, 2.0f, 0.0f};
12 
13  BMeshCreateParams bm_params;
14  bm_params.use_toolflags = true;
16  EXPECT_EQ(bm->totvert, 0);
17  /* make a custom layer so we can see if it is copied properly */
19  bv1 = BM_vert_create(bm, co1, nullptr, BM_CREATE_NOP);
20  ASSERT_TRUE(bv1 != nullptr);
21  EXPECT_EQ(bv1->co[0], 1.0f);
22  EXPECT_EQ(bv1->co[1], 2.0f);
23  EXPECT_EQ(bv1->co[2], 0.0f);
24  EXPECT_TRUE(is_zero_v3(bv1->no));
25  EXPECT_EQ(bv1->head.htype, (char)BM_VERT);
26  EXPECT_EQ(bv1->head.hflag, 0);
27  EXPECT_EQ(bv1->head.api_flag, 0);
28  bv2 = BM_vert_create(bm, nullptr, nullptr, BM_CREATE_NOP);
29  ASSERT_TRUE(bv2 != nullptr);
30  EXPECT_TRUE(is_zero_v3(bv2->co));
31  /* create with example should copy custom data but not select flag */
32  BM_vert_select_set(bm, bv2, true);
34  bv3 = BM_vert_create(bm, co1, bv2, BM_CREATE_NOP);
35  ASSERT_TRUE(bv3 != nullptr);
36  EXPECT_FALSE(BM_elem_flag_test((BMElem *)bv3, BM_ELEM_SELECT));
40 }
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
MINLINE bool is_zero_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
@ CD_PROP_FLOAT
@ BM_VERT
Definition: bmesh_class.h:383
@ BM_ELEM_SELECT
Definition: bmesh_class.h:471
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.c:58
@ BM_CREATE_NOP
Definition: bmesh_core.h:27
TEST(bmesh_core, BMVertCreate)
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:26
float BM_elem_float_data_get(CustomData *cd, void *element, int type)
void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:894
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.c:46
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
Definition: bmesh_mesh.c:307
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const struct BMeshCreateParams *params)
BMesh Make Mesh.
Definition: bmesh_mesh.c:157
int BM_mesh_elem_count(BMesh *bm, const char htype)
Definition: bmesh_mesh.c:2444
char htype
Definition: bmesh_class.h:76
char hflag
Definition: bmesh_class.h:78
char api_flag
Definition: bmesh_class.h:86
float co[3]
Definition: bmesh_class.h:99
float no[3]
Definition: bmesh_class.h:100
BMHeader head
Definition: bmesh_class.h:97
int totvert
Definition: bmesh_class.h:297
CustomData vdata
Definition: bmesh_class.h:337