diff options
author | rodri <rgl@antares-labs.eu> | 2024-08-27 12:06:45 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-08-27 12:06:45 +0000 |
commit | 3b06ad551d6706907b0d6cbf25807e1ef7e62ca9 (patch) | |
tree | 8094b9befe8586391fc5bbac7de000362afa9ef0 | |
parent | 981b643df2def9846c112469e94644500015b8e6 (diff) | |
download | 3dee-3b06ad551d6706907b0d6cbf25807e1ef7e62ca9.tar.gz 3dee-3b06ad551d6706907b0d6cbf25807e1ef7e62ca9.tar.bz2 3dee-3b06ad551d6706907b0d6cbf25807e1ef7e62ca9.zip |
remove duplicate min and max functions.
-rw-r--r-- | med.c | 20 | ||||
-rw-r--r-- | procgen.c | 3 | ||||
-rw-r--r-- | solar.c | 28 | ||||
-rw-r--r-- | vis.c | 30 |
4 files changed, 21 insertions, 60 deletions
@@ -106,18 +106,6 @@ static int doprof; 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 @@ gouraudvshader(VSparams *sp) 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 @@ phongshader(FSparams *sp) 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 @@ phongshader(FSparams *sp) 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); @@ -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; @@ -168,26 +168,14 @@ static int showskybox; 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 @@ static Point3 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) }; } @@ -97,18 +97,6 @@ static int depthon; 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 @@ gouraudvshader(VSparams *sp) 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 @@ phongshader(FSparams *sp) 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 @@ phongshader(FSparams *sp) 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 @@ blinnshader(FSparams *sp) 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 @@ blinnshader(FSparams *sp) 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 @@ toonvshader(VSparams *sp) 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 @@ boxshader(FSparams *sp) 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); |