replace MIN/MAX 3,4 with inline functions

This commit is contained in:
2012-12-21 05:07:26 +00:00
parent e09ddf0d4b
commit b2c66e268f
31 changed files with 143 additions and 110 deletions

View File

@@ -687,7 +687,7 @@ static void boundInsert(Bounds3D *b, float point[3])
static float getSurfaceDimension(PaintSurfaceData *sData)
{
Bounds3D *mb = &sData->bData->mesh_bounds;
return MAX3((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2]));
return max_fff((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2]));
}
static void freeGrid(PaintSurfaceData *data)
@@ -754,14 +754,14 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
/* get dimensions */
sub_v3_v3v3(dim, grid->grid_bounds.max, grid->grid_bounds.min);
copy_v3_v3(td, dim);
min_dim = MAX3(td[0], td[1], td[2]) / 1000.f;
min_dim = max_fff(td[0], td[1], td[2]) / 1000.f;
/* deactivate zero axises */
for (i = 0; i < 3; i++) {
if (td[i] < min_dim) { td[i] = 1.0f; axis -= 1; }
}
if (axis == 0 || MAX3(td[0], td[1], td[2]) < 0.0001f) {
if (axis == 0 || max_fff(td[0], td[1], td[2]) < 0.0001f) {
MEM_freeN(grid_bounds);
MEM_freeN(bData->grid);
bData->grid = NULL;
@@ -4260,7 +4260,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
if (surface->effect & MOD_DPAINT_EFFECT_DO_SHRINK)
shrink_speed = surface->shrink_speed;
fastest_effect = MAX3(spread_speed, shrink_speed, average_force);
fastest_effect = max_fff(spread_speed, shrink_speed, average_force);
avg_dist = bData->average_dist * CANVAS_REL_SIZE / getSurfaceDimension(sData);
steps = (int)ceil(1.5f * EFF_MOVEMENT_PER_FRAME * fastest_effect / avg_dist * timescale);
@@ -4444,8 +4444,7 @@ static void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescal
float dt, min_dist, damp_factor;
float wave_speed = surface->wave_speed;
double average_dist = 0.0f;
Bounds3D *mb = &sData->bData->mesh_bounds;
float canvas_size = MAX3((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2]));
const float canvas_size = getSurfaceDimension(sData);
float wave_scale = CANVAS_REL_SIZE / canvas_size;
/* allocate memory */

View File

@@ -500,8 +500,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo
BLI_assert(bezt_last != NULL);
if (include_handles) {
xminv = MIN3(xminv, bezt_first->vec[0][0], bezt_first->vec[1][0]);
xmaxv = MAX3(xmaxv, bezt_last->vec[1][0], bezt_last->vec[2][0]);
xminv = min_fff(xminv, bezt_first->vec[0][0], bezt_first->vec[1][0]);
xmaxv = max_fff(xmaxv, bezt_last->vec[1][0], bezt_last->vec[2][0]);
}
else {
xminv = min_ff(xminv, bezt_first->vec[1][0]);
@@ -517,8 +517,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
if ((do_sel_only == FALSE) || BEZSELECTED(bezt)) {
if (include_handles) {
yminv = MIN4(yminv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]);
ymaxv = MAX4(ymaxv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]);
yminv = min_ffff(yminv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]);
ymaxv = max_ffff(ymaxv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]);
}
else {
yminv = min_ff(yminv, bezt->vec[1][1]);

View File

@@ -1514,7 +1514,7 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
float in_v /*, out_v*/;
float workp[3];
float dvec[3];
float tmp_v, workp_v, max_len, len, nx, ny, nz, MAXN;
float tmp_v, workp_v, max_len, nx, ny, nz, max_dim;
calc_mballco(ml, in);
in_v = mbproc->function(in[0], in[1], in[2]);
@@ -1573,17 +1573,17 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
ny = abs((out[1] - in[1]) / mbproc->size);
nz = abs((out[2] - in[2]) / mbproc->size);
MAXN = MAX3(nx, ny, nz);
if (MAXN != 0.0f) {
dvec[0] = (out[0] - in[0]) / MAXN;
dvec[1] = (out[1] - in[1]) / MAXN;
dvec[2] = (out[2] - in[2]) / MAXN;
max_dim = max_fff(nx, ny, nz);
if (max_dim != 0.0f) {
float len = 0.0f;
dvec[0] = (out[0] - in[0]) / max_dim;
dvec[1] = (out[1] - in[1]) / max_dim;
dvec[2] = (out[2] - in[2]) / max_dim;
len = 0.0;
while (len <= max_len) {
workp[0] += dvec[0];
workp[1] += dvec[1];
workp[2] += dvec[2];
add_v3_v3(workp, dvec);
/* compute value of implicite function */
tmp_v = mbproc->function(workp[0], workp[1], workp[2]);
/* add cube to the stack, when value of implicite function crosses zero value */

View File

@@ -593,8 +593,8 @@ void BKE_sequence_calc(Scene *scene, Sequence *seq)
/* XXX These resets should not be necessary, but users used to be able to
* edit effect's length, leading to strange results. See [#29190] */
seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
seq->start = seq->startdisp = MAX3(seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp);
seq->enddisp = MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
seq->start = seq->startdisp = max_iii(seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp);
seq->enddisp = min_iii(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
/* we cant help if strips don't overlap, it wont give useful results.
* but at least ensure 'len' is never negative which causes bad bugs elsewhere. */
if (seq->enddisp < seq->startdisp) {

View File

@@ -170,7 +170,7 @@ void smoke_reallocate_fluid(SmokeDomainSettings *sds, float dx, int res[3], int
if (free_old && sds->fluid)
smoke_free(sds->fluid);
if (!MIN3(res[0], res[1], res[2])) {
if (!min_iii(res[0], res[1], res[2])) {
sds->fluid = NULL;
return;
}
@@ -191,7 +191,7 @@ void smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, float dx, int res[
if (free_old && sds->wt)
smoke_turbulence_free(sds->wt);
if (!MIN3(res[0], res[1], res[2])) {
if (!min_iii(res[0], res[1], res[2])) {
sds->wt = NULL;
return;
}

View File

@@ -1097,12 +1097,12 @@ static int sb_detect_face_pointCached(float face_v1[3], float face_v2[3], float
float facedist, outerfacethickness, tune = 10.f;
int a, deflected=0;
aabbmin[0] = MIN3(face_v1[0], face_v2[0], face_v3[0]);
aabbmin[1] = MIN3(face_v1[1], face_v2[1], face_v3[1]);
aabbmin[2] = MIN3(face_v1[2], face_v2[2], face_v3[2]);
aabbmax[0] = MAX3(face_v1[0], face_v2[0], face_v3[0]);
aabbmax[1] = MAX3(face_v1[1], face_v2[1], face_v3[1]);
aabbmax[2] = MAX3(face_v1[2], face_v2[2], face_v3[2]);
aabbmin[0] = min_fff(face_v1[0], face_v2[0], face_v3[0]);
aabbmin[1] = min_fff(face_v1[1], face_v2[1], face_v3[1]);
aabbmin[2] = min_fff(face_v1[2], face_v2[2], face_v3[2]);
aabbmax[0] = max_fff(face_v1[0], face_v2[0], face_v3[0]);
aabbmax[1] = max_fff(face_v1[1], face_v2[1], face_v3[1]);
aabbmax[2] = max_fff(face_v1[2], face_v2[2], face_v3[2]);
/* calculate face normal once again SIGH */
sub_v3_v3v3(edge1, face_v1, face_v2);
@@ -1196,12 +1196,12 @@ static int sb_detect_face_collisionCached(float face_v1[3], float face_v2[3], fl
float t, tune = 10.0f;
int a, deflected=0;
aabbmin[0] = MIN3(face_v1[0], face_v2[0], face_v3[0]);
aabbmin[1] = MIN3(face_v1[1], face_v2[1], face_v3[1]);
aabbmin[2] = MIN3(face_v1[2], face_v2[2], face_v3[2]);
aabbmax[0] = MAX3(face_v1[0], face_v2[0], face_v3[0]);
aabbmax[1] = MAX3(face_v1[1], face_v2[1], face_v3[1]);
aabbmax[2] = MAX3(face_v1[2], face_v2[2], face_v3[2]);
aabbmin[0] = min_fff(face_v1[0], face_v2[0], face_v3[0]);
aabbmin[1] = min_fff(face_v1[1], face_v2[1], face_v3[1]);
aabbmin[2] = min_fff(face_v1[2], face_v2[2], face_v3[2]);
aabbmax[0] = max_fff(face_v1[0], face_v2[0], face_v3[0]);
aabbmax[1] = max_fff(face_v1[1], face_v2[1], face_v3[1]);
aabbmax[2] = max_fff(face_v1[2], face_v2[2], face_v3[2]);
hash = vertexowner->soft->scratch->colliderhash;
ihash = BLI_ghashIterator_new(hash);

View File

@@ -175,6 +175,42 @@ MINLINE int max_ii(int a, int b)
return (b < a) ? a : b;
}
MINLINE float min_fff(float a, float b, float c)
{
return min_ff(min_ff(a, b), c);
}
MINLINE float max_fff(float a, float b, float c)
{
return max_ff(max_ff(a, b), c);
}
MINLINE int min_iii(int a, int b, int c)
{
return min_ii(min_ii(a, b), c);
}
MINLINE int max_iii(int a, int b, int c)
{
return max_ii(max_ii(a, b), c);
}
MINLINE float min_ffff(float a, float b, float c, float d)
{
return min_ff(min_fff(a, b, c), d);
}
MINLINE float max_ffff(float a, float b, float c, float d)
{
return max_ff(max_fff(a, b, c), d);
}
MINLINE int min_iiii(int a, int b, int c, int d)
{
return min_ii(min_iii(a, b, c), d);
}
MINLINE int max_iiii(int a, int b, int c, int d)
{
return max_ii(max_iii(a, b, c), d);
}
MINLINE float signf(float f)
{
return (f < 0.f) ? -1.f : 1.f;

View File

@@ -266,8 +266,8 @@ void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll)
{
float cmax = MAX3(r, g, b);
float cmin = MIN3(r, g, b);
const float cmax = max_fff(r, g, b);
const float cmin = min_fff(r, g, b);
float h, s, l = (cmax + cmin) / 2.0f;
if (cmax == cmin) {

View File

@@ -140,7 +140,7 @@ float area_poly_v3(int nr, float verts[][3], const float normal[3])
x = fabsf(normal[0]);
y = fabsf(normal[1]);
z = fabsf(normal[2]);
max = MAX3(x, y, z);
max = max_fff(x, y, z);
if (max == y) py = 2;
else if (max == x) {
px = 1;
@@ -1198,10 +1198,10 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3]
return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda);
/* first a simple bounding box test */
if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0;
if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0;
if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0;
if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0;
if (min_fff(v0[a1], v1[a1], v2[a1]) > p1[a1]) return 0;
if (min_fff(v0[a2], v1[a2], v2[a2]) > p1[a2]) return 0;
if (max_fff(v0[a1], v1[a1], v2[a1]) < p1[a1]) return 0;
if (max_fff(v0[a2], v1[a2], v2[a2]) < p1[a2]) return 0;
/* then a full intersection test */
#endif

View File

@@ -7885,7 +7885,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
int maxres = MAX3(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]);
int maxres = max_iii(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]);
smd->domain->scale = smd->domain->dx * maxres;
smd->domain->dx = 1.0f / smd->domain->scale;
}

View File

@@ -204,10 +204,10 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input
}
#define UPDATE_INPUT { \
newInput.xmin = MIN4(newInput.xmin, coords[0], coords[2], coords[4]); \
newInput.ymin = MIN4(newInput.ymin, coords[1], coords[3], coords[5]); \
newInput.xmax = MAX4(newInput.xmax, coords[0], coords[2], coords[4]); \
newInput.ymax = MAX4(newInput.ymax, coords[1], coords[3], coords[5]); \
newInput.xmin = min_ffff(newInput.xmin, coords[0], coords[2], coords[4]); \
newInput.ymin = min_ffff(newInput.ymin, coords[1], coords[3], coords[5]); \
newInput.xmax = max_ffff(newInput.xmax, coords[0], coords[2], coords[4]); \
newInput.ymax = max_ffff(newInput.ymax, coords[1], coords[3], coords[5]); \
} (void)0
rcti newInput;
@@ -273,7 +273,7 @@ void ScreenLensDistortionOperation::updateVariables(float distortion, float disp
const float d = 0.25f * max_ff(min_ff(dispersion, 1.0f), 0.0f);
this->m_kr = max_ff(min_ff((this->m_kg + d), 1.0f), -0.999f);
this->m_kb = max_ff(min_ff((this->m_kg - d), 1.0f), -0.999f);
this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb);
this->m_maxk = max_fff(this->m_kr, this->m_kg, this->m_kb);
this->m_sc = (this->m_data->fit && (this->m_maxk > 0.0f)) ? (1.0f / (1.0f + 2.0f * this->m_maxk)) :
(1.0f / (1.0f + this->m_maxk));
this->m_drg = 4.0f * (this->m_kg - this->m_kr);

View File

@@ -634,7 +634,7 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end
if (aDst->bcount > 0 && aSrc->bcount > 0) {
int indexDst = 0, indexSrc = 0;
start = MAX3(start, aDst->buckets[0].val, aSrc->buckets[0].val);
start = max_fff(start, aDst->buckets[0].val, aSrc->buckets[0].val);
while (indexDst < aDst->bcount && aDst->buckets[indexDst].val < start) {
indexDst++;

View File

@@ -1146,7 +1146,7 @@ static float len_v3_tri_side_max(const float v1[3], const float v2[3], const flo
const float s2 = len_squared_v3v3(v2, v3);
const float s3 = len_squared_v3v3(v3, v1);
return sqrtf(MAX3(s1, s2, s3));
return sqrtf(max_fff(s1, s2, s3));
}
static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree,

View File

@@ -1062,7 +1062,7 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
static unsigned int mirror_facehash(const void *ptr)
{
const MFace *mf = ptr;
int v0, v1;
unsigned int v0, v1;
if (mf->v4) {
v0 = MIN4(mf->v1, mf->v2, mf->v3, mf->v4);

View File

@@ -127,7 +127,7 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings *
float longest_axis;
BKE_object_dimensions_get(domainob, dim);
longest_axis = MAX3(dim[0], dim[1], dim[2]);
longest_axis = max_fff(dim[0], dim[1], dim[2]);
return longest_axis * scene->unit.scale_length;
}

View File

@@ -123,9 +123,9 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
epsx = MIN4(pat_min[0] - marker->search_min[0], marker->search_max[0] - pat_max[0],
epsx = min_ffff(pat_min[0] - marker->search_min[0], marker->search_max[0] - pat_max[0],
fabsf(pat_min[0]), fabsf(pat_max[0])) / 2;
epsy = MIN4(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1],
epsy = min_ffff(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1],
fabsf(pat_min[1]), fabsf(pat_max[1])) / 2;
epsx = max_ff(epsx, 2.0f / width);
@@ -166,7 +166,7 @@ static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2])
d3 = dist_squared_to_line_segment_v2(p, v3, v4);
d4 = dist_squared_to_line_segment_v2(p, v4, v1);
return sqrtf(MIN4(d1, d2, d3, d4));
return sqrtf(min_ffff(d1, d2, d3, d4));
}
static float dist_to_crns(float co[2], float pos[2], float crns[4][2])
@@ -181,7 +181,7 @@ static float dist_to_crns(float co[2], float pos[2], float crns[4][2])
d3 = dist_squared_to_line_segment_v2(p, v3, v4);
d4 = dist_squared_to_line_segment_v2(p, v4, v1);
return sqrtf(MIN4(d1, d2, d3, d4));
return sqrtf(min_ffff(d1, d2, d3, d4));
}
static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbase, float co[2])
@@ -210,7 +210,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas
d3 = dist_to_rect(co, marker->pos, marker->search_min, marker->search_max);
/* choose minimal distance. useful for cases of overlapped markers. */
dist = MIN3(d1, d2, d3);
dist = min_fff(d1, d2, d3);
if (track == NULL || dist < mindist) {
track = cur;

View File

@@ -3416,10 +3416,10 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa
vec[2][0] = vec[3][0] - dist;
vec[2][1] = vec[3][1];
}
if (v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) {
if (v2d && min_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) {
/* clipped */
}
else if (v2d && MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) {
else if (v2d && max_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) {
/* clipped */
}
else {

View File

@@ -859,7 +859,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
* the other strips. */
if (!RNA_struct_property_is_set(op->ptr, "channel")) {
if (seq->seq1) {
int chan = MAX3(seq->seq1 ? seq->seq1->machine : 0,
int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0,
seq->seq2 ? seq->seq2->machine : 0,
seq->seq3 ? seq->seq3->machine : 0);
if (chan < MAXSEQ)

View File

@@ -449,8 +449,8 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
* inserting previously found vertex into the plane equation */
/* d0 = (viewnormal[0]*cv[i][0] + viewnormal[1]*cv[i][1] + viewnormal[2]*cv[i][2]); */ /* UNUSED */
ds = (ABS(viewnormal[0]) * size[0] + ABS(viewnormal[1]) * size[1] + ABS(viewnormal[2]) * size[2]);
dd = MAX3(sds->global_size[0], sds->global_size[1], sds->global_size[2]) / 128.f;
ds = (fabsf(viewnormal[0]) * size[0] + fabsf(viewnormal[1]) * size[1] + fabsf(viewnormal[2]) * size[2]);
dd = max_fff(sds->global_size[0], sds->global_size[1], sds->global_size[2]) / 128.f;
n = 0;
good_index = i;
@@ -570,7 +570,7 @@ void draw_smoke_velocity(SmokeDomainSettings *domain, Object *ob)
float min[3];
float *cell_size = domain->cell_size;
float step_size = ((float)MAX3(base_res[0], base_res[1], base_res[2])) / 16.f;
float step_size = ((float)max_iii(base_res[0], base_res[1], base_res[2])) / 16.f;
float vf = domain->scale / 16.f * 2.f; /* velocity factor */
glLineWidth(1.0f);
@@ -624,7 +624,7 @@ void draw_smoke_heat(SmokeDomainSettings *domain, Object *ob)
float min[3];
float *cell_size = domain->cell_size;
float step_size = ((float)MAX3(base_res[0], base_res[1], base_res[2])) / 16.f;
float step_size = ((float)max_iii(base_res[0], base_res[1], base_res[2])) / 16.f;
float vf = domain->scale / 16.f * 2.f; /* velocity factor */
/* set first position so that it doesn't jump when domain moves */

View File

@@ -2233,7 +2233,7 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar,
float new_dist;
sub_v3_v3v3(afm, max, min);
size = MAX3(afm[0], afm[1], afm[2]);
size = max_fff(afm[0], afm[1], afm[2]);
if (ok_dist) {
/* fix up zoom distance if needed */

View File

@@ -1071,10 +1071,8 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL
}
}
box[0] = (max[0] - min[0]);
box[1] = (max[1] - min[1]);
box[2] = (max[2] - min[2]);
size = MAX3(box[0], box[1], box[2]);
sub_v3_v3v3(box, max, min);
size = max_fff(box[0], box[1], box[2]);
/* do not zoom closer than the near clipping plane */
size = max_ff(size, v3d->near * 1.5f);

View File

@@ -3109,7 +3109,7 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
sina2 = sin(a2);
sina3 = sin(a3);
sinmax = MAX3(sina1, sina2, sina3);
sinmax = max_fff(sina1, sina2, sina3);
/* shift vertices to find most stable order */
if (sina3 != sinmax) {

View File

@@ -101,9 +101,9 @@ void GPU_render_text(MTFace *tface, int mode,
float line_start= 0.0f, line_height;
if (v4)
line_height= MAX4(v1[1], v2[1], v3[1], v4[2]) - MIN4(v1[1], v2[1], v3[1], v4[2]);
line_height = max_ffff(v1[1], v2[1], v3[1], v4[2]) - min_ffff(v1[1], v2[1], v3[1], v4[2]);
else
line_height= MAX3(v1[1], v2[1], v3[1]) - MIN3(v1[1], v2[1], v3[1]);
line_height = max_fff(v1[1], v2[1], v3[1]) - min_fff(v1[1], v2[1], v3[1]);
line_height *= 1.2f; /* could be an option? */
/* end multiline */

View File

@@ -85,7 +85,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb
// so in the case of pincushion (kn < 0), corners will be outside window.
// Now also optionally scales image such that black areas are not visible when distort factor is positive
// (makes distorted corners match window corners, but really only valid if mk<=0.5)
const float mk = MAX3(kr, kg, kb);
const float mk = max_fff(kr, kg, kb);
const float sc = (fit && (mk > 0.f)) ? (1.f/(1.f + 2.f*mk)) : (1.f/(1.f + mk));
const float drg = 4.f*(kg - kr), dgb = 4.f*(kb - kg);

View File

@@ -1102,7 +1102,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject
return NULL;
}
dims = MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size);
dims = max_iiii(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size);
for (i = 0; i < vec_k1->size; i++) k1[i] = vec_k1->vec[i];
for (i = 0; i < vec_h1->size; i++) h1[i] = vec_h1->vec[i];

View File

@@ -542,13 +542,13 @@ static void octree_fill_rayface(Octree *oc, RayFace *face)
oc2 = rts[1][c];
oc3 = rts[2][c];
if (!RE_rayface_isQuad(face)) {
ocmin[c] = MIN3(oc1, oc2, oc3);
ocmax[c] = MAX3(oc1, oc2, oc3);
ocmin[c] = min_iii(oc1, oc2, oc3);
ocmax[c] = max_iii(oc1, oc2, oc3);
}
else {
oc4 = rts[3][c];
ocmin[c] = MIN4(oc1, oc2, oc3, oc4);
ocmax[c] = MAX4(oc1, oc2, oc3, oc4);
ocmin[c] = min_iiii(oc1, oc2, oc3, oc4);
ocmax[c] = max_iiii(oc1, oc2, oc3, oc4);
}
if (ocmax[c] > oc->ocres - 1) ocmax[c] = oc->ocres - 1;
if (ocmin[c] < 0) ocmin[c] = 0;
@@ -993,7 +993,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
}
xo = ocx1; yo = ocy1; zo = ocz1;
dda_lambda = MIN3(lambda_x, lambda_y, lambda_z);
dda_lambda = min_fff(lambda_x, lambda_y, lambda_z);
vec2[0] = ox1;
vec2[1] = oy1;
@@ -1083,7 +1083,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
}
dda_lambda = MIN3(lambda_x, lambda_y, lambda_z);
dda_lambda = min_fff(lambda_x, lambda_y, lambda_z);
if (dda_lambda == lambda_o) break;
/* to make sure the last node is always checked */
if (lambda_o >= 1.0f) break;

View File

@@ -286,7 +286,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
if (texres->talpha) texres->tin= texres->ta;
else if (tex->imaflag & TEX_CALCALPHA) {
texres->ta= texres->tin= MAX3(texres->tr, texres->tg, texres->tb);
texres->ta = texres->tin = max_fff(texres->tr, texres->tg, texres->tb);
}
else texres->ta= texres->tin= 1.0;
@@ -1112,10 +1112,10 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
}
/* pixel coordinates */
minx = MIN3(dxt[0], dyt[0], dxt[0] + dyt[0]);
maxx = MAX3(dxt[0], dyt[0], dxt[0] + dyt[0]);
miny = MIN3(dxt[1], dyt[1], dxt[1] + dyt[1]);
maxy = MAX3(dxt[1], dyt[1], dxt[1] + dyt[1]);
minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
maxx = max_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
miny = min_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
maxy = max_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
/* tex_sharper has been removed */
minx = (maxx - minx)*0.5f;
@@ -1416,7 +1416,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
}
if (tex->imaflag & TEX_CALCALPHA)
texres->ta = texres->tin = texres->ta * MAX3(texres->tr, texres->tg, texres->tb);
texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb);
else
texres->tin = texres->ta;
if (tex->flag & TEX_NEGALPHA) texres->ta = 1.f - texres->ta;
@@ -1535,10 +1535,10 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
/* pixel coordinates */
minx = MIN3(dxt[0], dyt[0], dxt[0] + dyt[0]);
maxx = MAX3(dxt[0], dyt[0], dxt[0] + dyt[0]);
miny = MIN3(dxt[1], dyt[1], dxt[1] + dyt[1]);
maxy = MAX3(dxt[1], dyt[1], dxt[1] + dyt[1]);
minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
maxx = max_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
miny = min_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
maxy = max_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
/* tex_sharper has been removed */
minx= (maxx-minx)/2.0f;
@@ -1826,7 +1826,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
}
if (tex->imaflag & TEX_CALCALPHA) {
texres->ta= texres->tin= texres->ta*MAX3(texres->tr, texres->tg, texres->tb);
texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb);
}
else texres->tin= texres->ta;

View File

@@ -1520,8 +1520,8 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int
return 0;
/* require intensities not being too different */
mino = MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity);
maxo = MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity);
mino = min_ffff(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity);
maxo = max_ffff(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity);
if (maxo - mino > 0.05f)
return 0;
@@ -1793,9 +1793,9 @@ void sample_occ(Render *re, ShadeInput *shi)
copy_v3_v3(sample->ao, shi->ao);
copy_v3_v3(sample->env, shi->env);
copy_v3_v3(sample->indirect, shi->indirect);
sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]);
sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2]));
sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2]));
sample->intensity = max_fff(sample->ao[0], sample->ao[1], sample->ao[2]);
sample->intensity = max_ff(sample->intensity, max_fff(sample->env[0], sample->env[1], sample->env[2]));
sample->intensity = max_ff(sample->intensity, max_fff(sample->indirect[0], sample->indirect[1], sample->indirect[2]));
sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco);
sample->filled = 1;
}
@@ -1888,9 +1888,9 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp)
copy_v3_v3(sample->ao, shi->ao);
copy_v3_v3(sample->env, shi->env);
copy_v3_v3(sample->indirect, shi->indirect);
sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]);
sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2]));
sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2]));
sample->intensity = max_fff(sample->ao[0], sample->ao[1], sample->ao[2]);
sample->intensity = max_ff(sample->intensity, max_fff(sample->env[0], sample->env[1], sample->env[2]));
sample->intensity = max_ff(sample->intensity, max_fff(sample->indirect[0], sample->indirect[1], sample->indirect[2]));
sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco);
sample->x = shi->xs;
sample->y = shi->ys;

View File

@@ -1745,8 +1745,8 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
else { /* 3d procedural, estimate from all dx/dy elems */
const float adx[3] = {fabsf(dx[0]), fabsf(dx[1]), fabsf(dx[2])};
const float ady[3] = {fabsf(dy[0]), fabsf(dy[1]), fabsf(dy[2])};
du = MAX3(adx[0], adx[1], adx[2]);
dv = MAX3(ady[0], ady[1], ady[2]);
du = max_fff(adx[0], adx[1], adx[2]);
dv = max_fff(ady[0], ady[1], ady[2]);
}
}

View File

@@ -1884,7 +1884,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
/* note: shi->mode! */
if (shi->mode & MA_TRANSP && (shi->mode & (MA_ZTRANSP|MA_RAYTRANSP))) {
if (shi->spectra!=0.0f) {
float t = MAX3(shr->spec[0], shr->spec[1], shr->spec[2]);
float t = max_fff(shr->spec[0], shr->spec[1], shr->spec[2]);
t *= shi->spectra;
if (t>1.0f) t= 1.0f;
shi->alpha= (1.0f-t)*shi->alpha+t;

View File

@@ -354,7 +354,7 @@ static void ms_diffuse(Render *re, int do_test_break, float *x0, float *x, float
static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Material *ma)
{
const float diff = ma->vol.ms_diff * 0.001f; /* compensate for scaling for a nicer UI range */
const int simframes = (int)(ma->vol.ms_spread * (float)MAX3(vp->res[0], vp->res[1], vp->res[2]));
const int simframes = (int)(ma->vol.ms_spread * (float)max_iii(vp->res[0], vp->res[1], vp->res[2]));
const int shade_type = ma->vol.shade_type;
float fac = ma->vol.ms_intensity;
@@ -652,7 +652,7 @@ static int precache_resolution(Render *re, VolumePrecache *vp, ObjectInstanceRen
global_bounds_obi(re, obi, bbmin, bbmax);
sub_v3_v3v3(dim, bbmax, bbmin);
div = MAX3(dim[0], dim[1], dim[2]);
div = max_fff(dim[0], dim[1], dim[2]);
dim[0] /= div;
dim[1] /= div;
dim[2] /= div;