[Bf-blender-cvs] [27a5da4dc3a] master: Cleanup: use uint8_t for various flags in curves
Jacques Lucke
noreply at git.blender.org
Wed Sep 16 12:23:46 CEST 2020
Commit: 27a5da4dc3a399e1fe7e88dc8722a891e9cfcf78
Author: Jacques Lucke
Date: Wed Sep 16 12:23:23 2020 +0200
Branches: master
https://developer.blender.org/rB27a5da4dc3a399e1fe7e88dc8722a891e9cfcf78
Cleanup: use uint8_t for various flags in curves
Previously, it was kind of a mess. In different places it was using `char`, `short` and `int`.
The changed properties are flags that are operated upon using bit operations. Therefore, the integer type should be unsigned. Since we only use 2 bits of these flags, `uint8_t` is large enough.
Especially note the change I had to make in `RNA_define.h` to make this work.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D8844
===================================================================
M source/blender/blenkernel/BKE_curve.h
M source/blender/blenkernel/BKE_lattice.h
M source/blender/blenkernel/intern/curve.c
M source/blender/blenkernel/intern/lattice.c
M source/blender/blenkernel/intern/mask.c
M source/blender/draw/intern/draw_cache_impl_curve.c
M source/blender/editors/animation/keyframes_edit.c
M source/blender/editors/curve/curve_intern.h
M source/blender/editors/curve/editcurve.c
M source/blender/editors/curve/editcurve_query.c
M source/blender/editors/curve/editcurve_select.c
M source/blender/editors/space_view3d/view3d_select.c
M source/blender/editors/transform/transform_data.h
M source/blender/makesdna/DNA_curve_types.h
M source/blender/makesrna/RNA_define.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 5930578c505..344338d4802 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -171,11 +171,11 @@ void BKE_nurbList_duplicate(struct ListBase *lb1, const struct ListBase *lb2);
void BKE_nurbList_handles_set(struct ListBase *editnurb, const char code);
void BKE_nurbList_handles_recalculate(struct ListBase *editnurb,
const bool calc_length,
- const char flag);
+ const uint8_t flag);
-void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag);
-void BKE_nurbList_flag_set(ListBase *editnurb, short flag, bool set);
-bool BKE_nurbList_flag_set_from_flag(ListBase *editnurb, short from_flag, short flag);
+void BKE_nurbList_handles_autocalc(ListBase *editnurb, uint8_t flag);
+void BKE_nurbList_flag_set(ListBase *editnurb, uint8_t flag, bool set);
+bool BKE_nurbList_flag_set_from_flag(ListBase *editnurb, uint8_t from_flag, uint8_t flag);
void BKE_nurb_free(struct Nurb *nu);
struct Nurb *BKE_nurb_duplicate(const struct Nurb *nu);
@@ -260,7 +260,7 @@ void BKE_nurb_handle_calc_simple_auto(struct Nurb *nu, struct BezTriple *bezt);
void BKE_nurb_handle_smooth_fcurve(struct BezTriple *bezt, int total, bool cyclic);
void BKE_nurb_handles_calc(struct Nurb *nu);
-void BKE_nurb_handles_autocalc(struct Nurb *nu, int flag);
+void BKE_nurb_handles_autocalc(struct Nurb *nu, uint8_t flag);
void BKE_nurb_bezt_handle_test(struct BezTriple *bezt,
const eBezTriple_Flag__Alias sel_flag,
const bool use_handle,
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index ee7744ece15..e210c022d85 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -77,7 +77,7 @@ int BKE_lattice_index_flip(
struct Lattice *lt, const int index, const bool flip_u, const bool flip_v, const bool flip_w);
void BKE_lattice_bitmap_from_flag(struct Lattice *lt,
unsigned int *bitmap,
- const short flag,
+ const uint8_t flag,
const bool clear,
const bool respecthide);
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index dfa8d65d117..74efa45cc73 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -4224,7 +4224,7 @@ void BKE_nurb_handles_test(Nurb *nu, const bool use_handle, const bool use_aroun
BKE_nurb_handles_calc(nu);
}
-void BKE_nurb_handles_autocalc(Nurb *nu, int flag)
+void BKE_nurb_handles_autocalc(Nurb *nu, uint8_t flag)
{
/* checks handle coordinates and calculates type */
const float eps = 0.0001f;
@@ -4305,7 +4305,7 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag)
BKE_nurb_handles_calc(nu);
}
-void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag)
+void BKE_nurbList_handles_autocalc(ListBase *editnurb, uint8_t flag)
{
Nurb *nu;
@@ -4410,7 +4410,9 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
}
}
-void BKE_nurbList_handles_recalculate(ListBase *editnurb, const bool calc_length, const char flag)
+void BKE_nurbList_handles_recalculate(ListBase *editnurb,
+ const bool calc_length,
+ const uint8_t flag)
{
Nurb *nu;
BezTriple *bezt;
@@ -4464,7 +4466,7 @@ void BKE_nurbList_handles_recalculate(ListBase *editnurb, const bool calc_length
}
}
-void BKE_nurbList_flag_set(ListBase *editnurb, short flag, bool set)
+void BKE_nurbList_flag_set(ListBase *editnurb, uint8_t flag, bool set)
{
Nurb *nu;
BezTriple *bezt;
@@ -4503,7 +4505,7 @@ void BKE_nurbList_flag_set(ListBase *editnurb, short flag, bool set)
/**
* Set \a flag for every point that already has \a from_flag set.
*/
-bool BKE_nurbList_flag_set_from_flag(ListBase *editnurb, short from_flag, short flag)
+bool BKE_nurbList_flag_set_from_flag(ListBase *editnurb, uint8_t from_flag, uint8_t flag)
{
bool changed = false;
@@ -4511,7 +4513,7 @@ bool BKE_nurbList_flag_set_from_flag(ListBase *editnurb, short from_flag, short
if (nu->type == CU_BEZIER) {
for (int i = 0; i < nu->pntsu; i++) {
BezTriple *bezt = &nu->bezt[i];
- int old_f1 = bezt->f1, old_f2 = bezt->f2, old_f3 = bezt->f3;
+ uint8_t old_f1 = bezt->f1, old_f2 = bezt->f2, old_f3 = bezt->f3;
SET_FLAG_FROM_TEST(bezt->f1, bezt->f1 & from_flag, flag);
SET_FLAG_FROM_TEST(bezt->f2, bezt->f2 & from_flag, flag);
@@ -4523,7 +4525,7 @@ bool BKE_nurbList_flag_set_from_flag(ListBase *editnurb, short from_flag, short
else {
for (int i = 0; i < nu->pntsu * nu->pntsv; i++) {
BPoint *bp = &nu->bp[i];
- int old_f1 = bp->f1;
+ uint8_t old_f1 = bp->f1;
SET_FLAG_FROM_TEST(bp->f1, bp->f1 & from_flag, flag);
changed |= (old_f1 != bp->f1);
@@ -4564,12 +4566,12 @@ void BKE_nurb_direction_switch(Nurb *nu)
swap_v3_v3(bezt2->vec[0], bezt2->vec[2]);
}
- SWAP(char, bezt1->h1, bezt1->h2);
- SWAP(char, bezt1->f1, bezt1->f3);
+ SWAP(uint8_t, bezt1->h1, bezt1->h2);
+ SWAP(uint8_t, bezt1->f1, bezt1->f3);
if (bezt1 != bezt2) {
- SWAP(char, bezt2->h1, bezt2->h2);
- SWAP(char, bezt2->f1, bezt2->f3);
+ SWAP(uint8_t, bezt2->h1, bezt2->h2);
+ SWAP(uint8_t, bezt2->f1, bezt2->f3);
bezt1->tilt = -bezt1->tilt;
bezt2->tilt = -bezt2->tilt;
}
@@ -4993,7 +4995,7 @@ bool BKE_nurb_type_convert(Nurb *nu,
bp++;
}
else {
- const char *f = &bezt->f1;
+ const uint8_t *f = &bezt->f1;
for (c = 0; c < 3; c++, f++) {
copy_v3_v3(bp->vec, bezt->vec[c]);
bp->vec[3] = 1.0;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index a3267c0762e..8725fcd86f9 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -246,7 +246,7 @@ int BKE_lattice_index_flip(
}
void BKE_lattice_bitmap_from_flag(
- Lattice *lt, BLI_bitmap *bitmap, const short flag, const bool clear, const bool respecthide)
+ Lattice *lt, BLI_bitmap *bitmap, const uint8_t flag, const bool clear, const bool respecthide)
{
const unsigned int tot = lt->pntsu * lt->pntsv * lt->pntsw;
BPoint *bp;
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index c8c4fea7ab1..8ef3d77d5e8 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -523,8 +523,8 @@ void BKE_mask_point_direction_switch(MaskSplinePoint *point)
copy_v2_v2(point->bezt.vec[0], point->bezt.vec[2]);
copy_v2_v2(point->bezt.vec[2], co_tmp);
/* in this case the flags are unlikely to be different but swap anyway */
- SWAP(char, point->bezt.f1, point->bezt.f3);
- SWAP(char, point->bezt.h1, point->bezt.h2);
+ SWAP(uint8_t, point->bezt.f1, point->bezt.f3);
+ SWAP(uint8_t, point->bezt.h1, point->bezt.h2);
/* swap UW's */
if (tot_uw > 1) {
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index b93c782a5b9..938c26a9cdf 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -686,15 +686,15 @@ static void curve_create_edit_curves_nor(CurveRenderData *rdata, GPUVertBuf *vbo
BLI_assert(vbo_len_used == verts_len_capacity);
}
-static char beztriple_vflag_get(CurveRenderData *rdata,
- char flag,
- char col_id,
- int v_idx,
- int nu_id,
- bool handle_point,
- const bool handle_selected)
+static uint8_t beztriple_vflag_get(CurveRenderData *rdata,
+ uint8_t flag,
+ uint8_t col_id,
+ int v_idx,
+ int nu_id,
+ bool handle_point,
+ const bool handle_selected)
{
- char vflag = 0;
+ uint8_t vflag = 0;
SET_FLAG_FROM_TEST(vflag, (flag & SELECT), VFLAG_VERT_SELECTED);
SET_FLAG_FROM_TEST(vflag, (v_idx == rdata->actvert && nu_id == rdata->actnu), VFLAG_VERT_ACTIVE);
SET_FLAG_FROM_TEST(vflag, (nu_id == rdata->actnu), ACTIVE_NURB);
@@ -707,9 +707,9 @@ static char beztriple_vflag_get(CurveRenderData *rdata,
return vflag;
}
-static char bpoint_vflag_get(CurveRenderData *rdata, char flag, int v_idx, int nu_id, int u)
+static uint8_t bpoint_vflag_get(CurveRenderData *rdata, uint8_t flag, int v_idx, int nu_id, int u)
{
- char vflag = 0;
+ uint8_t vflag = 0;
SET_FLAG_FROM_TEST(vflag, (flag & SELECT), VFLAG_VERT_SELECTED);
SET_FLAG_FROM_TEST(vflag, (v_idx == rdata->actvert && nu_id == rdata->actnu), VFLAG_VERT_ACTIVE);
SET_FLAG_FROM_TEST(vflag, (nu_id == rdata->actnu), ACTIVE_NURB);
@@ -783,7 +783,7 @@ static void curve_create_edit_data_and_handles(CurveRenderData *rdata,
GPU_indexbuf_add_line_verts(elbp_lines, vbo_len_used + 1, vbo_len_used + 2);
}
if (vbo_data) {
- const char vflag[3] = {
+ const uint8_t vflag[3] = {
beztriple_vflag_get(rdata, bezt->f1, bezt->h1, a, nu_id, true, handle_selected),
beztriple_vflag_get(rdata, bezt->f2, bezt->h1, a, nu_id, false, handle_selected),
beztriple_vflag_get(rdata, bezt->f3, bezt->h2, a, nu_id, true, handle_selected),
@@ -824,7 +824,7 @@ static void curve_create_edit_data_and_handles(CurveRenderData *rdata,
}
}
if (vbo_data) {
- char vflag = bpoint_vflag_get(rdata, bp->f1, a, nu_id, u);
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list