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
This commit is contained in:
parent
d376aea618
commit
27a5da4dc3
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
uint8_t vflag = bpoint_vflag_get(rdata, bp->f1, a, nu_id, u);
|
||||
GPU_vertbuf_attr_set(vbo_data, attr_id.data, vbo_len_used, &vflag);
|
||||
}
|
||||
if (vbo_pos) {
|
||||
|
|
|
@ -949,8 +949,8 @@ static void mirror_bezier_xaxis_ex(BezTriple *bezt, const float center)
|
|||
}
|
||||
swap_v3_v3(bezt->vec[0], bezt->vec[2]);
|
||||
|
||||
SWAP(char, bezt->h1, bezt->h2);
|
||||
SWAP(char, bezt->f1, bezt->f3);
|
||||
SWAP(uint8_t, bezt->h1, bezt->h2);
|
||||
SWAP(uint8_t, bezt->f1, bezt->f3);
|
||||
}
|
||||
|
||||
static void mirror_bezier_yaxis_ex(BezTriple *bezt, const float center)
|
||||
|
|
|
@ -71,8 +71,8 @@ typedef enum eCurveElem_Types {
|
|||
} eCurveElem_Types;
|
||||
|
||||
/* internal select utils */
|
||||
bool select_beztriple(BezTriple *bezt, bool selstatus, short flag, eVisible_Types hidden);
|
||||
bool select_bpoint(BPoint *bp, bool selstatus, short flag, bool hidden);
|
||||
bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Types hidden);
|
||||
bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden);
|
||||
|
||||
void FONT_OT_text_insert(struct wmOperatorType *ot);
|
||||
void FONT_OT_line_break(struct wmOperatorType *ot);
|
||||
|
@ -142,8 +142,8 @@ struct GHash *ED_curve_keyindex_hash_duplicate(struct GHash *keyindex);
|
|||
void ED_curve_keyindex_update_nurb(struct EditNurb *editnurb, struct Nurb *nu, struct Nurb *newnu);
|
||||
|
||||
/* helper functions */
|
||||
void ed_editnurb_translate_flag(struct ListBase *editnurb, short flag, const float vec[3]);
|
||||
bool ed_editnurb_extrude_flag(struct EditNurb *editnurb, const short flag);
|
||||
void ed_editnurb_translate_flag(struct ListBase *editnurb, uint8_t flag, const float vec[3]);
|
||||
bool ed_editnurb_extrude_flag(struct EditNurb *editnurb, const uint8_t flag);
|
||||
bool ed_editnurb_spin(float viewmat[4][4],
|
||||
struct View3D *v3d,
|
||||
struct Object *obedit,
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
|
||||
void selectend_nurb(Object *obedit, enum eEndPoint_Types selfirst, bool doswap, bool selstatus);
|
||||
static void adduplicateflagNurb(
|
||||
Object *obedit, View3D *v3d, ListBase *newnurb, const short flag, const bool split);
|
||||
Object *obedit, View3D *v3d, ListBase *newnurb, const uint8_t flag, const bool split);
|
||||
static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split);
|
||||
static bool curve_delete_vertices(Object *obedit, View3D *v3d);
|
||||
|
||||
|
@ -1600,7 +1600,7 @@ void CURVE_OT_split(wmOperatorType *ot)
|
|||
/** \name Flag Utility Functions
|
||||
* \{ */
|
||||
|
||||
static bool isNurbselUV(const Nurb *nu, int flag, int *r_u, int *r_v)
|
||||
static bool isNurbselUV(const Nurb *nu, uint8_t flag, int *r_u, int *r_v)
|
||||
{
|
||||
/* return (u != -1): 1 row in u-direction selected. U has value between 0-pntsv
|
||||
* return (v != -1): 1 column in v-direction selected. V has value between 0-pntsu
|
||||
|
@ -1743,7 +1743,7 @@ static void rotateflagNurb(ListBase *editnurb,
|
|||
}
|
||||
}
|
||||
|
||||
void ed_editnurb_translate_flag(ListBase *editnurb, short flag, const float vec[3])
|
||||
void ed_editnurb_translate_flag(ListBase *editnurb, uint8_t flag, const float vec[3])
|
||||
{
|
||||
/* all verts with ('flag' & flag) translate */
|
||||
Nurb *nu;
|
||||
|
@ -2052,7 +2052,7 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
|
|||
}
|
||||
|
||||
/* only for OB_SURF */
|
||||
bool ed_editnurb_extrude_flag(EditNurb *editnurb, const short flag)
|
||||
bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag)
|
||||
{
|
||||
Nurb *nu;
|
||||
BPoint *bp, *bpn, *newbp;
|
||||
|
@ -2194,7 +2194,7 @@ static bool calc_duplicate_actvert(
|
|||
}
|
||||
|
||||
static void adduplicateflagNurb(
|
||||
Object *obedit, View3D *v3d, ListBase *newnurb, const short flag, const bool split)
|
||||
Object *obedit, View3D *v3d, ListBase *newnurb, const uint8_t flag, const bool split)
|
||||
{
|
||||
ListBase *editnurb = object_editcurve_get(obedit);
|
||||
Nurb *nu, *newnu;
|
||||
|
|
|
@ -62,7 +62,7 @@ static void ED_curve_pick_vert__do_closest(void *userData,
|
|||
bool is_changed;
|
||||
} *data = userData;
|
||||
|
||||
short flag;
|
||||
uint8_t flag;
|
||||
float dist_test;
|
||||
|
||||
if (bp) {
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "DEG_depsgraph.h"
|
||||
|
||||
/* returns 1 in case (de)selection was successful */
|
||||
bool select_beztriple(BezTriple *bezt, bool selstatus, short flag, eVisible_Types hidden)
|
||||
bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Types hidden)
|
||||
{
|
||||
if ((bezt->hide == 0) || (hidden == HIDDEN)) {
|
||||
if (selstatus == SELECT) { /* selects */
|
||||
|
@ -77,7 +77,7 @@ bool select_beztriple(BezTriple *bezt, bool selstatus, short flag, eVisible_Type
|
|||
}
|
||||
|
||||
/* returns 1 in case (de)selection was successful */
|
||||
bool select_bpoint(BPoint *bp, bool selstatus, short flag, bool hidden)
|
||||
bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden)
|
||||
{
|
||||
if ((bp->hide == 0) || (hidden == 1)) {
|
||||
if (selstatus == SELECT) {
|
||||
|
|
|
@ -933,7 +933,7 @@ static void do_lasso_select_curve__doSelect(void *userData,
|
|||
data->is_changed = true;
|
||||
}
|
||||
else {
|
||||
char *flag_p = (&bezt->f1) + beztindex;
|
||||
uint8_t *flag_p = (&bezt->f1) + beztindex;
|
||||
const bool is_select = *flag_p & SELECT;
|
||||
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
|
||||
if (sel_op_result != -1) {
|
||||
|
@ -2743,7 +2743,7 @@ static void do_nurbs_box_select__doSelect(void *userData,
|
|||
bezt->f1 = bezt->f3 = bezt->f2;
|
||||
}
|
||||
else {
|
||||
char *flag_p = (&bezt->f1) + beztindex;
|
||||
uint8_t *flag_p = (&bezt->f1) + beztindex;
|
||||
const bool is_select = *flag_p & SELECT;
|
||||
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
|
||||
if (sel_op_result != -1) {
|
||||
|
|
|
@ -114,8 +114,8 @@ typedef struct TransData2D {
|
|||
* Also to unset temporary flags.
|
||||
*/
|
||||
typedef struct TransDataCurveHandleFlags {
|
||||
char ih1, ih2;
|
||||
char *h1, *h2;
|
||||
uint8_t ih1, ih2;
|
||||
uint8_t *h1, *h2;
|
||||
} TransDataCurveHandleFlags;
|
||||
|
||||
typedef struct TransData {
|
||||
|
|
|
@ -113,9 +113,9 @@ typedef struct BezTriple {
|
|||
char ipo;
|
||||
|
||||
/** H1, h2: the handle type of the two handles. */
|
||||
char h1, h2;
|
||||
uint8_t h1, h2;
|
||||
/** F1, f2, f3: used for selection status. */
|
||||
char f1, f2, f3;
|
||||
uint8_t f1, f2, f3;
|
||||
|
||||
/** Hide: used to indicate whether BezTriple is hidden (3D),
|
||||
* type of keyframe (eBezTriple_KeyframeType). */
|
||||
|
@ -143,7 +143,9 @@ typedef struct BPoint {
|
|||
/** Used for softbody goal weight. */
|
||||
float weight;
|
||||
/** F1: selection status, hide: is point hidden or not. */
|
||||
short f1, hide;
|
||||
uint8_t f1;
|
||||
char _pad1[1];
|
||||
short hide;
|
||||
/** User-set radius per point for beveling etc. */
|
||||
float radius;
|
||||
char _pad[4];
|
||||
|
|
|
@ -509,7 +509,8 @@ int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *ide
|
|||
const char *RNA_property_typename(PropertyType type);
|
||||
#define IS_DNATYPE_FLOAT_COMPAT(_str) (strcmp(_str, "float") == 0 || strcmp(_str, "double") == 0)
|
||||
#define IS_DNATYPE_INT_COMPAT(_str) \
|
||||
(strcmp(_str, "int") == 0 || strcmp(_str, "short") == 0 || strcmp(_str, "char") == 0)
|
||||
(strcmp(_str, "int") == 0 || strcmp(_str, "short") == 0 || strcmp(_str, "char") == 0 || \
|
||||
strcmp(_str, "uchar") == 0 || strcmp(_str, "ushort") == 0)
|
||||
#define IS_DNATYPE_BOOLEAN_COMPAT(_str) \
|
||||
(IS_DNATYPE_INT_COMPAT(_str) || strcmp(_str, "int64_t") == 0 || strcmp(_str, "uint64_t") == 0)
|
||||
|
||||
|
|
Loading…
Reference in New Issue