From 34fecdd60e61506e6d9c2127945bccac250ee830 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Nov 2012 12:31:05 +0000 Subject: code cleanup: use min/max functions rather then macros. --- source/blender/blenkernel/intern/particle_system.c | 8 +------- source/blender/blenlib/intern/BLI_kdopbvh.c | 2 +- source/blender/editors/interface/interface_layout.c | 6 +++--- source/blender/editors/space_sequencer/sequencer_draw.c | 4 ++-- source/blender/makesrna/intern/rna_action.c | 9 ++++++--- source/blender/makesrna/intern/rna_animation.c | 5 +++-- source/blender/makesrna/intern/rna_boid.c | 8 ++++---- source/blender/makesrna/intern/rna_curve.c | 6 ++---- source/blender/makesrna/intern/rna_mask.c | 3 +-- source/blender/makesrna/intern/rna_mesh.c | 3 +-- source/blender/makesrna/intern/rna_modifier.c | 3 +-- source/blender/makesrna/intern/rna_object.c | 8 +++----- source/blender/makesrna/intern/rna_object_force.c | 6 ++++-- source/blender/makesrna/intern/rna_particle.c | 6 ++---- source/blender/makesrna/intern/rna_pose.c | 11 ++--------- source/blender/makesrna/intern/rna_scene.c | 3 +-- source/blender/makesrna/intern/rna_tracking.c | 6 ++---- source/blender/render/intern/source/convertblender.c | 2 +- source/blender/render/intern/source/pipeline.c | 4 ++-- source/blender/render/intern/source/shadbuf.c | 2 +- 20 files changed, 43 insertions(+), 62 deletions(-) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 5e1e51883f0..a780a9e8684 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -467,13 +467,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) mv++; for (i=1; ico[0]); - min[1]=MIN2(min[1],mv->co[1]); - min[2]=MIN2(min[2],mv->co[2]); - - max[0]=MAX2(max[0],mv->co[0]); - max[1]=MAX2(max[1],mv->co[1]); - max[2]=MAX2(max[2],mv->co[2]); + minmax_v3v3_v3(min, max, mv->co); } sub_v3_v3v3(delta, max, min); diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 70617453eff..7968fcabda6 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -1117,7 +1117,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap) * max_ii(tree1->totleaf, tree2->totleaf)); data[j]->tree1 = tree1; data[j]->tree2 = tree2; - data[j]->max_overlap = MAX2(tree1->totleaf, tree2->totleaf); + data[j]->max_overlap = max_ii(tree1->totleaf, tree2->totleaf); data[j]->i = 0; data[j]->start_axis = min_axis(tree1->start_axis, tree2->start_axis); data[j]->stop_axis = min_axis(tree1->stop_axis, tree2->stop_axis); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 5170fc7d51b..52d909a34c0 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1780,7 +1780,7 @@ static void ui_litem_layout_row(uiLayout *litem) if (item->flag) { /* fixed minimum size items */ - itemw = ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL); + itemw = ui_item_fit(minw, fixedx, fixedw, min_ii(w, fixedw), !item->next, litem->alignment, NULL); fixedx += itemw; } else { @@ -1959,9 +1959,9 @@ static void ui_litem_estimate_column_flow(uiLayout *litem) ui_item_size(item, &itemw, &itemh); y -= itemh + style->buttonspacey; - miny = MIN2(miny, y); + miny = min_ii(miny, y); emy -= itemh; - maxw = MAX2(itemw, maxw); + maxw = max_ii(itemw, maxw); /* decide to go to next one */ if (col < flow->totcol - 1 && emy <= -emh) { diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 29babd355ad..a8103fe2630 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -285,8 +285,8 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, drawmeta_stipple(1); for (seq = seqm->seqbase.first; seq; seq = seq->next) { - chan_min = MIN2(chan_min, seq->machine); - chan_max = MAX2(chan_max, seq->machine); + chan_min = min_ii(chan_min, seq->machine); + chan_max = max_ii(chan_max, seq->machine); } chan_range = (chan_max - chan_min) + 1; diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index ba1aca2baba..1f9503f1cc9 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -46,9 +46,13 @@ #ifdef RNA_RUNTIME -#include "ED_keyframing.h" +#include "BLI_math_base.h" + #include "BKE_fcurve.h" +#include "ED_keyframing.h" + + static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter) { ListBaseIterator *internal = iter->internal; @@ -191,8 +195,7 @@ static void rna_Action_active_pose_marker_index_range(PointerRNA *ptr, int *min, bAction *act = (bAction *)ptr->data; *min = 0; - *max = BLI_countlist(&act->markers) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&act->markers) - 1); } diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 0553f4fa78e..350caf384c9 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -54,6 +54,8 @@ EnumPropertyItem keyingset_path_grouping_items[] = { #ifdef RNA_RUNTIME +#include "BLI_math_base.h" + #include "BKE_animsys.h" #include "BKE_fcurve.h" #include "BKE_nla.h" @@ -371,8 +373,7 @@ static void rna_KeyingSet_active_ksPath_index_range(PointerRNA *ptr, int *min, i KeyingSet *ks = (KeyingSet *)ptr->data; *min = 0; - *max = BLI_countlist(&ks->paths) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&ks->paths) - 1); } static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c index 8e45da50e9b..3da718afd1c 100644 --- a/source/blender/makesrna/intern/rna_boid.c +++ b/source/blender/makesrna/intern/rna_boid.c @@ -80,6 +80,8 @@ EnumPropertyItem boidruleset_type_items[] = { #ifdef RNA_RUNTIME +#include "BLI_math_base.h" + #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_particle.h" @@ -157,8 +159,7 @@ static void rna_BoidState_active_boid_rule_index_range(PointerRNA *ptr, int *min { BoidState *state = (BoidState *)ptr->data; *min = 0; - *max = BLI_countlist(&state->rules) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&state->rules) - 1); } static int rna_BoidState_active_boid_rule_index_get(PointerRNA *ptr) @@ -224,8 +225,7 @@ static void rna_BoidSettings_active_boid_state_index_range(PointerRNA *ptr, int { BoidSettings *boids = (BoidSettings *)ptr->data; *min = 0; - *max = BLI_countlist(&boids->states) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&boids->states) - 1); } static int rna_BoidSettings_active_boid_state_index_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 35699c6ef3f..a3cff99ddc8 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -242,16 +242,14 @@ static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max, { Curve *cu = (Curve *)ptr->id.data; *min = 0; - *max = cu->totcol - 1; - *max = MAX2(0, *max); + *max = max_ii(0, cu->totcol - 1); } static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) { Curve *cu = (Curve *)ptr->id.data; *min = 0; - *max = cu->totbox - 1; - *max = MAX2(0, *max); + *max = max_ii(0, cu->totbox - 1); } diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 56caa254a59..3f23a376ea3 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -158,8 +158,7 @@ static void rna_Mask_layer_active_index_range(PointerRNA *ptr, int *min, int *ma Mask *mask = (Mask *)ptr->id.data; *min = 0; - *max = mask->masklay_tot - 1; - *max = MAX2(0, *max); + *max = max_ii(0, mask->masklay_tot - 1); *softmin = *min; *softmax = *max; diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index f0b84332d07..170e6147d99 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1010,8 +1010,7 @@ static void rna_MeshPoly_material_index_range(PointerRNA *ptr, int *min, int *ma { Mesh *me = rna_mesh(ptr); *min = 0; - *max = me->totcol - 1; - *max = MAX2(0, *max); + *max = max_ii(0, me->totcol - 1); } static int rna_MeshVertex_index_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 8eca7162d39..d421eb697a3 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -481,8 +481,7 @@ static void rna_MultiresModifier_level_range(PointerRNA *ptr, int *min, int *max MultiresModifierData *mmd = (MultiresModifierData *)ptr->data; *min = 0; - *max = mmd->totlvl; /* intentionally _not_ -1 */ - *max = MAX2(0, *max); + *max = max_ii(0, mmd->totlvl); /* intentionally _not_ -1 */ } static int rna_MultiresModifier_external_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 10f361ef1bd..82f27b953cf 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -547,8 +547,7 @@ static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min Object *ob = (Object *)ptr->id.data; *min = 0; - *max = BLI_countlist(&ob->defbase) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&ob->defbase) - 1); } void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index) @@ -658,7 +657,7 @@ static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, in { Object *ob = (Object *)ptr->id.data; *min = 0; - *max = MAX2(ob->totcol - 1, 0); + *max = max_ii(ob->totcol - 1, 0); } /* returns active base material */ @@ -684,8 +683,7 @@ static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int * { Object *ob = (Object *)ptr->id.data; *min = 0; - *max = BLI_countlist(&ob->particlesystem) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&ob->particlesystem) - 1); } static int rna_Object_active_particle_system_index_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index f47b864d25a..6d7187da7d9 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -51,6 +51,9 @@ static EnumPropertyItem effector_shape_items[] = { #ifdef RNA_RUNTIME +#include "BLI_math_base.h" + + /* type specific return values only used from functions */ static EnumPropertyItem curve_shape_items[] = { {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""}, @@ -239,8 +242,7 @@ static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { - *max = BLI_countlist(pid->ptcaches) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(pid->ptcaches) - 1); break; } } diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 9ba2a062791..6825d3d781d 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -530,8 +530,7 @@ static void rna_ParticleSystem_active_particle_target_index_range(PointerRNA *pt { ParticleSystem *psys = (ParticleSystem *)ptr->data; *min = 0; - *max = BLI_countlist(&psys->targets) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&psys->targets) - 1); } static int rna_ParticleSystem_active_particle_target_index_get(PointerRNA *ptr) @@ -670,8 +669,7 @@ static void rna_ParticleDupliWeight_active_index_range(PointerRNA *ptr, int *min { ParticleSettings *part = (ParticleSettings *)ptr->id.data; *min = 0; - *max = BLI_countlist(&part->dupliweights) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&part->dupliweights) - 1); } static int rna_ParticleDupliWeight_active_index_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index c29537378dd..412aad20a41 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -381,13 +381,7 @@ static void rna_PoseChannel_bone_group_index_range(PointerRNA *ptr, int *min, in bPose *pose = (ob) ? ob->pose : NULL; *min = 0; - - if (pose) { - *max = BLI_countlist(&pose->agroups) - 1; - *max = MAX2(0, *max); - } - else - *max = 0; + *max = pose ? max_ii(0, BLI_countlist(&pose->agroups) - 1) : 0; } static PointerRNA rna_Pose_active_bone_group_get(PointerRNA *ptr) @@ -419,8 +413,7 @@ static void rna_Pose_active_bone_group_index_range(PointerRNA *ptr, int *min, in bPose *pose = (bPose *)ptr->data; *min = 0; - *max = BLI_countlist(&pose->agroups) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&pose->agroups) - 1); } #if 0 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 69bb1cc98ff..b102d463195 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1002,8 +1002,7 @@ static void rna_RenderSettings_active_layer_index_range(PointerRNA *ptr, int *mi RenderData *rd = (RenderData *)ptr->data; *min = 0; - *max = BLI_countlist(&rd->layers) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&rd->layers) - 1); } static PointerRNA rna_RenderSettings_active_layer_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 51b50f78e66..074a8ed9017 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -120,8 +120,7 @@ static void rna_tracking_active_object_index_range(PointerRNA *ptr, int *min, in MovieClip *clip = (MovieClip *)ptr->id.data; *min = 0; - *max = clip->tracking.tot_object - 1; - *max = MAX2(0, *max); + *max = max_ii(0, clip->tracking.tot_object - 1); } static PointerRNA rna_tracking_active_track_get(PointerRNA *ptr) @@ -263,8 +262,7 @@ static void rna_tracking_stabTracks_active_index_range(PointerRNA *ptr, int *min MovieClip *clip = (MovieClip *)ptr->id.data; *min = 0; - *max = clip->tracking.stabilization.tot_track - 1; - *max = MAX2(0, *max); + *max = max_ii(0, clip->tracking.stabilization.tot_track - 1); } static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index e305f434ebb..eb0a13b3942 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -4296,7 +4296,7 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset) /* compute average bounding box of strandpoint itself (width) */ if (obr->strandbuf->flag & R_STRAND_B_UNITS) - obr->strandbuf->maxwidth= MAX2(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end); + obr->strandbuf->maxwidth = max_ff(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end); else obr->strandbuf->maxwidth= 0.0f; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 7ef3aecad08..d305ed06af1 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2507,8 +2507,8 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, if (env->type == ENV_CUBE) { for (i = 0; i < 12; i += 2) { - maxX = MAX2(maxX, layout[i] + 1); - maxY = MAX2(maxY, layout[i + 1] + 1); + maxX = max_ii(maxX, (int)layout[i] + 1); + maxY = max_ii(maxY, (int)layout[i + 1] + 1); } ibuf = IMB_allocImBuf(maxX * dx, maxY * dx, 24, IB_rectfloat); diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index c37f48bc329..a7f6b40981d 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -637,7 +637,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) maxtotvert= 0; for (obr=re->objecttable.first; obr; obr=obr->next) - maxtotvert= MAX2(obr->totvert, maxtotvert); + maxtotvert = max_ii(obr->totvert, maxtotvert); clipflag= MEM_callocN(sizeof(char)*maxtotvert, "autoclipflag"); -- cgit v1.2.3