diff options
author | Jacques Lucke <jacques@blender.org> | 2020-09-16 13:23:23 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-09-16 13:23:23 +0300 |
commit | 27a5da4dc3a399e1fe7e88dc8722a891e9cfcf78 (patch) | |
tree | 7ad797f8746a58e527ed301bf7bcab4a389bb687 /source/blender/blenkernel | |
parent | d376aea61840587eddcf75386b804673e5593d60 (diff) |
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
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_curve.h | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_lattice.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 26 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 4 |
5 files changed, 23 insertions, 21 deletions
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) { |