summaryrefslogtreecommitdiff
path: root/src/engine/texture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/texture.cpp')
-rw-r--r--src/engine/texture.cpp68
1 files changed, 4 insertions, 64 deletions
diff --git a/src/engine/texture.cpp b/src/engine/texture.cpp
index e10dae7..77eac65 100644
--- a/src/engine/texture.cpp
+++ b/src/engine/texture.cpp
@@ -1529,7 +1529,6 @@ bool settexture(const char *name, int clamp)
vector<VSlot *> vslots;
vector<Slot *> slots;
-MSlot materialslots[(MATF_VOLUME|MATF_INDEX)+1];
Slot dummyslot;
VSlot dummyvslot(&dummyslot);
@@ -1555,14 +1554,6 @@ void texturereset(int *n)
COMMAND(texturereset, "i");
-void materialreset()
-{
- if(!(identflags&IDF_OVERRIDDEN) && !game::allowedittoggle()) return;
- loopi((MATF_VOLUME|MATF_INDEX)+1) materialslots[i].reset();
-}
-
-COMMAND(materialreset, "");
-
static int compactedvslots = 0, compactvslotsprogress = 0, clonedvslots = 0;
static bool markingvslots = false;
@@ -1571,7 +1562,6 @@ void clearslots()
resetslotshader();
slots.deletecontents();
vslots.deletecontents();
- loopi((MATF_VOLUME|MATF_INDEX)+1) materialslots[i].reset();
clonedvslots = 0;
}
@@ -2033,11 +2023,9 @@ const struct slottex
{"u", TEX_UNKNOWN},
{"d", TEX_DECAL},
{"n", TEX_NORMAL},
- {"g", TEX_GLOW},
{"s", TEX_SPEC},
{"z", TEX_DEPTH},
- {"a", TEX_ALPHA},
- {"e", TEX_ENVMAP}
+ {"a", TEX_ALPHA}
};
int findslottex(const char *name)
@@ -2053,12 +2041,9 @@ void texture(char *type, char *name, int *rot, int *xoffset, int *yoffset, float
{
if(slots.length()>=0x10000) return;
static int lastmatslot = -1;
- int tnum = findslottex(type), matslot = findmaterial(type);
+ int tnum = findslottex(type);
if(tnum<0) tnum = atoi(type);
- if(tnum==TEX_DIFFUSE) lastmatslot = matslot;
- else if(lastmatslot>=0) matslot = lastmatslot;
- else if(slots.empty()) return;
- Slot &s = matslot>=0 ? materialslots[matslot] : *(tnum!=TEX_DIFFUSE ? slots.last() : slots.add(new Slot(slots.length())));
+ Slot &s = *(tnum!=TEX_DIFFUSE ? slots.last() : slots.add(new Slot(slots.length())));
s.loaded = false;
s.texmask |= 1<<tnum;
if(s.sts.length()>=8) conoutf(CON_WARN, "warning: too many textures in slot %d", slots.length()-1);
@@ -2071,7 +2056,7 @@ void texture(char *type, char *name, int *rot, int *xoffset, int *yoffset, float
if(tnum==TEX_DIFFUSE)
{
setslotshader(s);
- VSlot &vs = matslot >= 0 ? materialslots[matslot] : *emptyvslot(s);
+ VSlot &vs = *emptyvslot(s);
vs.reset();
vs.rotation = clamp(*rot, 0, 7);
vs.offset = ivec2(*xoffset, *yoffset).max(0);
@@ -2155,12 +2140,6 @@ static int findtextype(Slot &s, int type, int last = -1)
return -1;
}
-static void addglow(ImageData &c, ImageData &g, const vec &glowcolor)
-{
- if(g.bpp < 3) { readwritergbtex(c, g, loopk(3) dst[k] = clamp(int(dst[k]) + int(src[0]*glowcolor[k]), 0, 255); ); }
- else { readwritergbtex(c, g, loopk(3) dst[k] = clamp(int(dst[k]) + int(src[k]*glowcolor[k]), 0, 255); ); }
-}
-
static void mergespec(ImageData &c, ImageData &s)
{
if(s.bpp < 3) { readwritergbatex(c, s, dst[3] = src[0]; ); }
@@ -2245,10 +2224,6 @@ static Slot &loadslot(Slot &s, bool forceload)
if(t.combined >= 0) continue;
switch(t.type)
{
- case TEX_ENVMAP:
- t.t = cubemapload(t.name);
- break;
-
default:
texcombine(s, i, t, forceload);
break;
@@ -2258,19 +2233,6 @@ static Slot &loadslot(Slot &s, bool forceload)
return s;
}
-MSlot &lookupmaterialslot(int index, bool load)
-{
- if(materialslots[index].sts.empty() && index&MATF_INDEX) index &= ~MATF_INDEX;
- MSlot &s = materialslots[index];
- if(load && !s.linked)
- {
- if(!s.loaded) loadslot(s, true);
- linkvslotshader(s);
- s.linked = true;
- }
- return s;
-}
-
Slot &lookupslot(int index, bool load)
{
Slot &s = slots.inrange(index) ? *slots[index] : (slots.inrange(DEFAULT_GEOM) ? *slots[DEFAULT_GEOM] : dummyslot);
@@ -2293,11 +2255,6 @@ void linkslotshaders()
{
loopv(slots) if(slots[i]->loaded) linkslotshader(*slots[i]);
loopv(vslots) if(vslots[i]->linked) linkvslotshader(*vslots[i]);
- loopi((MATF_VOLUME|MATF_INDEX)+1) if(materialslots[i].loaded)
- {
- linkslotshader(materialslots[i]);
- linkvslotshader(materialslots[i]);
- }
}
Texture *loadthumbnail(Slot &slot)
@@ -2318,16 +2275,6 @@ Texture *loadthumbnail(Slot &slot)
defformatstring(prefix, "<thumbnail:%.2f/%.2f/%.2f>", vslot.colorscale.x, vslot.colorscale.y, vslot.colorscale.z);
addname(name, slot, slot.sts[0], false, prefix);
}
- int glow = -1;
- if(slot.texmask&(1<<TEX_GLOW))
- {
- loopvj(slot.sts) if(slot.sts[j].type==TEX_GLOW) { glow = j; break; }
- if(glow >= 0)
- {
- defformatstring(prefix, "<glow:%.2f/%.2f/%.2f>", vslot.glowcolor.x, vslot.glowcolor.y, vslot.glowcolor.z);
- addname(name, slot, slot.sts[glow], true, prefix);
- }
- }
VSlot *layer = vslot.layer ? &lookupvslot(vslot.layer, false) : NULL;
if(layer)
{
@@ -2345,7 +2292,6 @@ Texture *loadthumbnail(Slot &slot)
{
ImageData s, g, l;
texturedata(s, NULL, &slot.sts[0], false);
- if(glow >= 0) texturedata(g, NULL, &slot.sts[glow], false);
if(layer) texturedata(l, NULL, &layer->slot->sts[0], false);
if(!s.data) t = slot.thumbnail = notexture;
else
@@ -2356,7 +2302,6 @@ Texture *loadthumbnail(Slot &slot)
if(g.data)
{
if(g.w != s.w || g.h != s.h) scaleimage(g, s.w, s.h);
- addglow(s, g, vslot.glowcolor);
}
if(l.data)
{
@@ -2408,7 +2353,6 @@ void cleanuptextures()
{
loopv(slots) slots[i]->cleanup();
loopv(vslots) vslots[i]->cleanup();
- loopi((MATF_VOLUME|MATF_INDEX)+1) materialslots[i].cleanup();
enumerate(textures, Texture, tex, cleanuptexture(&tex));
}
@@ -2431,10 +2375,6 @@ bool reloadtexture(Texture &tex)
if(!texturedata(s, tex.name, NULL, true, &compress) || !newtexture(&tex, NULL, s, tex.clamp, tex.mipmap, false, false, compress)) return false;
break;
}
-
- case Texture::CUBEMAP:
- if(!cubemaploadwildcard(&tex, NULL, tex.mipmap, true)) return false;
- break;
}
return true;
}