[Bf-blender-cvs] [fb08353f386] master: Cleanup: replace ParamBool and PBool with bool for GEO_uv API
Chris Blackbourn
noreply at git.blender.org
Thu Jun 2 01:53:04 CEST 2022
Commit: fb08353f3864c512e20822e802f24bb1b827f28f
Author: Chris Blackbourn
Date: Thu Jun 2 09:48:53 2022 +1000
Branches: master
https://developer.blender.org/rBfb08353f3864c512e20822e802f24bb1b827f28f
Cleanup: replace ParamBool and PBool with bool for GEO_uv API
Also improve const correctness and type correctness.
Reviewed By: brecht
Ref D15075
===================================================================
M source/blender/editors/uvedit/uvedit_unwrap_ops.c
M source/blender/geometry/GEO_uv_parametrizer.h
M source/blender/geometry/intern/uv_parametrizer.c
===================================================================
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index f24057920d7..cbc9b2a8d06 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -301,22 +301,19 @@ void ED_uvedit_get_aspect(Object *ob, float *r_aspx, float *r_aspy)
static void construct_param_handle_face_add(ParamHandle *handle,
const Scene *scene,
BMFace *efa,
- int face_index,
+ ParamKey face_index,
const int cd_loop_uv_offset)
{
- ParamKey key;
ParamKey *vkeys = BLI_array_alloca(vkeys, efa->len);
- ParamBool *pin = BLI_array_alloca(pin, efa->len);
- ParamBool *select = BLI_array_alloca(select, efa->len);
- float **co = BLI_array_alloca(co, efa->len);
+ bool *pin = BLI_array_alloca(pin, efa->len);
+ bool *select = BLI_array_alloca(select, efa->len);
+ const float **co = BLI_array_alloca(co, efa->len);
float **uv = BLI_array_alloca(uv, efa->len);
int i;
BMIter liter;
BMLoop *l;
- key = (ParamKey)face_index;
-
/* let parametrizer split the ngon, it can make better decisions
* about which split is best for unwrapping than poly-fill. */
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
@@ -329,7 +326,7 @@ static void construct_param_handle_face_add(ParamHandle *handle,
select[i] = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
}
- GEO_uv_parametrizer_face_add(handle, key, i, vkeys, co, uv, pin, select);
+ GEO_uv_parametrizer_face_add(handle, face_index, i, vkeys, co, uv, pin, select);
}
/* See: construct_param_handle_multi to handle multiple objects at once. */
@@ -500,8 +497,8 @@ static void texface_from_original_index(const Scene *scene,
BMFace *efa,
int index,
float **r_uv,
- ParamBool *r_pin,
- ParamBool *r_select)
+ bool *r_pin,
+ bool *r_select)
{
BMLoop *l;
BMIter liter;
@@ -633,8 +630,8 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene,
/* Prepare and feed faces to the solver */
for (i = 0, mpoly = subsurfedPolys; i < numOfFaces; i++, mpoly++) {
ParamKey key, vkeys[4];
- ParamBool pin[4], select[4];
- float *co[4];
+ bool pin[4], select[4];
+ const float *co[4];
float *uv[4];
BMFace *origFace = faceMap[i];
@@ -1245,7 +1242,7 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
handle = construct_param_handle(scene, obedit, em->bm, &options, NULL);
}
- GEO_uv_parametrizer_lscm_begin(handle, PARAM_TRUE, abf);
+ GEO_uv_parametrizer_lscm_begin(handle, true, abf);
/* Create or increase size of g_live_unwrap.handles array */
if (g_live_unwrap.handles == NULL) {
@@ -1796,7 +1793,7 @@ static void uvedit_unwrap(const Scene *scene,
handle = construct_param_handle(scene, obedit, em->bm, options, result_info);
}
- GEO_uv_parametrizer_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
+ GEO_uv_parametrizer_lscm_begin(handle, false, scene->toolsettings->unwrapper == 0);
GEO_uv_parametrizer_lscm_solve(handle,
result_info ? &result_info->count_changed : NULL,
result_info ? &result_info->count_failed : NULL);
diff --git a/source/blender/geometry/GEO_uv_parametrizer.h b/source/blender/geometry/GEO_uv_parametrizer.h
index 38121646cd5..7fe60a3a855 100644
--- a/source/blender/geometry/GEO_uv_parametrizer.h
+++ b/source/blender/geometry/GEO_uv_parametrizer.h
@@ -14,10 +14,6 @@ extern "C" {
typedef struct ParamHandle ParamHandle; /* Handle to an array of charts. */
typedef intptr_t ParamKey; /* Key (hash) for identifying verts and faces. */
-typedef enum ParamBool {
- PARAM_TRUE = 1,
- PARAM_FALSE = 0,
-} ParamBool;
/* -------------------------------------------------------------------- */
/** \name Chart Construction:
@@ -39,19 +35,19 @@ ParamHandle *GEO_uv_parametrizer_construct_begin(void);
void GEO_uv_parametrizer_aspect_ratio(ParamHandle *handle, float aspx, float aspy);
void GEO_uv_parametrizer_face_add(ParamHandle *handle,
- ParamKey key,
- int nverts,
- ParamKey *vkeys,
- float *co[4],
- float *uv[4],
- ParamBool *pin,
- ParamBool *select);
+ const ParamKey key,
+ const int nverts,
+ const ParamKey *vkeys,
+ const float **co,
+ float **uv, /* Output will eventually be written to `uv`. */
+ const bool *pin,
+ const bool *select);
void GEO_uv_parametrizer_edge_set_seam(ParamHandle *handle, ParamKey *vkeys);
void GEO_uv_parametrizer_construct_end(ParamHandle *handle,
- ParamBool fill,
- ParamBool topology_from_uvs,
+ bool fill,
+ bool topology_from_uvs,
int *count_fail);
void GEO_uv_parametrizer_delete(ParamHandle *handle);
@@ -70,7 +66,7 @@ void GEO_uv_parametrizer_delete(ParamHandle *handle);
*
* \{ */
-void GEO_uv_parametrizer_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf);
+void GEO_uv_parametrizer_lscm_begin(ParamHandle *handle, bool live, bool abf);
void GEO_uv_parametrizer_lscm_solve(ParamHandle *handle, int *count_changed, int *count_failed);
void GEO_uv_parametrizer_lscm_end(ParamHandle *handle);
diff --git a/source/blender/geometry/intern/uv_parametrizer.c b/source/blender/geometry/intern/uv_parametrizer.c
index 87dd6bc7547..af3bcc3bdec 100644
--- a/source/blender/geometry/intern/uv_parametrizer.c
+++ b/source/blender/geometry/intern/uv_parametrizer.c
@@ -36,11 +36,6 @@
#define param_warning(message) \
{/*printf("Warning %s:%d: %s\n", __FILE__, __LINE__, message);*/}(void)0
-typedef enum PBool {
- P_TRUE = 1,
- P_FALSE = 0,
-} PBool;
-
/* Special Purpose Hash */
typedef intptr_t PHashKey;
@@ -509,53 +504,26 @@ static void UNUSED_FUNCTION(p_chart_uv_from_array)(PChart *chart, float (*points
}
}
-static PBool p_intersect_line_2d_dir(const float v1[2],
- const float dir1[2],
- const float v2[2],
- const float dir2[2],
- float r_isect[2])
+static bool p_intersect_line_2d_dir(const float v1[2],
+ const float dir1[2],
+ const float v2[2],
+ const float dir2[2],
+ float r_isect[2])
{
float lmbda, div;
div = dir2[0] * dir1[1] - dir2[1] * dir1[0];
if (div == 0.0f) {
- return P_FALSE;
+ return false;
}
lmbda = ((v1[1] - v2[1]) * dir1[0] - (v1[0] - v2[0]) * dir1[1]) / div;
r_isect[0] = v1[0] + lmbda * dir2[0];
r_isect[1] = v1[1] + lmbda * dir2[1];
- return P_TRUE;
-}
-
-#if 0
-static PBool p_intersect_line_2d(const float v1[2],
- const float v2[2],
- const float v3[2],
- const float v4[2],
- const float r_isect[2])
-{
- float dir1[2], dir2[2];
-
- dir1[0] = v4[0] - v3[0];
- dir1[1] = v4[1] - v3[1];
-
- dir2[0] = v2[0] - v1[0];
- dir2[1] = v2[1] - v1[1];
-
- if (!p_intersect_line_2d_dir(v1, dir1, v2, dir2, isect)) {
- /* parallel - should never happen in theory for polygon kernel, but
- * let's give a point nearby in case things go wrong */
- isect[0] = (v1[0] + v2[0]) * 0.5f;
- isect[1] = (v1[1] + v2[1]) * 0.5f;
- return P_FALSE;
- }
-
- return P_TRUE;
+ return true;
}
-#endif
/* Topological Utilities */
@@ -586,9 +554,9 @@ static PEdge *p_boundary_edge_prev(PEdge *e)
return last->next->next;
}
-static PBool p_vert_interior(PVert *v)
+static bool p_vert_interior(PVert *v)
{
- return (v->edge->pair != NULL);
+ return v->edge->pair;
}
static void p_face_flip(PFace *f)
@@ -807,7 +775,7 @@ static PEdge *p_edge_lookup(ParamHandle *handle, const PHashKey *vkeys)
return NULL;
}
-static int p_face_exists(ParamHandle *handle, ParamKey *pvkeys, int i1, int i2, int i3)
+static int p_face_exists(ParamHandle *handle, const ParamKey *pvkeys, int i1, int i2, int i3)
{
PHashKey *vkeys = (PHashKey *)pvkeys;
PHashKey key = PHASH_edge(vkeys[i1], vkeys[i2]);
@@ -816,19 +784,19 @@ static int p_face_exists(ParamHandle *handle, ParamKey *pvkeys, int i1, int i2,
while (e) {
if ((e->vert->u.key == vkeys[i1]) && (e->next->vert->u.key == vkeys[i2])) {
if (e->next->next->vert->u.key == vkeys[i3]) {
- return P_TRUE;
+ return true;
}
}
else if ((e->vert->u.key == vkeys[i2]) && (e->next->vert->u.key == vkeys[i1])) {
if (e->next->next->vert->u.key == vkeys[i3]) {
- return P_TRUE;
+ return true;
}
}
e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
}
- return P_FALSE;
+ return false;
}
static PChart *p_chart_new(ParamHandle *handle)
@@ -845,7 +813,7 @@ static void p_chart_delete(PChart *chart)
MEM_freeN(chart);
}
-static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep)
+static bool p_edge_implicit_seam(PEdge *e, PEdge *ep)
{
float *uv1, *uv2, *uvp1, *uvp2;
float limit[2];
@@ -868,21 +836,18 @@ static PBool p
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list