Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/bmesh/operators')
-rw-r--r--source/blender/bmesh/operators/bmo_connect_nonplanar.c4
-rw-r--r--source/blender/bmesh/operators/bmo_connect_pair.c24
-rw-r--r--source/blender/bmesh/operators/bmo_create.c1
-rw-r--r--source/blender/bmesh/operators/bmo_poke.c15
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c32
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c4
6 files changed, 34 insertions, 46 deletions
diff --git a/source/blender/bmesh/operators/bmo_connect_nonplanar.c b/source/blender/bmesh/operators/bmo_connect_nonplanar.c
index ac88ffb9065..8112844fc8a 100644
--- a/source/blender/bmesh/operators/bmo_connect_nonplanar.c
+++ b/source/blender/bmesh/operators/bmo_connect_nonplanar.c
@@ -24,7 +24,7 @@
static float bm_face_subset_calc_planar(BMLoop *l_first, BMLoop *l_last, const float no[3])
{
float axis_mat[3][3];
- float z_prev, z_curr;
+ float z_prev;
float delta_z = 0.0f;
/* Newell's Method */
@@ -35,7 +35,7 @@ static float bm_face_subset_calc_planar(BMLoop *l_first, BMLoop *l_last, const f
z_prev = dot_m3_v3_row_z(axis_mat, l_last->v->co);
do {
- z_curr = dot_m3_v3_row_z(axis_mat, l_iter->v->co);
+ const float z_curr = dot_m3_v3_row_z(axis_mat, l_iter->v->co);
delta_z += fabsf(z_curr - z_prev);
z_prev = z_curr;
} while ((l_iter = l_iter->next) != l_term);
diff --git a/source/blender/bmesh/operators/bmo_connect_pair.c b/source/blender/bmesh/operators/bmo_connect_pair.c
index e91dab3dd6f..26f1a9e626e 100644
--- a/source/blender/bmesh/operators/bmo_connect_pair.c
+++ b/source/blender/bmesh/operators/bmo_connect_pair.c
@@ -83,7 +83,7 @@ typedef struct PathContext {
/* only to access BMO flags */
BMesh *bm_bmoflag;
- BMVert *v_a, *v_b;
+ BMVert *v_pair[2];
BLI_mempool *link_pool;
} PathContext;
@@ -593,17 +593,17 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
}
pc.bm_bmoflag = bm;
- pc.v_a = ((BMVert **)op_verts_slot->data.p)[0];
- pc.v_b = ((BMVert **)op_verts_slot->data.p)[1];
+ pc.v_pair[0] = ((BMVert **)op_verts_slot->data.p)[0];
+ pc.v_pair[1] = ((BMVert **)op_verts_slot->data.p)[1];
/* fail! */
- if (!(pc.v_a && pc.v_b)) {
+ if (!(pc.v_pair[0] && pc.v_pair[1])) {
return;
}
#ifdef DEBUG_PRINT
- printf("%s: v_a: %d\n", __func__, BM_elem_index_get(pc.v_a));
- printf("%s: v_b: %d\n", __func__, BM_elem_index_get(pc.v_b));
+ printf("%s: v_pair[0]: %d\n", __func__, BM_elem_index_get(pc.v_pair[0]));
+ printf("%s: v_pair[1]: %d\n", __func__, BM_elem_index_get(pc.v_pair[1]));
#endif
/* tag so we won't touch ever (typically hidden faces) */
@@ -618,15 +618,15 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
/* calculate matrix */
{
- bm_vert_pair_to_matrix(&pc.v_a, pc.matrix);
- pc.axis_sep = dot_m3_v3_row_x(pc.matrix, pc.v_a->co);
+ bm_vert_pair_to_matrix(pc.v_pair, pc.matrix);
+ pc.axis_sep = dot_m3_v3_row_x(pc.matrix, pc.v_pair[0]->co);
}
/* add first vertex */
{
PathLinkState *state;
state = MEM_callocN(sizeof(*state), __func__);
- state_link_add(&pc, state, (BMElem *)pc.v_a, NULL);
+ state_link_add(&pc, state, (BMElem *)pc.v_pair[0], NULL);
BLI_heapsimple_insert(pc.states, state->dist, state);
}
@@ -642,7 +642,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
/* either we insert this into 'pc.states' or its freed */
bool continue_search;
- if (state->link_last->ele == (BMElem *)pc.v_b) {
+ if (state->link_last->ele == (BMElem *)pc.v_pair[1]) {
/* pass, wait until all are found */
#ifdef DEBUG_PRINT
printf("%s: state %p loop found %.4f\n", __func__, state, state->dist);
@@ -698,8 +698,8 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
} while ((link = link->next));
}
- BMO_vert_flag_enable(bm, pc.v_a, VERT_OUT);
- BMO_vert_flag_enable(bm, pc.v_b, VERT_OUT);
+ BMO_vert_flag_enable(bm, pc.v_pair[0], VERT_OUT);
+ BMO_vert_flag_enable(bm, pc.v_pair[1], VERT_OUT);
BLI_mempool_destroy(pc.link_pool);
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index a809fe6ee3d..9dba48a8961 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -77,7 +77,6 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
* | .
* | .
* +........+ <-- starts out free standing.
- *
*/
/* Here we check for consistency and create 2 edges */
diff --git a/source/blender/bmesh/operators/bmo_poke.c b/source/blender/bmesh/operators/bmo_poke.c
index 7ff3b9b072c..6622dbf7575 100644
--- a/source/blender/bmesh/operators/bmo_poke.c
+++ b/source/blender/bmesh/operators/bmo_poke.c
@@ -52,8 +52,7 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
}
BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
- BMFace *f_new;
- float f_center[3], f_center_mean[3];
+ float f_center[3];
BMVert *v_center = NULL;
BMLoop *l_iter, *l_first;
/* only interpolate the central loop from the face once,
@@ -69,15 +68,6 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
v_center = BM_vert_create(bm, f_center, NULL, BM_CREATE_NOP);
BMO_vert_flag_enable(bm, v_center, ELE_NEW);
- if (cd_loop_mdisp_offset != -1) {
- if (center_mode == BMOP_POKE_MEDIAN) {
- copy_v3_v3(f_center_mean, f_center);
- }
- else {
- BM_face_calc_center_median(f, f_center_mean);
- }
- }
-
/* handled by BM_loop_interp_from_face */
// BM_vert_interp_from_face(bm, v_center, f);
@@ -92,8 +82,7 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
BMLoop *l_new;
-
- f_new = BM_face_create_quad_tri(
+ BMFace *f_new = BM_face_create_quad_tri(
bm, l_iter->v, l_iter->next->v, v_center, NULL, f, BM_CREATE_NOP);
l_new = BM_FACE_FIRST_LOOP(f_new);
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index 432c7590f3c..c60ffbedb94 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -855,12 +855,12 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
/* one segment first */
for (a = 0; a <= tot; a++) {
/* Going in this direction, then edge extruding, makes normals face outward */
- /* Calculate with doubles for higher precision, see: T87779. */
- const float phi = M_PI * ((double)a / (double)tot);
+ float sin_phi, cos_phi;
+ sin_cos_from_fraction(a, 2 * tot, &sin_phi, &cos_phi);
- vec[0] = 0.0;
- vec[1] = rad * sinf(phi);
- vec[2] = rad * cosf(phi);
+ vec[0] = 0.0f;
+ vec[1] = rad * sin_phi;
+ vec[2] = rad * cos_phi;
eve = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
BMO_vert_flag_enable(bm, eve, VERT_MARK);
@@ -1262,11 +1262,9 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
for (a = 0; a < segs; a++) {
/* Going this way ends up with normal(s) upward */
-
- /* Calculate with doubles for higher precision, see: T87779. */
- const float phi = (2.0 * M_PI) * ((double)a / (double)segs);
- vec[0] = -radius * sinf(phi);
- vec[1] = radius * cosf(phi);
+ sin_cos_from_fraction(a, segs, &vec[0], &vec[1]);
+ vec[0] *= -radius;
+ vec[1] *= radius;
vec[2] = 0.0f;
mul_m4_v3(mat, vec);
v1 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
@@ -1393,16 +1391,18 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
BMFace **side_faces = MEM_mallocN(sizeof(*side_faces) * side_faces_len, __func__);
for (int i = 0; i < segs; i++) {
- /* Calculate with doubles for higher precision, see: T87779. */
- const float phi = (2.0 * M_PI) * ((double)i / (double)segs);
- vec[0] = rad1 * sinf(phi);
- vec[1] = rad1 * cosf(phi);
+ /* Calculate with higher precision, see: T87779. */
+ float sin_phi, cos_phi;
+ sin_cos_from_fraction(i, segs, &sin_phi, &cos_phi);
+
+ vec[0] = rad1 * sin_phi;
+ vec[1] = rad1 * cos_phi;
vec[2] = -depth_half;
mul_m4_v3(mat, vec);
v1 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
- vec[0] = rad2 * sinf(phi);
- vec[1] = rad2 * cosf(phi);
+ vec[0] = rad2 * sin_phi;
+ vec[1] = rad2 * cos_phi;
vec[2] = depth_half;
mul_m4_v3(mat, vec);
v2 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index 309ef2cf21e..d88f3112a71 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -470,7 +470,7 @@ void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
BMLoop *lf; /* current face loops */
MLoopUV *f_luv; /* first face loop uv */
float p_uv[2]; /* previous uvs */
- float t_uv[2]; /* tmp uvs */
+ float t_uv[2]; /* temp uvs */
int n = 0;
BM_ITER_ELEM (lf, &l_iter, fs, BM_LOOPS_OF_FACE) {
@@ -603,7 +603,7 @@ void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
const size_t size = cd_loop_color_type == CD_PROP_COLOR ? sizeof(MPropCol) : sizeof(MLoopCol);
void *p_col; /* previous color */
- void *t_col = alloca(size); /* tmp color */
+ void *t_col = alloca(size); /* Temp color. */
BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
if (use_ccw == false) { /* same loops direction */