include and translate texture slots during copy&paste

When blocks of map geometry are copy-pasted between maps (or xmaps), this
commit translates the texture slot numbers between different texture
config sets. Missing textures are assigned a slot in the target map.

When texture slots are added, automapconfig gets enabled.

If the paste gets removed by the undo function, the newly assigned texture
slots will NOT be removed. This is by design.
This commit is contained in:
ac-stef
2015-06-05 16:00:01 +02:00
parent 779df670fe
commit 3bdd199ad2
4 changed files with 95 additions and 5 deletions
+27 -2
View File
@@ -360,7 +360,23 @@ block *blockcopy(const block &s)
return b;
}
void blockpaste(const block &b, int bx, int by, bool light) // slow version, editmode only
void blocktexusage(const block &b, uchar *used)
{
const sqr *q = (const sqr *)((&b)+1);
loopirev(b.xs * b.ys)
{ // collect used texture slots in block
used[q->wtex] = 1;
if(q->type != SOLID)
{
used[q->ctex] = 1;
used[q->ftex] = 1;
used[q->utex] = 1;
}
q++;
}
}
void blockpaste(const block &b, int bx, int by, bool light, uchar *texmap) // slow version, editmode only
{
const sqr *q = (const sqr *)((&b)+1);
sqr *dest = 0;
@@ -376,7 +392,15 @@ void blockpaste(const block &b, int bx, int by, bool light) // slow version, ed
tg = dest->g;
tb = dest->b;
*dest = *q++;
*dest = *q;
if(texmap)
{ // translate texture slot numbers
dest->wtex = texmap[q->wtex];
dest->ctex = texmap[q->ctex];
dest->ftex = texmap[q->ftex];
dest->utex = texmap[q->utex];
}
if (light) //edit mode paste
{
@@ -384,6 +408,7 @@ void blockpaste(const block &b, int bx, int by, bool light) // slow version, ed
dest->g = tg;
dest->b = tb;
}
q++;
}
block bb = { bx, by, b.xs, b.ys };
remipmore(bb);