Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++20-ify #267

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ endif()

project("Blue Nebula" C CXX)

# require at least C++14 and C11
# require at least C++20 and C11
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(src)
30 changes: 15 additions & 15 deletions src/engine/animmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -891,14 +891,14 @@ struct animmodel : model
vec oaxis, oforward;
matrixstack[matrixpos].transposedtransformnormal(axis, oaxis);
float pitchamount = pitchscale*pitch + pitchoffset;
if(pitchmin || pitchmax) pitchamount = clamp(pitchamount, pitchmin, pitchmax);
if(pitchmin || pitchmax) pitchamount = std::clamp(pitchamount, pitchmin, pitchmax);
if(as->cur.anim&ANIM_NOPITCH || (as->interp < 1 && as->prev.anim&ANIM_NOPITCH))
pitchamount *= (as->cur.anim&ANIM_NOPITCH ? 0 : as->interp) + (as->interp < 1 && as->prev.anim&ANIM_NOPITCH ? 0 : 1-as->interp);
if(pitchamount)
{
++matrixpos;
matrixstack[matrixpos] = matrixstack[matrixpos-1];
matrixstack[matrixpos].rotate(pitchamount*RAD, oaxis);
matrixstack[matrixpos].rotate(pitchamount*rad, oaxis);
}
matrixstack[matrixpos].transposedtransformnormal(forward, oforward);

Expand Down Expand Up @@ -933,9 +933,9 @@ struct animmodel : model
{
linkedpart &link = links[i];
link.matrix.translate(link.translate, resize);
if(link.rotate.x) link.matrix.rotate_around_z(link.rotate.x*RAD);
if(link.rotate.z) link.matrix.rotate_around_x(-link.rotate.z*RAD);
if(link.rotate.y) link.matrix.rotate_around_y(link.rotate.y*RAD);
if(link.rotate.x) link.matrix.rotate_around_z(link.rotate.x*rad);
if(link.rotate.z) link.matrix.rotate_around_x(-link.rotate.z*rad);
if(link.rotate.y) link.matrix.rotate_around_y(link.rotate.y*rad);

matrixpos++;
matrixstack[matrixpos].mul(matrixstack[matrixpos-1], link.matrix);
Expand Down Expand Up @@ -1073,14 +1073,14 @@ struct animmodel : model
if(!d || !d->ragdoll || anim&ANIM_RAGDOLL)
{
matrixstack[0].settranslation(o);
if(yaw) matrixstack[0].rotate_around_z(yaw*RAD);
if(roll) matrixstack[0].rotate_around_x(-roll*RAD);
if(yaw) matrixstack[0].rotate_around_z(yaw*rad);
if(roll) matrixstack[0].rotate_around_x(-roll*rad);
matrixstack[0].transformnormal(vec(axis), axis);
matrixstack[0].transformnormal(vec(forward), forward);
if(offsetyaw) matrixstack[0].rotate_around_z(offsetyaw*RAD);
if(offsetroll) matrixstack[0].rotate_around_x(-offsetroll*RAD);
if(syaw) matrixstack[0].rotate_around_z(syaw*RAD);
if(sroll) matrixstack[0].rotate_around_x(-sroll*RAD);
if(offsetyaw) matrixstack[0].rotate_around_z(offsetyaw*rad);
if(offsetroll) matrixstack[0].rotate_around_x(-offsetroll*rad);
if(syaw) matrixstack[0].rotate_around_z(syaw*rad);
if(sroll) matrixstack[0].rotate_around_x(-sroll*rad);
}
else
{
Expand Down Expand Up @@ -1164,9 +1164,9 @@ struct animmodel : model
void initmatrix(matrix4x3 &m)
{
m.identity();
if(offsetyaw) m.rotate_around_z(offsetyaw*RAD);
if(offsetroll) m.rotate_around_x(-offsetroll*RAD);
if(offsetpitch) m.rotate_around_y(offsetpitch*RAD);
if(offsetyaw) m.rotate_around_z(offsetyaw*rad);
if(offsetroll) m.rotate_around_x(-offsetroll*rad);
if(offsetpitch) m.rotate_around_y(offsetpitch*rad);
}

void genBIH(vector<BIH::mesh> &bih)
Expand Down Expand Up @@ -1562,7 +1562,7 @@ template<class MDL, class MESH> struct modelcommands

static void setmaterial(char *meshname, int *material, int *material2)
{
loopskins(meshname, s, { s.material = clamp(*material, 0, int(MAXLIGHTMATERIALS)); s.material2 = clamp(*material2, 0, int(MAXLIGHTMATERIALS)); });
loopskins(meshname, s, { s.material = std::clamp(*material, 0, int(MAXLIGHTMATERIALS)); s.material2 = std::clamp(*material2, 0, int(MAXLIGHTMATERIALS)); });
}

static void setlink(int *parent, int *child, char *tagname, float *x, float *y, float *z, float *yaw, float *pitch, float *roll)
Expand Down
4 changes: 2 additions & 2 deletions src/engine/bih.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ bool BIH::triintersect(const mesh &m, int tidx, const vec &mo, const vec &mray,
{
vec2 at = m.gettc(t.vert[0]), bt = m.gettc(t.vert[1]).sub(at).mul(v*invdet), ct = m.gettc(t.vert[2]).sub(at).mul(w*invdet);
at.add(bt).add(ct);
int si = clamp(int(m.tex->xs * at.x), 0, m.tex->xs-1),
ti = clamp(int(m.tex->ys * at.y), 0, m.tex->ys-1);
int si = std::clamp(int(m.tex->xs * at.x), 0, m.tex->xs-1),
ti = std::clamp(int(m.tex->ys * at.y), 0, m.tex->ys-1);
if(!(m.tex->alphamask[ti*((m.tex->xs+7)/8) + si/8] & (1<<(si%8)))) return false;
}
if(!(mode&RAY_SHADOW)) hitsurface = m.xformnorm.transform(n).normalize();
Expand Down
34 changes: 17 additions & 17 deletions src/engine/blend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ uchar lookupblendmap(BlendMapCache *cache, const vec &pos)
rx = ix-cache->origin.x, ry = iy-cache->origin.y;
loop(vy, 2) loop(vx, 2)
{
int cx = clamp(rx+vx, 0, (1<<cache->scale)-1), cy = clamp(ry+vy, 0, (1<<cache->scale)-1);
int cx = std::clamp(rx+vx, 0, (1<<cache->scale)-1), cy = std::clamp(ry+vy, 0, (1<<cache->scale)-1);
if(cache->node.type==BM_IMAGE)
*val++ = cache->node.image->data[cy*BM_IMAGE_SIZE + cx];
else *val++ = lookupblendmap(cx, cy, cache->node.branch, cache->scale);
Expand Down Expand Up @@ -265,10 +265,10 @@ static void fillblendmap(uchar &type, BlendMapNode &node, int size, uchar val, i
void fillblendmap(int x, int y, int w, int h, uchar val)
{
int bmsize = hdr.worldsize>>BM_SCALE,
x1 = clamp(x, 0, bmsize),
y1 = clamp(y, 0, bmsize),
x2 = clamp(x+w, 0, bmsize),
y2 = clamp(y+h, 0, bmsize);
x1 = std::clamp(x, 0, bmsize),
y1 = std::clamp(y, 0, bmsize),
x2 = std::clamp(x+w, 0, bmsize),
y2 = std::clamp(y+h, 0, bmsize);
if(max(x1, y1) >= bmsize || min(x2, y2) <= 0 || x1>=x2 || y1>=y2) return;
fillblendmap(blendmap.type, blendmap, bmsize, val, x1, y1, x2, y2);
}
Expand Down Expand Up @@ -312,10 +312,10 @@ static void invertblendmap(uchar &type, BlendMapNode &node, int size, int x1, in
void invertblendmap(int x, int y, int w, int h)
{
int bmsize = hdr.worldsize>>BM_SCALE,
x1 = clamp(x, 0, bmsize),
y1 = clamp(y, 0, bmsize),
x2 = clamp(x+w, 0, bmsize),
y2 = clamp(y+h, 0, bmsize);
x1 = std::clamp(x, 0, bmsize),
y1 = std::clamp(y, 0, bmsize),
x2 = std::clamp(x+w, 0, bmsize),
y2 = std::clamp(y+h, 0, bmsize);
if(max(x1, y1) >= bmsize || min(x2, y2) <= 0 || x1>=x2 || y1>=y2) return;
invertblendmap(blendmap.type, blendmap, bmsize, x1, y1, x2, y2);
}
Expand Down Expand Up @@ -392,8 +392,8 @@ static void blitblendmap(uchar &type, BlendMapNode &node, int bmx, int bmy, int
memset(node.image->data, val, sizeof(node.image->data));
}

int x1 = clamp(sx - bmx, 0, bmsize), y1 = clamp(sy - bmy, 0, bmsize),
x2 = clamp(sx+sw - bmx, 0, bmsize), y2 = clamp(sy+sh - bmy, 0, bmsize);
int x1 = std::clamp(sx - bmx, 0, bmsize), y1 = std::clamp(sy - bmy, 0, bmsize),
x2 = std::clamp(sx+sw - bmx, 0, bmsize), y2 = std::clamp(sy+sh - bmy, 0, bmsize);
uchar *dst = &node.image->data[y1*BM_IMAGE_SIZE + x1];
src += max(bmy - sy, 0)*sw + max(bmx - sx, 0);
loopi(y2-y1)
Expand Down Expand Up @@ -545,7 +545,7 @@ void delblendbrush(const char *name)
delete brushes[i];
brushes.remove(i--);
}
curbrush = brushes.empty() ? -1 : clamp(curbrush, 0, brushes.length()-1);
curbrush = brushes.empty() ? -1 : std::clamp(curbrush, 0, brushes.length()-1);
}

void addblendbrush(const char *name, const char *imgname)
Expand Down Expand Up @@ -626,7 +626,7 @@ void rotateblendbrush(int *val)
{
if(!canpaintblendmap()) return;

int numrots = *val < 0 ? 3 : clamp(*val, 1, 5);
int numrots = *val < 0 ? 3 : std::clamp(*val, 1, 5);
BlendBrush *brush = brushes[curbrush];
brush->reorient(numrots>=2 && numrots<=4, numrots<=2 || numrots==5, (numrots&5)==1);
}
Expand All @@ -638,8 +638,8 @@ void paintblendmap(bool msg)
if(!canpaintblendmap(true, false, msg)) return;

BlendBrush *brush = brushes[curbrush];
int x = (int)floor(clamp(worldpos.x, 0.0f, float(hdr.worldsize))/(1<<BM_SCALE) - 0.5f*brush->w),
y = (int)floor(clamp(worldpos.y, 0.0f, float(hdr.worldsize))/(1<<BM_SCALE) - 0.5f*brush->h);
int x = (int)floor(std::clamp(worldpos.x, 0.0f, float(hdr.worldsize))/(1<<BM_SCALE) - 0.5f*brush->w),
y = (int)floor(std::clamp(worldpos.y, 0.0f, float(hdr.worldsize))/(1<<BM_SCALE) - 0.5f*brush->h);
blitblendmap(brush->data, x, y, brush->w, brush->h);
previewblends(ivec((x-1)<<BM_SCALE, (y-1)<<BM_SCALE, 0),
ivec((x+brush->w+1)<<BM_SCALE, (y+brush->h+1)<<BM_SCALE, hdr.worldsize));
Expand Down Expand Up @@ -733,8 +733,8 @@ void renderblendbrush()
if(!blendpaintmode || !brushes.inrange(curbrush)) return;

BlendBrush *brush = brushes[curbrush];
int x1 = (int)floor(clamp(worldpos.x, 0.0f, float(hdr.worldsize))/(1<<BM_SCALE) - 0.5f*brush->w) << BM_SCALE,
y1 = (int)floor(clamp(worldpos.y, 0.0f, float(hdr.worldsize))/(1<<BM_SCALE) - 0.5f*brush->h) << BM_SCALE,
int x1 = (int)floor(std::clamp(worldpos.x, 0.0f, float(hdr.worldsize))/(1<<BM_SCALE) - 0.5f*brush->w) << BM_SCALE,
y1 = (int)floor(std::clamp(worldpos.y, 0.0f, float(hdr.worldsize))/(1<<BM_SCALE) - 0.5f*brush->h) << BM_SCALE,
x2 = x1 + (brush->w << BM_SCALE),
y2 = y1 + (brush->h << BM_SCALE);

Expand Down
47 changes: 27 additions & 20 deletions src/engine/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ char *svariable(const char *name, const char *cur, char **storage, identfun fun,
void setvar(const char *name, int i, bool dofunc, bool def)
{
GETVAR(id, ID_VAR, name, );
*id->storage.i = clamp(i, id->minval, id->maxval);
*id->storage.i = std::clamp(i, id->minval, id->maxval);
if(def || versioning)
{
id->def.i = i;
Expand All @@ -554,7 +554,7 @@ void setvar(const char *name, int i, bool dofunc, bool def)
void setfvar(const char *name, float f, bool dofunc, bool def)
{
GETVAR(id, ID_FVAR, name, );
*id->storage.f = clamp(f, id->minvalf, id->maxvalf);
*id->storage.f = std::clamp(f, id->minvalf, id->maxvalf);
if(def || versioning)
{
id->def.f = f;
Expand Down Expand Up @@ -1559,10 +1559,13 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
bool more = compileword(code, p, VAL_ANY, idname, idlen);
if(!more) goto endstatement;
skipcomments(p);
if(p[0] == '=') switch(p[1])
{
if (p[0] == '=') {
switch(p[1]) {
case '/':
if(p[2] != '/') break;
if (p[2] != '/') {
break;
}
[[fallthrough]];
case ';': case ' ': case '\t': case '\r': case '\n': case '\0':
p++;
if(idname)
Expand All @@ -1574,6 +1577,8 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
if(!(more = compilearg(code, p, VAL_ANY))) compilestr(code);
code.add(id && idname ? (id->index < MAXARGS ? CODE_ALIASARG : CODE_ALIAS)|(id->index<<8) : CODE_ALIASU);
goto endstatement;
break;
}
}
numargs = 0;
if(!idname)
Expand Down Expand Up @@ -2797,8 +2802,10 @@ void explodelist(const char *s, vector<char *> &elems, int limit)
void explodelist(const char *s, std::vector<std::string> &elems, int limit)
{
const char *start, *end;
while((limit < 0 || elems.size() < limit) && parselist(s, start, end))

while ((limit < 0 || elems.size() < static_cast<size_t>(limit)) && parselist(s, start, end)) {
elems.emplace_back(std::string(start, end-start));
}
}

char *indexlist(const char *s, int pos)
Expand Down Expand Up @@ -2842,8 +2849,8 @@ COMMAND(0, at, "si1V");

void substring(char *s, int *start, int *count, int *numargs)
{
int len = strlen(s), offset = clamp(*start, 0, len);
commandret->setstr(newstring(&s[offset], *numargs >= 3 ? clamp(*count, 0, len - offset) : len - offset));
int len = strlen(s), offset = std::clamp(*start, 0, len);
commandret->setstr(newstring(&s[offset], *numargs >= 3 ? std::clamp(*count, 0, len - offset) : len - offset));
}
COMMAND(0, substring, "siiN");

Expand Down Expand Up @@ -3273,7 +3280,7 @@ ICOMMAND(0, ^~, "ii", (int *a, int *b), intret(*a ^ ~*b));
ICOMMAND(0, &~, "ii", (int *a, int *b), intret(*a & ~*b));
ICOMMAND(0, |~, "ii", (int *a, int *b), intret(*a | ~*b));
ICOMMAND(0, <<, "ii", (int *a, int *b), intret(*b < 32 ? *a << max(*b, 0) : 0));
ICOMMAND(0, >>, "ii", (int *a, int *b), intret(*a >> clamp(*b, 0, 31)));
ICOMMAND(0, >>, "ii", (int *a, int *b), intret(*a >> std::clamp(*b, 0, 31)));
ICOMMAND(0, &&, "e1V", (tagval *args, int numargs),
{
if(!numargs) intret(1);
Expand All @@ -3297,17 +3304,17 @@ ICOMMAND(0, ||, "e1V", (tagval *args, int numargs),

ICOMMAND(0, mod, "ii", (int *a, int *b), intret(*b ? *a % *b : 0));
ICOMMAND(0, modf, "ff", (float *a, float *b), floatret(*b ? fmod(*a, *b) : 0));
ICOMMAND(0, sin, "f", (float *a), floatret(sin(*a*RAD)));
ICOMMAND(0, cos, "f", (float *a), floatret(cos(*a*RAD)));
ICOMMAND(0, tan, "f", (float *a), floatret(tan(*a*RAD)));
ICOMMAND(0, asin, "f", (float *a), floatret(asin(*a)/RAD));
ICOMMAND(0, acos, "f", (float *a), floatret(acos(*a)/RAD));
ICOMMAND(0, atan, "f", (float *a), floatret(atan(*a)/RAD));
ICOMMAND(0, atan2, "ff", (float *y, float *x), floatret(atan2(*y, *x)/RAD));
ICOMMAND(0, sin, "f", (float *a), floatret(sin(*a*rad)));
ICOMMAND(0, cos, "f", (float *a), floatret(cos(*a*rad)));
ICOMMAND(0, tan, "f", (float *a), floatret(tan(*a*rad)));
ICOMMAND(0, asin, "f", (float *a), floatret(asin(*a)/rad));
ICOMMAND(0, acos, "f", (float *a), floatret(acos(*a)/rad));
ICOMMAND(0, atan, "f", (float *a), floatret(atan(*a)/rad));
ICOMMAND(0, atan2, "ff", (float *y, float *x), floatret(atan2(*y, *x)/rad));
ICOMMAND(0, sqrt, "f", (float *a), floatret(sqrt(*a)));
ICOMMAND(0, pow, "ff", (float *a, float *b), floatret(pow(*a, *b)));
ICOMMAND(0, loge, "f", (float *a), floatret(log(*a)));
ICOMMAND(0, log2, "f", (float *a), floatret(log(*a)/M_LN2));
ICOMMAND(0, log2, "f", (float *a), floatret(log(*a)/ln2));
ICOMMAND(0, log10, "f", (float *a), floatret(log10(*a)));
ICOMMAND(0, exp, "f", (float *a), floatret(exp(*a)));
ICOMMAND(0, min, "V", (tagval *args, int numargs),
Expand Down Expand Up @@ -3509,8 +3516,8 @@ ICOMMAND(0, stringreplace, "sss", (char *s, char *o, char *n), commandret->setst
void stringsplice(const char *s, const char *vals, int *skip, int *count)
{
int slen = strlen(s), vlen = strlen(vals),
offset = clamp(*skip, 0, slen),
len = clamp(*count, 0, slen - offset);
offset = std::clamp(*skip, 0, slen),
len = std::clamp(*count, 0, slen - offset);
char *p = newstring(slen - len + vlen);
if(offset) memcpy(p, s, offset);
if(vlen) memcpy(&p[offset], vals, vlen);
Expand Down Expand Up @@ -3658,4 +3665,4 @@ char *limitstring(const char *str, size_t len)
copystring(limitstrtext, str, len);
return limitstrtext;
}
ICOMMAND(0, limitstring, "si", (char *s, int *n), result(limitstring(s, *n)));
ICOMMAND(0, limitstring, "si", (char *s, int *n), result(limitstring(s, *n)));
2 changes: 1 addition & 1 deletion src/engine/decal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ struct decalrenderer
decaltangent = vec(dir.z, -dir.x, dir.y);
decaltangent.sub(vec(dir).mul(decaltangent.dot(dir)));
#endif
if(flags&DF_ROTATE) decaltangent.rotate(rnd(360)*RAD, dir);
if(flags&DF_ROTATE) decaltangent.rotate(rnd(360)*rad, dir);
decaltangent.normalize();
decalbitangent.cross(decaltangent, dir);
if(flags&DF_RND4)
Expand Down
2 changes: 1 addition & 1 deletion src/engine/dynlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void makelightfx(extentity &e, extentity &f)
millis -= interval; e.emit[2] = lastmillis-millis;
}
if(millis >= e.emit[0]) loopi(LFX_MAX-1) if(e.attrs[4]&(1<<(LFX_S_MAX+i))) { effect = i+1; break; }
#define lightskew float skew = clamp(millis < e.emit[0] ? 1.f-(float(millis)/float(e.emit[0])) : float(millis-e.emit[0])/float(e.emit[1]), 0.f, 1.f);
#define lightskew float skew = std::clamp(millis < e.emit[0] ? 1.f-(float(millis)/float(e.emit[0])) : float(millis-e.emit[0])/float(e.emit[1]), 0.f, 1.f);
switch(effect)
{
case LFX_FLICKER:
Expand Down
6 changes: 3 additions & 3 deletions src/engine/explosion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace sphere
float ds = 1.0f/slices, dt = 1.0f/stacks, t = 1.0f;
loopi(stacks+1)
{
float rho = M_PI*(1-t), s = 0.0f, sinrho = i && i < stacks ? sin(rho) : 0, cosrho = !i ? 1 : (i < stacks ? cos(rho) : -1);
float rho = pi*(1-t), s = 0.0f, sinrho = i && i < stacks ? sin(rho) : 0, cosrho = !i ? 1 : (i < stacks ? cos(rho) : -1);
loopj(slices+1)
{
float theta = j==slices ? 0 : 2*M_PI*s;
float theta = j==slices ? 0 : 2*pi*s;
vert &v = verts[i*(slices+1) + j];
v.pos = vec(-sin(theta)*sinrho, cos(theta)*sinrho, cosrho);
v.s = ushort(s*0xFFFF);
Expand Down Expand Up @@ -216,7 +216,7 @@ struct explosionrenderer : sharedlistrenderer
t = vec(dir.x*dir.z, dir.y*dir.z, -mag2/dist);
}

matrix3 rot(lastmillis/1000.0f*143*RAD, vec(1/SQRT3, 1/SQRT3, 1/SQRT3));
matrix3 rot(lastmillis/1000.0f*143*rad, vec(1/sqrt3, 1/sqrt3, 1/sqrt3));
LOCALPARAM(texgenS, rot.transposedtransform(s));
LOCALPARAM(texgenT, rot.transposedtransform(t));

Expand Down
14 changes: 7 additions & 7 deletions src/engine/grass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ struct grasswedge

void init(int i, int n)
{
dir = vec(2*M_PI*(i+0.5f)/float(n), 0);
across = vec(2*M_PI*((i+0.5f)/float(n) + 0.25f), 0);
edge1 = vec(2*M_PI*i/float(n), 0).div(cos(M_PI/n));
edge2 = vec(2*M_PI*(i+1)/float(n), 0).div(cos(M_PI/n));
bound1 = plane(vec(2*M_PI*(i/float(n) - 0.25f), 0), 0);
bound2 = plane(vec(2*M_PI*((i+1)/float(n) + 0.25f), 0), 0);
dir = vec(2*pi*(i+0.5f)/float(n), 0);
across = vec(2*pi*((i+0.5f)/float(n) + 0.25f), 0);
edge1 = vec(2*pi*i/float(n), 0).div(cos(pi/n));
edge2 = vec(2*pi*(i+1)/float(n), 0).div(cos(pi/n));
bound1 = plane(vec(2*pi*(i/float(n) - 0.25f), 0), 0);
bound2 = plane(vec(2*pi*((i+1)/float(n) + 0.25f), 0), 0);
across.div(-across.dot(bound1));
}
};
Expand Down Expand Up @@ -77,7 +77,7 @@ FVAR(IDF_WORLD, grassanimscale, 0, 0.03f, 1);

static void animategrass()
{
loopi(numgrassoffsets) grassanimoffsets[i] = grassanimscale*sinf(2*M_PI*(grassoffsets[i] + lastmillis/float(grassanimmillis)));
loopi(numgrassoffsets) grassanimoffsets[i] = grassanimscale*sinf(2*pi*(grassoffsets[i] + lastmillis/float(grassanimmillis)));
lastgrassanim = lastmillis;
}

Expand Down
Loading