code cleanup: use min/max inline functions rather than macros & simplify loop
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user