From a3375729f8518c8069edafde36953b558329a0db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 Dec 2018 22:56:19 +1100 Subject: Cleanup: macro hygiene, style, doxy comments --- source/blender/blenkernel/BKE_curve.h | 2 +- source/blender/blenkernel/BKE_gpencil_modifier.h | 57 ++++++++++++++-------- source/blender/blenlib/intern/edgehash.c | 6 +-- .../blender/draw/engines/gpencil/gpencil_engine.c | 2 +- source/blender/editors/mesh/mesh_data.c | 2 +- .../blender/editors/space_view3d/view3d_select.c | 2 +- 6 files changed, 44 insertions(+), 27 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index be46a2dd01a..ebbdbc7f7a0 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -68,7 +68,7 @@ typedef struct CVKeyIndex { #define SEGMENTSU(nu) ( ((nu)->flagu & CU_NURB_CYCLIC) ? (nu)->pntsu : (nu)->pntsu - 1) #define SEGMENTSV(nu) ( ((nu)->flagv & CU_NURB_CYCLIC) ? (nu)->pntsv : (nu)->pntsv - 1) -#define CU_DO_TILT(cu, nu) (((nu->flag & CU_2D) && (cu->flag & CU_3D) == 0) ? 0 : 1) +#define CU_DO_TILT(cu, nu) ((((nu)->flag & CU_2D) && ((cu)->flag & CU_3D) == 0) ? 0 : 1) #define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || ((cu)->flag & CU_PATH_RADIUS) || (cu)->bevobj || (cu)->ext1 != 0.0f || (cu)->ext2 != 0.0f) ? 1 : 0) /* not 3d and not unfilled */ diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h index e31f61c909a..8acbfac7981 100644 --- a/source/blender/blenkernel/BKE_gpencil_modifier.h +++ b/source/blender/blenkernel/BKE_gpencil_modifier.h @@ -49,9 +49,11 @@ struct bGPDframe; struct bGPDstroke; struct ModifierUpdateDepsgraphContext; -#define GPENCIL_MODIFIER_ACTIVE(_md, _is_render) (((_md->mode & eGpencilModifierMode_Realtime) && (_is_render == false)) || \ - ((_md->mode & eGpencilModifierMode_Render) && (_is_render == true))) -#define GPENCIL_MODIFIER_EDIT(_md, _is_edit) (((_md->mode & eGpencilModifierMode_Editmode) == 0) && (_is_edit)) +#define GPENCIL_MODIFIER_ACTIVE(_md, _is_render) \ + ((((_md)->mode & eGpencilModifierMode_Realtime) && (_is_render == false)) || \ + (((_md)->mode & eGpencilModifierMode_Render) && (_is_render == true))) +#define GPENCIL_MODIFIER_EDIT(_md, _is_edit) \ + ((((_md)->mode & eGpencilModifierMode_Editmode) == 0) && (_is_edit)) typedef enum { /* Should not be used, only for None modifier type */ @@ -93,15 +95,16 @@ typedef void(*GreasePencilIDWalkFunc)(void *userData, struct Object *ob, struct typedef void(*GreasePencilTexWalkFunc)(void *userData, struct Object *ob, struct GpencilModifierData *md, const char *propname); typedef struct GpencilModifierTypeInfo { - /* The user visible name for this modifier */ + /** The user visible name for this modifier */ char name[32]; - /* The DNA struct name for the modifier data type, used to + /** + * The DNA struct name for the modifier data type, used to * write the DNA data out. */ char struct_name[32]; - /* The size of the modifier data type, used by allocation. */ + /** The size of the modifier data type, used by allocation. */ int struct_size; GpencilModifierTypeType type; @@ -110,12 +113,14 @@ typedef struct GpencilModifierTypeInfo { /********************* Non-optional functions *********************/ - /* Copy instance data for this modifier type. Should copy all user + /** + * Copy instance data for this modifier type. Should copy all user * level settings to the target modifier. */ void (*copyData)(const struct GpencilModifierData *md, struct GpencilModifierData *target); - /* Callback for GP "stroke" modifiers that operate on the + /** + * Callback for GP "stroke" modifiers that operate on the * shape and parameters of the provided strokes (e.g. Thickness, Noise, etc.) * * The gpl parameter contains the GP layer that the strokes come from. @@ -129,7 +134,8 @@ typedef struct GpencilModifierTypeInfo { void (*deformStroke)(struct GpencilModifierData *md, struct Depsgraph *depsgraph, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps); - /* Callback for GP "geometry" modifiers that create extra geometry + /** + * Callback for GP "geometry" modifiers that create extra geometry * in the frame (e.g. Array) * * The gpf parameter contains the GP frame/strokes to operate on. This is @@ -143,7 +149,8 @@ typedef struct GpencilModifierTypeInfo { void (*generateStrokes)(struct GpencilModifierData *md, struct Depsgraph *depsgraph, struct Object *ob, struct bGPDlayer *gpl, struct bGPDframe *gpf); - /* Bake-down GP modifier's effects into the GP datablock. + /** + * Bake-down GP modifier's effects into the GP datablock. * * This gets called when the user clicks the "Apply" button in the UI. * As such, this callback needs to go through all layers/frames in the @@ -155,7 +162,8 @@ typedef struct GpencilModifierTypeInfo { /********************* Optional functions *********************/ - /* Callback for GP "time" modifiers that offset keyframe time + /** + * Callback for GP "time" modifiers that offset keyframe time * Returns the frame number to be used after apply the modifier. This is * usually an offset of the animation for duplicated datablocks. * @@ -164,21 +172,24 @@ typedef struct GpencilModifierTypeInfo { int (*remapTime)(struct GpencilModifierData *md, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bGPDlayer *gpl, int cfra); - /* Initialize new instance data for this modifier type, this function + /** + * Initialize new instance data for this modifier type, this function * should set modifier variables to their default values. * * This function is optional. */ void (*initData)(struct GpencilModifierData *md); - /* Free internal modifier data variables, this function should + /** + * Free internal modifier data variables, this function should * not free the md variable itself. * * This function is optional. */ void (*freeData)(struct GpencilModifierData *md); - /* Return a boolean value indicating if this modifier is able to be + /** + * Return a boolean value indicating if this modifier is able to be * calculated based on the modifier data. This is *not* regarding the * md->flag, that is tested by the system, this is just if the data * validates (for example, a lattice will return false if the lattice @@ -188,14 +199,16 @@ typedef struct GpencilModifierTypeInfo { */ bool (*isDisabled)(struct GpencilModifierData *md, int userRenderParams); - /* Add the appropriate relations to the dependency graph. + /** + * Add the appropriate relations to the dependency graph. * * This function is optional. */ void (*updateDepsgraph)(struct GpencilModifierData *md, const struct ModifierUpdateDepsgraphContext *ctx); - /* Should return true if the modifier needs to be recalculated on time + /** + * Should return true if the modifier needs to be recalculated on time * changes. * * This function is optional (assumes false if not present). @@ -203,7 +216,8 @@ typedef struct GpencilModifierTypeInfo { bool (*dependsOnTime)(struct GpencilModifierData *md); - /* Should call the given walk function on with a pointer to each Object + /** + * Should call the given walk function on with a pointer to each Object * pointer that the modifier data stores. This is used for linking on file * load and for unlinking objects or forwarding object references. * @@ -212,7 +226,8 @@ typedef struct GpencilModifierTypeInfo { void (*foreachObjectLink)(struct GpencilModifierData *md, struct Object *ob, GreasePencilObjectWalkFunc walk, void *userData); - /* Should call the given walk function with a pointer to each ID + /** + * Should call the given walk function with a pointer to each ID * pointer (i.e. each datablock pointer) that the modifier data * stores. This is used for linking on file load and for * unlinking datablocks or forwarding datablock references. @@ -223,7 +238,8 @@ typedef struct GpencilModifierTypeInfo { void (*foreachIDLink)(struct GpencilModifierData *md, struct Object *ob, GreasePencilIDWalkFunc walk, void *userData); - /* Should call the given walk function for each texture that the + /** + * Should call the given walk function for each texture that the * modifier data stores. This is used for finding all textures in * the context for the UI. * @@ -233,7 +249,8 @@ typedef struct GpencilModifierTypeInfo { void (*foreachTexLink)(struct GpencilModifierData *md, struct Object *ob, GreasePencilTexWalkFunc walk, void *userData); - /* get the number of times the strokes are duplicated in this modifier. + /** + * Get the number of times the strokes are duplicated in this modifier. * This is used to calculate the size of the GPU VBOs */ int (*getDuplicationFactor)(struct GpencilModifierData *md); diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index 7061c1b8702..b46383cf9de 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -63,8 +63,8 @@ typedef struct EdgeSet { #define ENTRIES_CAPACITY(container) (uint)(1 << (container)->capacity_exp) #define MAP_CAPACITY(container) (uint)(1 << ((container)->capacity_exp + 1)) -#define CLEAR_MAP(container) memset(container->map, 0xFF, sizeof(int32_t) * MAP_CAPACITY(container)) -#define UPDATE_SLOT_MASK(container) (container)->slot_mask = MAP_CAPACITY(container) - 1 +#define CLEAR_MAP(container) memset((container)->map, 0xFF, sizeof(int32_t) * MAP_CAPACITY(container)) +#define UPDATE_SLOT_MASK(container) { (container)->slot_mask = MAP_CAPACITY(container) - 1; } ((void)0) #define PERTURB_SHIFT 5 #define ITER_SLOTS(CONTAINER, EDGE, SLOT, INDEX) \ @@ -127,7 +127,7 @@ static uint calc_capacity_exp_for_reserve(uint reserve) /** \name Internal Utility API * \{ */ -#define EH_INDEX_HAS_EDGE(eh, index, edge) (index) >= 0 && edges_equal((edge), (eh)->entries[index].edge) +#define EH_INDEX_HAS_EDGE(eh, index, edge) ((index) >= 0 && edges_equal((edge), (eh)->entries[index].edge)) static void edgehash_free_values(EdgeHash *eh, EdgeHashFreeFP free_value) { diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 0e998363ec5..66d9bac1fac 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -116,7 +116,7 @@ static void GPENCIL_create_framebuffers(void *vedata) /* create multiframe framebuffer for AA */ if ((stl->storage->framebuffer_flag & GP_FRAMEBUFFER_MULTISAMPLE) && - (stl->storage->multisamples > 0)) + (stl->storage->multisamples > 0)) { DRW_gpencil_multisample_ensure(vedata, size[0], size[1]); } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index fef4314019f..8b2c7601524 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -122,7 +122,7 @@ static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_t return data; } -#define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data) +#define GET_CD_DATA(me, data) ((me)->edit_btmesh ? &(me)->edit_btmesh->bm->data : &(me)->data) static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) { const int type = layer->type; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b3405b4659a..08d8d168e81 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -794,7 +794,7 @@ static void do_lasso_select_armature__doSelectBone( if (screen_co_b[0] != IS_CLIPPED) { if (BLI_rcti_isect_pt(data->rect, UNPACK2(screen_co_b)) && - BLI_lasso_is_point_inside(data->mcords, data->moves, UNPACK2(screen_co_b), INT_MAX)) + BLI_lasso_is_point_inside(data->mcords, data->moves, UNPACK2(screen_co_b), INT_MAX)) { is_inside_flag |= BONESEL_TIP; } -- cgit v1.2.3