diff options
Diffstat (limited to 'src/engine/material.cpp')
| -rw-r--r-- | src/engine/material.cpp | 90 |
1 files changed, 4 insertions, 86 deletions
diff --git a/src/engine/material.cpp b/src/engine/material.cpp index 2cc8177..6fee9d3 100644 --- a/src/engine/material.cpp +++ b/src/engine/material.cpp @@ -101,9 +101,6 @@ const struct material } materials[] = { {"air", MAT_AIR}, - {"water", MAT_WATER}, {"water1", MAT_WATER}, {"water2", MAT_WATER+1}, {"water3", MAT_WATER+2}, {"water4", MAT_WATER+3}, - {"glass", MAT_GLASS}, {"glass1", MAT_GLASS}, {"glass2", MAT_GLASS+1}, {"glass3", MAT_GLASS+2}, {"glass4", MAT_GLASS+3}, - {"lava", MAT_LAVA}, {"lava1", MAT_LAVA}, {"lava2", MAT_LAVA+1}, {"lava3", MAT_LAVA+2}, {"lava4", MAT_LAVA+3}, {"clip", MAT_CLIP}, {"noclip", MAT_NOCLIP}, {"gameclip", MAT_GAMECLIP}, @@ -151,17 +148,6 @@ int visiblematerial(const cube &c, int orient, const ivec &co, int size, ushort case MAT_AIR: break; - case MAT_LAVA: - case MAT_WATER: - if(visibleface(c, orient, co, size, mat, MAT_AIR, matmask)) - return (orient != O_BOTTOM ? MATSURF_VISIBLE : MATSURF_EDIT_ONLY); - break; - - case MAT_GLASS: - if(visibleface(c, orient, co, size, MAT_GLASS, MAT_AIR, matmask)) - return MATSURF_VISIBLE; - break; - default: if(visibleface(c, orient, co, size, mat, MAT_AIR, matmask)) return MATSURF_EDIT_ONLY; @@ -284,7 +270,7 @@ int optimizematsurfs(materialsurface *matbuf, int matsurfs) cur->visible == start->visible && cur->o[dim] == start->o[dim]) ++cur; - if(start->orient != O_TOP || !vertwater) + if(start->orient != O_TOP) { if(start!=matbuf) memmove(matbuf, start, (cur-start)*sizeof(materialsurface)); matbuf += mergemats(matbuf, cur-start); @@ -336,11 +322,6 @@ static bool sortedit; static inline bool vismatcmp(const materialsurface *xm, const materialsurface *ym) { const materialsurface &x = *xm, &y = *ym; - if(!sortedit) - { - if((x.material&MATF_VOLUME) == MAT_LAVA) { if((y.material&MATF_VOLUME) != MAT_LAVA) return true; } - else if((y.material&MATF_VOLUME) == MAT_LAVA) return false; - } int xdim = dimension(x.orient), ydim = dimension(y.orient); loopi(3) { @@ -387,7 +368,6 @@ void sortmaterials(vector<materialsurface *> &vismats) { int matvol = m.material&MATF_VOLUME; if(m.visible == MATSURF_EDIT_ONLY) { i += m.skip; continue; } - if(glaring && matvol!=MAT_LAVA) { i += m.skip; continue; } } else if(glaring) continue; vismats.add(&m); @@ -410,11 +390,8 @@ void rendermatgrid(vector<materialsurface *> &vismats) { switch(m.material&~MATF_INDEX) { - case MAT_WATER: color = bvec4( 0, 0, 85, 255); break; // blue case MAT_CLIP: color = bvec4(85, 0, 0, 255); break; // red - case MAT_GLASS: color = bvec4( 0, 85, 85, 255); break; // cyan case MAT_NOCLIP: color = bvec4( 0, 85, 0, 255); break; // green - case MAT_LAVA: color = bvec4(85, 40, 0, 255); break; // orange case MAT_GAMECLIP: color = bvec4(85, 85, 0, 255); break; // yellow case MAT_DEATH: color = bvec4(40, 40, 40, 255); break; // black case MAT_ALPHA: color = bvec4(85, 0, 85, 255); break; // pink @@ -429,62 +406,6 @@ void rendermatgrid(vector<materialsurface *> &vismats) disablepolygonoffset(GL_POLYGON_OFFSET_LINE); } -#define GLASSVARS(name) \ - bvec name##color(0x20, 0x80, 0xC0); \ - HVARFR(name##colour, 0, 0x2080C0, 0xFFFFFF, \ - { \ - if(!name##colour) name##colour = 0x2080C0; \ - name##color = bvec((name##colour>>16)&0xFF, (name##colour>>8)&0xFF, name##colour&0xFF); \ - }); - -GLASSVARS(glass) -GLASSVARS(glass2) -GLASSVARS(glass3) -GLASSVARS(glass4) - -GETMATIDXVAR(glass, colour, int) -GETMATIDXVAR(glass, color, const bvec &) - -VARP(glassenv, 0, 1, 1); - -static void drawglass(const materialsurface &m, float offset) -{ - if(gle::attribbuf.empty()) - { - gle::defvertex(); - gle::defnormal(4, GL_BYTE); - gle::begin(GL_QUADS); - } - float x = m.o.x, y = m.o.y, z = m.o.z, csize = m.csize, rsize = m.rsize; - switch(m.orient) - { - #define GENFACEORIENT(orient, v0, v1, v2, v3) \ - case orient: v0 v1 v2 v3 break; - #define GENFACEVERT(orient, vert, mx,my,mz, sx,sy,sz) \ - { \ - gle::attribf(mx sx, my sy, mz sz); \ - gle::attrib(matnormals[orient]); \ - } - GENFACEVERTS(x, x, y, y, z, z, /**/, + csize, /**/, + rsize, + offset, - offset) - #undef GENFACEORIENT - #undef GENFACEVERT - } -} - -static inline void changematerial(int mat, int orient) -{ - switch(mat&~MATF_INDEX) - { - case MAT_LAVA: - if(orient==O_TOP) flushlava(); - else xtraverts += gle::end(); - break; - default: - xtraverts += gle::end(); - break; - } -} - void rendermaterials() { vector<materialsurface *> vismats; @@ -512,11 +433,8 @@ void rendermaterials() { switch(m.material&~MATF_INDEX) { - case MAT_WATER: color = bvec4(255, 128, 0, 255); break; // blue case MAT_CLIP: color = bvec4( 0, 255, 255, 255); break; // red - case MAT_GLASS: color = bvec4(255, 0, 0, 255); break; // cyan case MAT_NOCLIP: color = bvec4(255, 0, 255, 255); break; // green - case MAT_LAVA: color = bvec4( 0, 128, 255, 255); break; // orange case MAT_GAMECLIP: color = bvec4( 0, 0, 255, 255); break; // yellow case MAT_DEATH: color = bvec4(192, 192, 192, 255); break; // black case MAT_ALPHA: color = bvec4( 0, 255, 0, 255); break; // pink @@ -529,15 +447,15 @@ void rendermaterials() xtraverts += gle::end(); } - if(lastorient >= 0) changematerial(lastmat, lastorient); + if(lastorient >= 0) + if(lastmat&~MATF_INDEX) + xtraverts += gle::end(); if(!depth) glDepthMask(GL_TRUE); if(blended) glDisable(GL_BLEND); extern int wireframe; if(editmode && showmat && !drawtex && !wireframe) - { rendermatgrid(vismats); - } glEnable(GL_CULL_FACE); } |
