diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-11 13:39:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-11 13:39:37 +0400 |
commit | 10d18e5b5f279f99ecc6d6304a580f581408d92c (patch) | |
tree | d8f9bb9e171952408e874af8a349c1bbf6452b21 | |
parent | 39231c90dd5b986612cffd00fe65760430e04c83 (diff) |
code cleanup: use min/max inline functions rather than macros & simplify loop
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 3 |
5 files changed, 24 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 5fea74d52de..2dbc63e6944 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -504,8 +504,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo xmaxv = MAX3(xmaxv, bezt_last->vec[1][0], bezt_last->vec[2][0]); } else { - xminv = MIN2(xminv, bezt_first->vec[1][0]); - xmaxv = MAX2(xmaxv, bezt_last->vec[1][0]); + xminv = minf(xminv, bezt_first->vec[1][0]); + xmaxv = maxf(xmaxv, bezt_last->vec[1][0]); } } } @@ -521,8 +521,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo ymaxv = MAX4(ymaxv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]); } else { - yminv = MIN2(yminv, bezt->vec[1][1]); - ymaxv = MAX2(ymaxv, bezt->vec[1][1]); + yminv = minf(yminv, bezt->vec[1][1]); + ymaxv = maxf(ymaxv, bezt->vec[1][1]); } foundvert = TRUE; @@ -533,8 +533,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo else if (fcu->fpt) { /* frame range can be directly calculated from end verts */ if (xmin || xmax) { - xminv = MIN2(xminv, fcu->fpt[0].vec[0]); - xmaxv = MAX2(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]); + xminv = minf(xminv, fcu->fpt[0].vec[0]); + xmaxv = maxf(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]); } /* only loop over keyframes to find extents for values if needed */ @@ -591,15 +591,15 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end, if (bezt_first) { BLI_assert(bezt_last != NULL); - min = MIN2(min, bezt_first->vec[1][0]); - max = MAX2(max, bezt_last->vec[1][0]); + min = minf(min, bezt_first->vec[1][0]); + max = maxf(max, bezt_last->vec[1][0]); foundvert = TRUE; } } else if (fcu->fpt) { - min = MIN2(min, fcu->fpt[0].vec[0]); - max = MAX2(max, fcu->fpt[fcu->totvert - 1].vec[0]); + min = minf(min, fcu->fpt[0].vec[0]); + max = maxf(max, fcu->fpt[fcu->totvert - 1].vec[0]); foundvert = TRUE; } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 17a3c595ea7..b79608342dd 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -691,8 +691,8 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const if (nu->bp) { step = nu->pntsu * nu->pntsv; - a1 = MAX2(a, start); - a2 = MIN2(a + step, end); + a1 = maxi(a, start); + a2 = mini(a + step, end); if (a1 < a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BPOINT); } @@ -700,8 +700,8 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const step = 3 * nu->pntsu; /* exception because keys prefer to work with complete blocks */ - a1 = MAX2(a, start); - a2 = MIN2(a + step, end); + a1 = maxi(a, start); + a2 = mini(a + step, end); if (a1 < a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BEZTRIPLE); } @@ -1217,7 +1217,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in remain = step; } - count = MIN2(remain, estep); + count = mini(remain, estep); if (mode == KEY_MODE_BEZTRIPLE) { count += 3 - count % 3; } @@ -1573,7 +1573,7 @@ void key_to_latt(KeyBlock *kb, Lattice *lt) fp = kb->data; tot = lt->pntsu * lt->pntsv * lt->pntsw; - tot = MIN2(kb->totelem, tot); + tot = mini(kb->totelem, tot); for (a = 0; a < tot; a++, fp += 3, bp++) { copy_v3_v3(bp->vec, fp); @@ -1645,7 +1645,7 @@ void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb) tot = BKE_nurbList_verts_count(nurb); - tot = MIN2(kb->totelem, tot); + tot = mini(kb->totelem, tot); while (nu && tot > 0) { @@ -1713,7 +1713,7 @@ void key_to_mesh(KeyBlock *kb, Mesh *me) mvert = me->mvert; fp = kb->data; - tot = MIN2(kb->totelem, me->totvert); + tot = mini(kb->totelem, me->totvert); for (a = 0; a < tot; a++, fp += 3, mvert++) { copy_v3_v3(mvert->co, fp); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index dfa3582cee8..5dfecfcb717 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2700,7 +2700,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID) == 0) { scene->physics_settings.quick_cache_step = scene->physics_settings.quick_cache_step ? - MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) : + mini(scene->physics_settings.quick_cache_step, pid->cache->step) : pid->cache->step; } } diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 64920df6e20..726127fdcad 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -123,12 +123,12 @@ void *BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len) if (BM_iter_init(&iter, bm, itype, data) && iter.count > 0) { BMElem *ele; BMElem **array = MEM_mallocN(sizeof(ele) * iter.count, __func__); - int i; + int i = 0; *r_len = iter.count; /* set before iterating */ - for (ele = BM_iter_step(&iter), i = 0; ele; ele = BM_iter_step(&iter), i++) { - array[i] = ele; + while ((ele = BM_iter_step(&iter))) { + array[i++] = ele; } return array; } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index d36c0bbaf4a..4c1c377cb9f 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1659,8 +1659,9 @@ void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, int value) IDP_Int(idprop) = value; rna_idproperty_touch(idprop); } - else if (bprop->set) + else if (bprop->set) { bprop->set(ptr, value); + } else if (prop->flag & PROP_EDITABLE) { IDPropertyTemplate val = {0}; IDProperty *group; |