ref: 3b06ad551d6706907b0d6cbf25807e1ef7e62ca9
parent: 981b643df2def9846c112469e94644500015b8e6
author: rodri <rgl@antares-labs.eu>
date: Tue Aug 27 08:06:45 EDT 2024
remove duplicate min and max functions.
--- a/med.c
+++ b/med.c
@@ -106,18 +106,6 @@
static int showhud;
Color (*tsampler)(Texture*,Point2);
-static int
-min(int a, int b)
-{
- return a < b? a: b;
-}
-
-static int
-max(int a, int b)
-{
- return a > b? a: b;
-}
-
static Point3
Vecquat(Quaternion q)
{
@@ -291,13 +279,13 @@
ambient = mulpt3(lightc, Ka);
ambient = modulapt3(ambient, m.diffuse);
- Kd = fmax(0, dotvec3(sp->v->n, lightdir));
+ Kd = max(0, dotvec3(sp->v->n, lightdir));
diffuse = mulpt3(lightc, Kd);
diffuse = modulapt3(diffuse, m.diffuse);
lookdir = normvec3(subpt3(sp->su->camera->p, pos));
lightdir = qrotate(lightdir, sp->v->n, PI);
- spec = pow(fmax(0, dotvec3(lookdir, lightdir)), m.shininess);
+ spec = pow(max(0, dotvec3(lookdir, lightdir)), m.shininess);
specular = mulpt3(lightc, spec*Ks);
specular = modulapt3(specular, m.specular);
@@ -403,7 +391,7 @@
ambient = mulpt3(lightc, Ka);
ambient = modulapt3(ambient, m.diffuse);
- Kd = fmax(0, dotvec3(n, lightdir));
+ Kd = max(0, dotvec3(n, lightdir));
diffuse = mulpt3(lightc, Kd);
diffuse = modulapt3(diffuse, m.diffuse);
@@ -412,7 +400,7 @@
lookdir = normvec3(subpt3(sp->su->camera->p, pos));
lightdir = qrotate(lightdir, n, PI);
- spec = pow(fmax(0, dotvec3(lookdir, lightdir)), m.shininess);
+ spec = pow(max(0, dotvec3(lookdir, lightdir)), m.shininess);
specular = mulpt3(lightc, spec*Ks);
specular = modulapt3(specular, m.specular);
--- a/procgen.c
+++ b/procgen.c
@@ -17,9 +17,6 @@
#include "libgraphics/graphics.h"
#include "fns.h"
-#define min(a, b) ((a)<(b)?(a):(b))
-#define max(a, b) ((a)>(b)?(a):(b))
-
Renderer *rctl;
Camera *cam;
Scene *scn;
--- a/solar.c
+++ b/solar.c
@@ -168,26 +168,14 @@
static int doprof;
static int showhud;
-static int
-min(int a, int b)
-{
- return a < b? a: b;
-}
-
-static int
-max(int a, int b)
-{
- return a > b? a: b;
-}
-
static Point3
minpt3(Point3 a, Point3 b)
{
return (Point3){
- fmin(a.x, b.x),
- fmin(a.y, b.y),
- fmin(a.z, b.z),
- fmin(a.w, b.w)
+ min(a.x, b.x),
+ min(a.y, b.y),
+ min(a.z, b.z),
+ min(a.w, b.w)
};
}
@@ -195,10 +183,10 @@
maxpt3(Point3 a, Point3 b)
{
return (Point3){
- fmax(a.x, b.x),
- fmax(a.y, b.y),
- fmax(a.z, b.z),
- fmax(a.w, b.w)
+ max(a.x, b.x),
+ max(a.y, b.y),
+ max(a.z, b.z),
+ max(a.w, b.w)
};
}
--- a/vis.c
+++ b/vis.c
@@ -97,18 +97,6 @@
static int abuffon;
Color (*tsampler)(Texture*,Point2);
-static int
-min(int a, int b)
-{
- return a < b? a: b;
-}
-
-static int
-max(int a, int b)
-{
- return a > b? a: b;
-}
-
static Point3
Vecquat(Quaternion q)
{
@@ -151,13 +139,13 @@
ambient = mulpt3(lightc, Ka);
ambient = modulapt3(ambient, m.diffuse);
- Kd = fmax(0, dotvec3(sp->v->n, lightdir));
+ Kd = max(0, dotvec3(sp->v->n, lightdir));
diffuse = mulpt3(lightc, Kd);
diffuse = modulapt3(diffuse, m.diffuse);
lookdir = normvec3(subpt3(sp->su->camera->p, pos));
lightdir = qrotate(lightdir, sp->v->n, PI);
- spec = pow(fmax(0, dotvec3(lookdir, lightdir)), m.shininess);
+ spec = pow(max(0, dotvec3(lookdir, lightdir)), m.shininess);
specular = mulpt3(lightc, spec*Ks);
specular = modulapt3(specular, m.specular);
@@ -263,7 +251,7 @@
ambient = mulpt3(lightc, Ka);
ambient = modulapt3(ambient, m.diffuse);
- Kd = fmax(0, dotvec3(n, lightdir));
+ Kd = max(0, dotvec3(n, lightdir));
diffuse = mulpt3(lightc, Kd);
diffuse = modulapt3(diffuse, m.diffuse);
@@ -272,7 +260,7 @@
lookdir = normvec3(subpt3(sp->su->camera->p, pos));
lightdir = qrotate(lightdir, n, PI);
- spec = pow(fmax(0, dotvec3(lookdir, lightdir)), m.shininess);
+ spec = pow(max(0, dotvec3(lookdir, lightdir)), m.shininess);
specular = mulpt3(lightc, spec*Ks);
specular = modulapt3(specular, m.specular);
@@ -335,7 +323,7 @@
ambient = mulpt3(lightc, Ka);
ambient = modulapt3(ambient, m.diffuse);
- Kd = fmax(0, dotvec3(n, lightdir));
+ Kd = max(0, dotvec3(n, lightdir));
diffuse = mulpt3(lightc, Kd);
diffuse = modulapt3(diffuse, m.diffuse);
@@ -344,7 +332,7 @@
lookdir = normvec3(subpt3(sp->su->camera->p, pos));
lightdir = normvec3(addpt3(lookdir, lightdir)); /* half vector */
- spec = pow(fmax(0, dotvec3(n, lightdir)), m.shininess);
+ spec = pow(max(0, dotvec3(n, lightdir)), m.shininess);
specular = mulpt3(lightc, spec*Ks);
specular = modulapt3(specular, m.specular);
@@ -362,7 +350,7 @@
sp->v->n = model2world(sp->su->entity, sp->v->n);
pos = model2world(sp->su->entity, sp->v->p);
lightdir = normvec3(subpt3(light.p, pos));
- intens = fmax(0, dotvec3(sp->v->n, lightdir));
+ intens = max(0, dotvec3(sp->v->n, lightdir));
addvattr(sp->v, "intensity", VANumber, &intens);
if(sp->v->mtl != nil)
sp->v->c = sp->v->mtl->diffuse;
@@ -496,8 +484,8 @@
p = Pt2(fabs(uv.x - 0.5), fabs(uv.y - 0.5), 1);
p = subpt2(p, r);
- p.x = fmax(p.x, 0);
- p.y = fmax(p.y, 0);
+ p.x = max(p.x, 0);
+ p.y = max(p.y, 0);
if(vec2len(p) > 0)
return Vec3(0,0,0);