forked from bartvdbraak/blender
add inline functions for max/min ints, good to use when the arguments are function calls (we had a few of these).
This commit is contained in:
parent
f608b3c444
commit
7217927414
@ -545,7 +545,9 @@ static void seq_update_sound_bounds_recursive_rec(Scene *scene, Sequence *metase
|
||||
* since sound is played outside of evaluating the imbufs, */
|
||||
for (seq = metaseq->seqbase.first; seq; seq = seq->next) {
|
||||
if (seq->type == SEQ_TYPE_META) {
|
||||
seq_update_sound_bounds_recursive_rec(scene, seq, MAX2(start, metaseq_start(seq)), MIN2(end, metaseq_end(seq)));
|
||||
seq_update_sound_bounds_recursive_rec(scene, seq,
|
||||
maxi(start, metaseq_start(seq)),
|
||||
mini(end, metaseq_end(seq)));
|
||||
}
|
||||
else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
|
||||
if (seq->scene_sound) {
|
||||
@ -3140,7 +3142,7 @@ int seq_tx_get_final_left(Sequence *seq, int metaclip)
|
||||
{
|
||||
if (metaclip && seq->tmp) {
|
||||
/* return the range clipped by the parents range */
|
||||
return MAX2(seq_tx_get_final_left(seq, 0), seq_tx_get_final_left((Sequence *)seq->tmp, 1) );
|
||||
return maxi(seq_tx_get_final_left(seq, 0), seq_tx_get_final_left((Sequence *)seq->tmp, TRUE));
|
||||
}
|
||||
else {
|
||||
return (seq->start - seq->startstill) + seq->startofs;
|
||||
@ -3151,7 +3153,7 @@ int seq_tx_get_final_right(Sequence *seq, int metaclip)
|
||||
{
|
||||
if (metaclip && seq->tmp) {
|
||||
/* return the range clipped by the parents range */
|
||||
return MIN2(seq_tx_get_final_right(seq, 0), seq_tx_get_final_right((Sequence *)seq->tmp, 1) );
|
||||
return mini(seq_tx_get_final_right(seq, 0), seq_tx_get_final_right((Sequence *)seq->tmp, TRUE));
|
||||
}
|
||||
else {
|
||||
return ((seq->start + seq->len) + seq->endstill) - seq->endofs;
|
||||
|
@ -648,7 +648,7 @@ static int implicit_leafs_index(BVHBuildHelper *data, int depth, int child_index
|
||||
// This functions returns the number of branches needed to have the requested number of leafs.
|
||||
static int implicit_needed_branches(int tree_type, int leafs)
|
||||
{
|
||||
return MAX2(1, (leafs + tree_type - 3) / (tree_type - 1) );
|
||||
return maxi(1, (leafs + tree_type - 3) / (tree_type - 1) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -143,12 +143,20 @@ MINLINE float minf(float a, float b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
MINLINE float maxf(float a, float b)
|
||||
{
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
MINLINE int mini(int a, int b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
MINLINE int maxi(int a, int b)
|
||||
{
|
||||
return (b < a) ? a : b;
|
||||
}
|
||||
|
||||
MINLINE float signf(float f)
|
||||
{
|
||||
return (f < 0.f) ? -1.f : 1.f;
|
||||
|
@ -663,7 +663,7 @@ void BLI_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj,
|
||||
bvh->totgrid = totgrid;
|
||||
bvh->gridkey = *key;
|
||||
bvh->grid_hidden = grid_hidden;
|
||||
bvh->leaf_limit = MAX2(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1);
|
||||
bvh->leaf_limit = maxi(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1);
|
||||
|
||||
BB_reset(&cb);
|
||||
|
||||
|
@ -303,7 +303,7 @@ void ScreenLensDistortionOperation::updateVariables(float distortion, float disp
|
||||
{
|
||||
this->m_kg = maxf(minf(distortion, 1.0f), -0.999f);
|
||||
// smaller dispersion range for somewhat more control
|
||||
const float d = 0.25f * MAX2(MIN2(dispersion, 1.f), 0.f);
|
||||
const float d = 0.25f * maxf(minf(dispersion, 1.0f), 0.0f);
|
||||
this->m_kr = maxf(minf((this->m_kg + d), 1.0f), -0.999f);
|
||||
this->m_kb = maxf(minf((this->m_kg - d), 1.0f), -0.999f);
|
||||
this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb);
|
||||
|
@ -2418,7 +2418,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
|
||||
* on the first item */
|
||||
offset[0] = 0;
|
||||
for (bt = block->buttons.first; bt; bt = bt->next)
|
||||
offset[0] = MIN2(offset[0], -(bt->x1 + 0.8f * (bt->x2 - bt->x1)));
|
||||
offset[0] = mini(offset[0], -(bt->x1 + 0.8f * (bt->x2 - bt->x1)));
|
||||
|
||||
offset[1] = 1.5 * UI_UNIT_Y;
|
||||
}
|
||||
|
@ -346,7 +346,8 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
|
||||
const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) ||
|
||||
(roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2;
|
||||
|
||||
minsize = MIN2((rect->xmax - rect->xmin) * hnum, (rect->ymax - rect->ymin) * vnum);
|
||||
minsize = mini((rect->xmax - rect->xmin) * hnum,
|
||||
(rect->ymax - rect->ymin) * vnum);
|
||||
|
||||
if (2.0f * rad > minsize)
|
||||
rad = 0.5f * minsize;
|
||||
|
@ -624,8 +624,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
|
||||
* covers the entire screen).
|
||||
*/
|
||||
glGetFloatv(GL_SCISSOR_BOX, scissor);
|
||||
draw_w = MIN2(img_w - off_x, ceil((scissor[2] - rast_x) / xzoom));
|
||||
draw_h = MIN2(img_h - off_y, ceil((scissor[3] - rast_y) / yzoom));
|
||||
draw_w = mini(img_w - off_x, ceil((scissor[2] - rast_x) / xzoom));
|
||||
draw_h = mini(img_h - off_y, ceil((scissor[3] - rast_y) / yzoom));
|
||||
|
||||
if (draw_w > 0 && draw_h > 0) {
|
||||
int old_row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH);
|
||||
|
@ -852,7 +852,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
|
||||
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
|
||||
(int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))),
|
||||
MIN2((int)(rect.xmax - rect.xmin - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
|
||||
mini((int)(rect.xmax - rect.xmin - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
|
||||
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
|
||||
uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL);
|
||||
uiBlockLayoutResolve(gnode->block, NULL, NULL);
|
||||
|
@ -1049,7 +1049,7 @@ static void draw_seq_backdrop(View2D *v2d)
|
||||
glRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
|
||||
|
||||
/* Alternating horizontal stripes */
|
||||
i = MAX2(1, ((int)v2d->cur.ymin) - 1);
|
||||
i = maxi(1, ((int)v2d->cur.ymin) - 1);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
while (i < v2d->cur.ymax) {
|
||||
@ -1068,7 +1068,7 @@ static void draw_seq_backdrop(View2D *v2d)
|
||||
glEnd();
|
||||
|
||||
/* Darker lines separating the horizontal bands */
|
||||
i = MAX2(1, ((int)v2d->cur.ymin) - 1);
|
||||
i = maxi(1, ((int)v2d->cur.ymin) - 1);
|
||||
UI_ThemeColor(TH_GRID);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
|
@ -587,8 +587,8 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
|
||||
// n-agonal
|
||||
int ov, nv;
|
||||
float mind, maxd, lwt;
|
||||
ys = MAX2((int)floor(bkh_b[2]*ct_crad + y), 0);
|
||||
ye = MIN2((int)ceil(bkh_b[3]*ct_crad + y), new->y - 1);
|
||||
ys = maxi((int)floor(bkh_b[2] * ct_crad + y), 0);
|
||||
ye = mini((int)ceil(bkh_b[3] * ct_crad + y), new->y - 1);
|
||||
for (sy=ys; sy<=ye; sy++) {
|
||||
float fxs = 1e10f, fxe = -1e10f;
|
||||
float yf = (sy - y)/ct_crad;
|
||||
|
@ -89,7 +89,7 @@ static inline int rayobject_bb_intersect_test(const Isect *isec, const float *_b
|
||||
RE_RC_COUNT(isec->raycounter->bb.test);
|
||||
|
||||
if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0;
|
||||
if (t2x < 0.0 || t2y < 0.0 || t2z < 0.0) return 0;
|
||||
if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return 0;
|
||||
if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0;
|
||||
RE_RC_COUNT(isec->raycounter->bb.hit);
|
||||
|
||||
|
@ -649,9 +649,9 @@ static void RE_rayobject_octree_done(RayObject *tree)
|
||||
t02 = oc->max[2] - oc->min[2];
|
||||
|
||||
/* this minus 0.1 is old safety... seems to be needed? */
|
||||
oc->ocfacx = (oc->ocres - 0.1) / t00;
|
||||
oc->ocfacy = (oc->ocres - 0.1) / t01;
|
||||
oc->ocfacz = (oc->ocres - 0.1) / t02;
|
||||
oc->ocfacx = (oc->ocres - 0.1f) / t00;
|
||||
oc->ocfacy = (oc->ocres - 0.1f) / t01;
|
||||
oc->ocfacz = (oc->ocres - 0.1f) / t02;
|
||||
|
||||
oc->ocsize = sqrt(t00 * t00 + t01 * t01 + t02 * t02); /* global, max size octree */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user